ci: support sonatype user token for publishing #100
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration Test | |
on: | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
checks: write | |
pull-requests: write | |
id-token: write | |
env: | |
iam_role_to_assume: ${{ secrets.ROLE_ARN }} | |
device_farm_project_arn: ${{ secrets.DEVICE_FARM_PROJECT_ARN }} | |
device_farm_pool_arn: ${{ secrets.DEVICE_FARM_POOL_ARN }} | |
device_farm_test_spec_arn: ${{ secrets.DEVICE_FARM_TEST_SPEC_ARN }} | |
clickstream_app_id: ${{ secrets.CLICKSTREAM_APP_ID }} | |
clickstream_endpoint: ${{ secrets.CLICKSTREAM_ENDPOINT }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '8' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Build SDK release aar file | |
run: | | |
chmod +x gradlew | |
./gradlew assembleRelease | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Build sample android app | |
run: | | |
git clone https://github.com/aws-samples/clickstream-sdk-samples | |
mkdir clickstream-sdk-samples/android/app/libs/ | |
cp -f clickstream/build/outputs/aar/clickstream-release.aar clickstream-sdk-samples/android/app/libs/ | |
cd clickstream-sdk-samples/android | |
sed -i "s#\"appId\": \"your appId\"#\"appId\": \"${{ env.clickstream_app_id }}\"#g" app/src/main/res/raw/amplifyconfiguration.json | |
sed -i "s#\"endpoint\": \"your endpoint\"#\"endpoint\": \"${{ env.clickstream_endpoint }}\"#g" app/src/main/res/raw/amplifyconfiguration.json | |
cat app/src/main/res/raw/amplifyconfiguration.json | |
sed -i "s#implementation 'software.aws.solution:clickstream:0.10.0'#implementation(files(\"libs/clickstream-release.aar\"))\n implementation(\"com.amplifyframework:core:1.37.2\")\n implementation(\"com.amazonaws:aws-android-sdk-mobile-client:2.51.0\")\n implementation(\"com.squareup.okhttp3:okhttp:4.9.1\")#g" app/build.gradle | |
cat app/build.gradle | |
./gradlew assembleDebug | |
- name: Build Device Farm test file | |
run: | | |
cd integrationtest | |
pip install virtualenv | |
virtualenv --help | |
virtualenv workspace | |
cd workspace | |
source bin/activate | |
pip install -r ../requirements.txt | |
mkdir tests | |
cp ../appium/shopping_test.py tests/ | |
find tests/ | |
py.test --collect-only tests/ | |
find . -name '__pycache__' -type d -exec rm -r {} + | |
find . -name '*.pyc' -exec rm -f {} + | |
find . -name '*.pyo' -exec rm -f {} + | |
find . -name '*~' -exec rm -f {} + | |
pip freeze > requirements.txt | |
zip -r test_bundle.zip tests/ requirements.txt | |
ls | |
cd .. | |
- name: Configure AWS Credentials | |
if: ${{ env.iam_role_to_assume != '' }} | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ env.iam_role_to_assume }} | |
aws-region: us-west-2 | |
- name: Execute device farm test | |
run: | | |
cd integrationtest | |
pip install -r requirements.txt | |
cd devicefarm | |
cp ../../clickstream-sdk-samples/android/app/build/outputs/apk/debug/app-debug.apk ./ | |
cp ../workspace/test_bundle.zip ./ | |
ls | |
python -u -c "from automate_device_farm import upload_and_test_android; upload_and_test_android('app-debug.apk', 'test_bundle.zip', '${{ env.device_farm_project_arn }}', '${{ env.device_farm_test_spec_arn }}', '${{ env.device_farm_pool_arn }}')" | |
- name: Execute logcat test | |
run: | | |
cd integrationtest/devicefarm | |
pytest logcat_test.py -s --junitxml=report/logcat_test_report.xml --html=report/logcat_test_report.html | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: success() || failure() | |
with: | |
report_paths: 'integrationtest/devicefarm/report/*.xml' | |
require_tests: true | |
detailed_summary: true | |
include_passed: true | |
fail_on_failure: true | |
job_name: integration test | |
- name: Upload test result | |
uses: actions/upload-artifact@v4 | |
if: success() || failure() | |
with: | |
name: test-result | |
path: | | |
integrationtest/devicefarm/report/ | |
integrationtest/devicefarm/MyAndroidAppTest-*/** |