Skip to content

Commit e500fa9

Browse files
xiaoweiizxkane
authored andcommitted
ci: enable github actions.
1 parent ebc148a commit e500fa9

File tree

6 files changed

+189
-26
lines changed

6 files changed

+189
-26
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Android SDK Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: set up JDK 8
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: '8'
18+
distribution: 'temurin'
19+
cache: gradle
20+
- name: Grant execute permission for gradlew
21+
run: chmod +x gradlew
22+
- name: Build with Gradle
23+
run: ./gradlew build -p clickstream
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Run Code coverage
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: set up JDK 8
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: '8'
18+
distribution: 'temurin'
19+
cache: gradle
20+
- name: Grant execute permission for gradlew
21+
run: chmod +x gradlew
22+
- name: Generate test report
23+
run: ./gradlew jacocoTestReport
24+
- name: Upload test result
25+
uses: actions/upload-artifact@v3
26+
if: success() || failure()
27+
with:
28+
name: test-result
29+
path: |
30+
clickstream/build/reports/
31+
clickstream/build/test-results/
32+
- name: Upload Test Report
33+
uses: codecov/codecov-action@v3
34+
with:
35+
name: report
36+
files: clickstream/build/reports/jacoco/jacoco.xml

.github/workflows/lint.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Commit Title Lint
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: amannn/action-semantic-pull-request@v3.2.6
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
# Configure which types are allowed.
18+
# Default: https://github.com/commitizen/conventional-commit-types
19+
types: |
20+
fix
21+
feat
22+
docs
23+
style
24+
refactor
25+
perf
26+
test
27+
build
28+
ci
29+
chore
30+
revert
31+
release
32+
# Configure which scopes are allowed.
33+
scopes: |
34+
deps-dev
35+
deps
36+
inference
37+
dashboard
38+
model
39+
core
40+
ui
41+
docs
42+
# Configure that a scope must always be provided.
43+
requireScope: false
44+
# Configure additional validation for the subject based on a regex.
45+
# This example ensures the subject doesn't start with an uppercase character.
46+
subjectPattern: ^(?![A-Z]).+$
47+
# If `subjectPattern` is configured, you can use this property to override
48+
# the default error message that is shown when the pattern doesn't match.
49+
# The variables `subject` and `title` can be used within the message.
50+
subjectPatternError: |
51+
The subject "{subject}" found in the pull request title "{title}"
52+
didn't match the configured pattern. Please ensure that the subject
53+
doesn't start with an uppercase character.
54+
# For work-in-progress PRs you can typically use draft pull requests
55+
# from Github. However, private repositories on the free plan don't have
56+
# this option and therefore this action allows you to opt-in to using the
57+
# special "[WIP]" prefix to indicate this state. This will avoid the
58+
# validation of the PR title and the pull request checks remain pending.
59+
# Note that a second check will be reported if this is enabled.
60+
wip: true

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ ext {
6464
junit: 'junit:junit:4.13.2',
6565
mockito: 'org.mockito:mockito-core:3.1.0',
6666
moco: 'com.github.dreamhead:moco-core:1.4.0',
67-
robolectric: 'org.robolectric:robolectric:4.7.3',
67+
robolectric: 'org.robolectric:robolectric:4.9.2',
6868
]
6969
}
7070

7171
subprojects { project ->
7272
afterEvaluate {
7373
configAndroidLibrary(project)
7474
project.apply from: '../jacoco.gradle'
75-
project.apply from: '../publishing.gradle'
7675
}
7776
}
7877

gradle.properties

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,19 @@ org.gradle.jvmargs=-Xmx4g
1313
org.gradle.parallel=true
1414

1515
VERSION_NAME=0.3.0
16-
POM_GROUP=com.amazonaws.solution
16+
17+
POM_GROUP=software.aws.solution
1718
POM_ARTIFACT_ID=clickstream
19+
POM_NAME=clickstream analytics android sdk
20+
POM_DESCRIPTION=android sdk for clickstream analytics to collect and send event
21+
POM_URL=https://github.com/awslabs/clickstream-android
22+
POM_SCM_URL=https://github.com/awslabs/clickstream-android
23+
POM_SCM_CONNECTION=scm:git:git://github.com/awslabs/clickstream-android.git
24+
POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/awslabs/clickstream-android.git
25+
26+
POM_DEVELOPER_ID=aws-gcr-solution
27+
POM_DEVELOPER_ORGANIZATION_URL=https://aws.amazon.com/cn/solutions
28+
1829
VERSION_CODE=1
1930
android.useAndroidX=true
2031
android.enableJetifier=false

publishing.gradle

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ apply plugin: 'maven-publish'
1919

2020
version = project.ext.VERSION_NAME
2121
group = POM_GROUP
22+
def keyFile = rootProject.file("key.properties")
23+
def keyProp = new Properties()
24+
keyProp.load(keyFile.newInputStream())
2225

2326
afterEvaluate { project ->
2427
publishing {
@@ -28,37 +31,68 @@ afterEvaluate { project ->
2831
groupId POM_GROUP
2932
artifactId POM_ARTIFACT_ID
3033
version project.ext.VERSION_NAME
34+
3135
artifact("${buildDir}/outputs/aar/${artifactId}-release.aar")
3236
println "publish ${buildDir}/outputs/aar/${artifactId}-release.aar"
33-
pom.withXml {
34-
def dependenciesNode = asNode().appendNode('dependencies')
35-
// Note that this only handles implementation
36-
// dependencies. In the future, may need to add api,
37-
// etc.
38-
configurations.implementation.allDependencies.each {
39-
def dependencyNode = dependenciesNode.appendNode('dependency')
40-
dependencyNode.appendNode('groupId', it.group)
41-
dependencyNode.appendNode('artifactId', it.name)
42-
dependencyNode.appendNode('version', it.version)
37+
38+
pom {
39+
name = POM_NAME
40+
description = POM_DESCRIPTION
41+
url = POM_URL
42+
43+
scm {
44+
url = POM_SCM_URL
45+
connection = POM_SCM_CONNECTION
46+
developerConnection = POM_SCM_DEV_CONNECTION
47+
}
48+
49+
licenses {
50+
license {
51+
name = 'The Apache License, Version 2.0'
52+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
53+
distribution = 'repo'
54+
}
55+
}
56+
57+
developers {
58+
developer {
59+
id = POM_DEVELOPER_ID
60+
organizationUrl = POM_DEVELOPER_ORGANIZATION_URL
61+
roles = ["developer"]
62+
}
63+
}
64+
65+
withXml {
66+
def dependenciesNode = asNode().appendNode('dependencies')
67+
// Note that this only handles implementation
68+
// dependencies. In the future, may need to add api,
69+
// etc.
70+
configurations.implementation.allDependencies.each {
71+
def dependencyNode = dependenciesNode.appendNode('dependency')
72+
dependencyNode.appendNode('groupId', it.group)
73+
dependencyNode.appendNode('artifactId', it.name)
74+
dependencyNode.appendNode('version', it.version)
75+
}
4376
}
4477
}
4578
}
4679
}
4780
repositories {
48-
def keyFile = rootProject.file("key.properties")
49-
def keyProp = new Properties()
50-
keyProp.load(keyFile.newInputStream())
51-
maven { // Add Gitlab repo for aws-analytics-web-analytics
52-
url keyProp.getProperty("projectUrl")
53-
name "GitLab"
54-
credentials(HttpHeaderCredentials) {
55-
name = 'Private-Token'
56-
value = keyProp.getProperty("gitLabPrivateToken")
57-
}
58-
authentication {
59-
header(HttpHeaderAuthentication)
81+
maven {
82+
url = "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/"
83+
credentials {
84+
username = keyProp.getProperty("nexusUsername")
85+
password = keyProp.getProperty("nexusPassword")
6086
}
6187
}
6288
}
6389
}
64-
}
90+
91+
signing {
92+
def signingPassword = keyProp.getProperty("signing.password")
93+
def keyId = keyProp.getProperty("signing.keyId")
94+
def signingKey = keyProp.getProperty("signing.inMemoryKey").replace("\\n", "\n")
95+
useInMemoryPgpKeys(keyId, signingKey, signingPassword)
96+
sign publishing.publications.library
97+
}
98+
}

0 commit comments

Comments
 (0)