diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 544dfed..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,189 +0,0 @@ -# -# Copyright 2022 Adobe. All rights reserved. -# This file is licensed to you under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. You may obtain a copy -# of the License at http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under -# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS -# OF ANY KIND, either express or implied. See the License for the specific language -# governing permissions and limitations under the License. -# - -version: 2.1 -orbs: - # Use the circleci android orb version that supports OpenJDK17 required by AGP 8.2+ - android: circleci/android@2.4.0 - codecov: codecov/codecov@4.0.1 - -parameters: - gradle-cache-prefix: - type: string - default: v1 - build-cache-prefix: - type: string - default: v1 - build-path: - type: string - default: "code/analytics/build" - -# Workflows orchestrate a set of jobs to be run; -workflows: - version: 2 - build-test-deploy: - jobs: - - validate-code - - build-and-unit-test: - requires: - - validate-code - - functional-test: - requires: - - validate-code - - build-test-app: - requires: - - validate-code - filters: - branches: - only: - - main - - staging - -jobs: - validate-code: - executor: - name: android/android-docker - resource-class: medium - tag: 2024.01.1 - - steps: - - checkout - - - android/restore-gradle-cache: - cache-prefix: << pipeline.parameters.gradle-cache-prefix >> - - - android/restore-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> - - - run: - name: Check Format - command: make checkformat - - - run: - name: Check Style - command: make checkstyle - - - android/save-gradle-cache: - cache-prefix: << pipeline.parameters.gradle-cache-prefix >> - - - android/save-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> - - - store_artifacts: - path: << pipeline.parameters.build-path >>/reports - - build-and-unit-test: - executor: - name: android/android-docker - resource-class: medium - tag: 2024.01.1 - - steps: - - checkout - - - android/restore-gradle-cache: - cache-prefix: << pipeline.parameters.gradle-cache-prefix >> - - - android/restore-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> - - - run: - name: Javadoc - command: make javadoc - - - store_artifacts: - path: << pipeline.parameters.build-path >>/docs/javadoc - - - run: - name: Assemble Phone - command: make assemble-phone - - - android/run-tests: - test-command: make unit-test-coverage - - - android/save-gradle-cache: - cache-prefix: << pipeline.parameters.gradle-cache-prefix >> - - - android/save-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> - - - store_artifacts: - path: << pipeline.parameters.build-path >>/reports/tests - - - store_test_results: - path: << pipeline.parameters.build-path >>/test-results/testPhoneDebugUnitTest - - - codecov/upload: - file: << pipeline.parameters.build-path >>/reports/coverage/test/phone/debug/report.xml - flags: unit-tests - - functional-test: - executor: - name: android/android-machine - resource-class: medium - tag: 2024.01.1 - - steps: - - checkout - - - android/restore-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> - - - run: - name: List available emulator images - command: sdkmanager --list - - - android/start-emulator-and-run-tests: - # It should match the name seen in the "sdkmanager --list" output - system-image: system-images;android-29;default;x86 - # The command to be run, while waiting for emulator startup - post-emulator-launch-assemble-command: make assemble-phone - # The test command - test-command: make functional-test-coverage - restore-gradle-cache-prefix: << pipeline.parameters.gradle-cache-prefix >> - - - android/save-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> - - - codecov/upload: - file: << pipeline.parameters.build-path >>/reports/coverage/androidTest/phone/debug/connected/report.xml - flags: functional-tests - - - store_artifacts: - path: << pipeline.parameters.build-path >>/reports/androidTests - - - store_test_results: - path: << pipeline.parameters.build-path >>/outputs/androidTest-results - - build-test-app: - - executor: - name: android/android-docker - resource-class: medium - tag: 2024.01.1 - - steps: - - checkout - - - android/restore-gradle-cache: - cache-prefix: << pipeline.parameters.gradle-cache-prefix >> - - android/restore-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> - - - run: - name: Assemble App - command: make assemble-app - - - android/save-gradle-cache: - cache-prefix: << pipeline.parameters.gradle-cache-prefix >> - - android/save-build-cache: - cache-prefix: << pipeline.parameters.build-cache-prefix >> \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/workflows/build-and-test.yml similarity index 55% rename from .github/release-drafter.yml rename to .github/workflows/build-and-test.yml index e053484..21e4b8a 100644 --- a/.github/release-drafter.yml +++ b/.github/workflows/build-and-test.yml @@ -1,5 +1,5 @@ # -# Copyright 2024 Adobe. All rights reserved. +# Copyright 2025 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy # of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -10,7 +10,20 @@ # governing permissions and limitations under the License. # -template: | - ## What’s Changed +name: Build and Test - $CHANGES \ No newline at end of file +on: + pull_request: + +jobs: + build-and-test: + name: "CI" + uses: adobe/aepsdk-commons/.github/workflows/android-build-and-test.yml@gha-android-3.3.0 + with: + android-api-levels: '[29]' + run-test-unit: true + run-test-functional: true + run-build-app: true + enable-codecov: true + javadoc-build-path: code/analytics/build/dokka/javadoc + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml index 3a95b8f..75ac2b7 100644 --- a/.github/workflows/maven-release.yml +++ b/.github/workflows/maven-release.yml @@ -11,66 +11,34 @@ # name: Publish Release + on: workflow_dispatch: inputs: tag: - description: 'tag/version' - required: true - - action_tag: - description: 'Create tag? ("no" to skip)' + description: 'The tag (version) to be released (ex: 1.2.3).' + type: string required: true - default: 'yes' -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache Gradle packages - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - - - name: Verify version - run: | - set -eo pipefail - echo Release version: ${{ github.event.inputs.tag }} - (./scripts/version.sh -v ${{ github.event.inputs.tag }}) + create-github-release: + description: 'Create GitHub release using tag. If the provided `tag` does not exist, it will be created.' + type: boolean + required: true + default: true - - name: Create GH Release - id: create_release - uses: release-drafter/release-drafter@v5 - if: ${{ github.event.inputs.action_tag == 'yes' }} - with: - name: v${{ github.event.inputs.tag }} - tag: v${{ github.event.inputs.tag }} - version: v${{ github.event.inputs.tag }} - publish: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Import GPG key - env: - GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }} - GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }} - run: | - echo $GPG_SECRET_KEYS | base64 --decode | gpg --import --no-tty --batch --yes - echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes + core-dependency: + description: 'The Core dependency version in gradle.properties to be validated (ex: 1.2.3).' + type: string + required: true - - name: Publish to Maven Central Repository - run: make ci-publish - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} +jobs: + publish: + permissions: + contents: write + uses: adobe/aepsdk-commons/.github/workflows/android-maven-release.yml@gha-android-3.3.0 + with: + tag: ${{ github.event.inputs.tag }} + create-github-release: ${{ github.event.inputs.create-github-release == 'true' }} + version-validation-paths: code/gradle.properties, code/analytics/src/main/java/com/adobe/marketing/mobile/analytics/internal/AnalyticsConstants.kt + version-validation-dependencies: Core ${{ github.event.inputs.core-dependency }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/maven-snapshot.yml b/.github/workflows/maven-snapshot.yml index 1a19c19..c0f398d 100644 --- a/.github/workflows/maven-snapshot.yml +++ b/.github/workflows/maven-snapshot.yml @@ -11,37 +11,13 @@ # name: Publish Snapshot -on: + +on: workflow_dispatch: jobs: publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - name: Cache Gradle packages - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - - name: Import GPG key - env: - GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }} - GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }} - run: | - echo $GPG_SECRET_KEYS | base64 --decode | gpg --import --no-tty --batch --yes - echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes - - name: Publish to Maven Snapshot Repository - run: make ci-publish-staging - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} + permissions: + contents: write + uses: adobe/aepsdk-commons/.github/workflows/android-maven-snapshot.yml@gha-android-3.3.0 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml index eace367..4e549ea 100644 --- a/.github/workflows/update-version.yml +++ b/.github/workflows/update-version.yml @@ -10,36 +10,38 @@ # governing permissions and limitations under the License. # -name: Update Version +name: Update Versions + on: workflow_dispatch: inputs: - version: - description: 'New version to use for the Analytics extension. Example: 3.0.0' + version: + description: 'New version to use for the extension (ex: 1.2.3).' + type: string + required: true + + branch: + description: 'The target branch where the version update will be applied and the pull request will be merged into.' + type: string required: true core-dependency: - description: '[Optional] Update Core dependency in pom.xml. Example: 3.0.0' + description: | + If a version is provided, update Core dependency in gradle.properties (ex: 1.2.3). + This is a published dependency in the pom.xml file. + type: string required: false + default: '' jobs: - update-version: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Update Analytics - run: (./scripts/version.sh -u -v ${{ github.event.inputs.version }} -d "Core ${{ github.event.inputs.core-dependency }},") - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ github.token }} - commit-message: Updating version to ${{ github.event.inputs.version }}. - branch: version-${{ github.event.inputs.version }}-update - delete-branch: true - title: Updating version to ${{ github.event.inputs.version }} - body: Updating version to ${{ github.event.inputs.version }} - + update-versions: + permissions: + contents: write + pull-requests: write + uses: adobe/aepsdk-commons/.github/workflows/versions.yml@gha-android-3.3.0 + with: + version: ${{ github.event.inputs.version }} + branch: ${{ github.event.inputs.branch }} + dependencies: Core ${{ github.event.inputs.core-dependency }} + paths: code/gradle.properties, code/analytics/src/main/java/com/adobe/marketing/mobile/analytics/internal/AnalyticsConstants.kt + update: true \ No newline at end of file diff --git a/Makefile b/Makefile index 1fcc7a9..a705cf7 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,9 @@ checkformat: checkstyle: (./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) checkstyle) +# Used by build and test CI workflow +lint: checkformat checkstyle + unit-test: (./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) testPhoneDebugUnitTest) diff --git a/scripts/version.sh b/scripts/version.sh deleted file mode 100755 index 55c19e1..0000000 --- a/scripts/version.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash - -# Make this script executable from terminal: -# chmod 755 version.sh -set -e # Any subsequent(*) commands which fail will cause the shell script to exit immediately - -ROOT_DIR=$(git rev-parse --show-toplevel) -LINE="================================================================================" -VERSION_REGEX="[0-9]+\.[0-9]+\.[0-9]+" - -GRADLE_PROPERTIES_FILE=$ROOT_DIR"/code/gradle.properties" -CONSTANTS_FILE=$ROOT_DIR"/code/analytics/src/main/java/com/adobe/marketing/mobile/analytics/internal/AnalyticsConstants.kt" -# Java files -#EXTENSION_VERSION_REGEX="^.*String EXTENSION_VERSION *= *" -# Kotlin files -EXTENSION_VERSION_REGEX="^ +const val EXTENSION_VERSION *= *" - -help() -{ - echo "" - echo "Usage: $0 -v VERSION -d DEPENDENCIES" - echo "" - echo -e " -v\t- Version to update or verify for the extension. \n\t Example: 3.0.2\n" - echo -e " -d\t- Comma seperated dependecies to update along with their version. \n\t Example: "Core 3.1.1, Edge 3.2.1"\n" - echo -e " -u\t- Updates the version. If this flag is absent, the script verifies if the version is correct\n" - exit 1 # Exit script after printing help -} - -sed_platform() { - # Ensure sed works properly in linux and mac-os. - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' "$@" - else - sed -i "$@" - fi -} - -update() { - echo "Changing version to $VERSION" - - # Replace version in Constants file - echo "Changing 'EXTENSION_VERSION' to '$VERSION' in '$CONSTANTS_FILE'" - sed_platform -E "/$EXTENSION_VERSION_REGEX/{s/$VERSION_REGEX/$VERSION/;}" $CONSTANTS_FILE - - # Replace version in gradle.properties - echo "Changing 'moduleVersion' to '$VERSION' in '$GRADLE_PROPERTIES_FILE'" - sed_platform -E "/^moduleVersion/{s/$VERSION_REGEX/$VERSION/;}" $GRADLE_PROPERTIES_FILE - - # Replace dependencies in gradle.properties - if [ "$DEPENDENCIES" != "none" ]; then - IFS="," - dependenciesArray=($(echo "$DEPENDENCIES")) - - IFS=" " - for dependency in "${dependenciesArray[@]}"; do - dependencyArray=(${dependency// / }) - dependencyName=${dependencyArray[0]} - dependencyVersion=${dependencyArray[1]} - - if [ "$dependencyVersion" != "" ]; then - echo "Changing 'maven${dependencyName}Version' to '$dependencyVersion' in '$GRADLE_PROPERTIES_FILE'" - sed_platform -E "/^maven${dependencyName}Version/{s/$VERSION_REGEX/$dependencyVersion/;}" $GRADLE_PROPERTIES_FILE - fi - done - fi -} - -verify() { - echo "Verifing version is $VERSION" - - if ! grep -E "$EXTENSION_VERSION_REGEX\"$VERSION\"" "$CONSTANTS_FILE" >/dev/null; then - echo "'EXTENSION_VERSION' does not match '$VERSION' in '$CONSTANTS_FILE'" - exit 1 - fi - - if ! grep -E "^moduleVersion=.*$VERSION" "$GRADLE_PROPERTIES_FILE" >/dev/null; then - echo "'moduleVersion' does not match '$VERSION' in '$GRADLE_PROPERTIES_FILE'" - exit 1 - fi - - if [ "$DEPENDENCIES" != "none" ]; then - IFS="," - dependenciesArray=($(echo "$DEPENDENCIES")) - - IFS=" " - for dependency in "${dependenciesArray[@]}"; do - dependencyArray=(${dependency// / }) - dependencyName=${dependencyArray[0]} - dependencyVersion=${dependencyArray[1]} - - if [ "$dependencyVersion" != "" ]; then - if ! grep -E "^maven${dependencyName}Version=.*$dependencyVersion" "$GRADLE_PROPERTIES_FILE" >/dev/null; then - echo "maven${dependencyName}Version does not match '$dependencyVersion' in '$GRADLE_PROPERTIES_FILE'" - exit 1 - fi - fi - done - fi - - echo "Success" -} - - -while getopts "v:d:u" opt -do - case "$opt" in - v ) VERSION="$OPTARG" ;; - d ) DEPENDENCIES="$OPTARG" ;; - u ) UPDATE="true" ;; - ? ) help ;; # Print help in case parameter is non-existent - esac -done - -# Print help in case parameters are empty -if [ -z "$VERSION" ] -then - echo "********** USAGE ERROR **********" - echo "Some or all of the parameters are empty. See usage below:"; - help -fi - - - -echo "$LINE" -if [[ ${UPDATE} = "true" ]]; -then - update -else - verify -fi -echo "$LINE" \ No newline at end of file