diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..dec6263 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml new file mode 100644 index 0000000..5154741 --- /dev/null +++ b/.github/workflows/code_coverage.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d80cd75 --- /dev/null +++ b/.github/workflows/lint.yml @@ -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/action-semantic-pull-request@v3.2.6 + 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 diff --git a/build.gradle b/build.gradle index a3394f6..d2de166 100644 --- a/build.gradle +++ b/build.gradle @@ -64,7 +64,7 @@ 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', ] } @@ -72,7 +72,6 @@ subprojects { project -> afterEvaluate { configAndroidLibrary(project) project.apply from: '../jacoco.gradle' - project.apply from: '../publishing.gradle' } } diff --git a/gradle.properties b/gradle.properties index 111a9f5..62063fe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/publishing.gradle b/publishing.gradle index 5b042e2..03d6bb5 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -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 { @@ -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 + } +} \ No newline at end of file