Skip to content

Commit

Permalink
ci: enable github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoweii authored and zxkane committed Apr 6, 2023
1 parent ebc148a commit e500fa9
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 26 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Android SDK Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -p clickstream
36 changes: 36 additions & 0 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run Code coverage

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Generate test report
run: ./gradlew jacocoTestReport
- name: Upload test result
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-result
path: |
clickstream/build/reports/
clickstream/build/test-results/
- name: Upload Test Report
uses: codecov/codecov-action@v3
with:
name: report
files: clickstream/build/reports/jacoco/jacoco.xml
60 changes: 60 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Commit Title Lint

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed.
# Default: https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
docs
style
refactor
perf
test
build
ci
chore
revert
release
# Configure which scopes are allowed.
scopes: |
deps-dev
deps
inference
dashboard
model
core
ui
docs
# Configure that a scope must always be provided.
requireScope: false
# Configure additional validation for the subject based on a regex.
# This example ensures the subject doesn't start with an uppercase character.
subjectPattern: ^(?![A-Z]).+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
# For work-in-progress PRs you can typically use draft pull requests
# from Github. However, private repositories on the free plan don't have
# this option and therefore this action allows you to opt-in to using the
# special "[WIP]" prefix to indicate this state. This will avoid the
# validation of the PR title and the pull request checks remain pending.
# Note that a second check will be reported if this is enabled.
wip: true
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ ext {
junit: 'junit:junit:4.13.2',
mockito: 'org.mockito:mockito-core:3.1.0',
moco: 'com.github.dreamhead:moco-core:1.4.0',
robolectric: 'org.robolectric:robolectric:4.7.3',
robolectric: 'org.robolectric:robolectric:4.9.2',
]
}

subprojects { project ->
afterEvaluate {
configAndroidLibrary(project)
project.apply from: '../jacoco.gradle'
project.apply from: '../publishing.gradle'
}
}

Expand Down
13 changes: 12 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ org.gradle.jvmargs=-Xmx4g
org.gradle.parallel=true

VERSION_NAME=0.3.0
POM_GROUP=com.amazonaws.solution

POM_GROUP=software.aws.solution
POM_ARTIFACT_ID=clickstream
POM_NAME=clickstream analytics android sdk
POM_DESCRIPTION=android sdk for clickstream analytics to collect and send event
POM_URL=https://github.com/awslabs/clickstream-android
POM_SCM_URL=https://github.com/awslabs/clickstream-android
POM_SCM_CONNECTION=scm:git:git://github.com/awslabs/clickstream-android.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/awslabs/clickstream-android.git

POM_DEVELOPER_ID=aws-gcr-solution
POM_DEVELOPER_ORGANIZATION_URL=https://aws.amazon.com/cn/solutions

VERSION_CODE=1
android.useAndroidX=true
android.enableJetifier=false
80 changes: 57 additions & 23 deletions publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ apply plugin: 'maven-publish'

version = project.ext.VERSION_NAME
group = POM_GROUP
def keyFile = rootProject.file("key.properties")
def keyProp = new Properties()
keyProp.load(keyFile.newInputStream())

afterEvaluate { project ->
publishing {
Expand All @@ -28,37 +31,68 @@ afterEvaluate { project ->
groupId POM_GROUP
artifactId POM_ARTIFACT_ID
version project.ext.VERSION_NAME

artifact("${buildDir}/outputs/aar/${artifactId}-release.aar")
println "publish ${buildDir}/outputs/aar/${artifactId}-release.aar"
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Note that this only handles implementation
// dependencies. In the future, may need to add api,
// etc.
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)

pom {
name = POM_NAME
description = POM_DESCRIPTION
url = POM_URL

scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}

developers {
developer {
id = POM_DEVELOPER_ID
organizationUrl = POM_DEVELOPER_ORGANIZATION_URL
roles = ["developer"]
}
}

withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Note that this only handles implementation
// dependencies. In the future, may need to add api,
// etc.
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
repositories {
def keyFile = rootProject.file("key.properties")
def keyProp = new Properties()
keyProp.load(keyFile.newInputStream())
maven { // Add Gitlab repo for aws-analytics-web-analytics
url keyProp.getProperty("projectUrl")
name "GitLab"
credentials(HttpHeaderCredentials) {
name = 'Private-Token'
value = keyProp.getProperty("gitLabPrivateToken")
}
authentication {
header(HttpHeaderAuthentication)
maven {
url = "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = keyProp.getProperty("nexusUsername")
password = keyProp.getProperty("nexusPassword")
}
}
}
}
}

signing {
def signingPassword = keyProp.getProperty("signing.password")
def keyId = keyProp.getProperty("signing.keyId")
def signingKey = keyProp.getProperty("signing.inMemoryKey").replace("\\n", "\n")
useInMemoryPgpKeys(keyId, signingKey, signingPassword)
sign publishing.publications.library
}
}

0 comments on commit e500fa9

Please sign in to comment.