Update Test #155
This file contains hidden or 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: Update Test | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # Runs every work day at 01:00 UTC (02:00 Europe CET) | |
| - cron: "0 1 * * 1-5" | |
| permissions: | |
| # Only need read access to repository contents | |
| contents: read | |
| jobs: | |
| create_ocis: | |
| uses: ./.github/workflows/ocisbackend.yml | |
| with: | |
| ocis_version: ${{ vars.OCIS_VERSION }} | |
| secrets: | |
| ocis_url: ${{ secrets.OC_SERVER_URL }} | |
| ssh_host: ${{ secrets.SSH_HOST }} | |
| ssh_user: ${{ secrets.SSH_USER }} | |
| ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| ocis_pwd: ${{ secrets.OCIS_PWD }} | |
| build_apk_latest: | |
| uses: owncloud/android/.github/workflows/build-apk.yml@master | |
| with: | |
| build_variant: qaRelease | |
| version: latest | |
| build_apk_master: | |
| uses: owncloud/android/.github/workflows/build-apk.yml@master | |
| with: | |
| build_variant: qaRelease | |
| version: master | |
| sign_latest: | |
| name: Align and sign latest APK | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build_apk_latest | |
| env: | |
| BUILD_TOOLS_VERSION: "34.0.0" | |
| steps: | |
| - name: Download latest APK artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| name: ${{ needs.build_apk_latest.outputs.artifact_name }} | |
| path: ./ | |
| - name: Move latest APK to root directory | |
| run: cp ./${{ needs.build_apk_latest.outputs.artifact_name }} ./owncloud-latest.apk | |
| - name: Restore keystore | |
| run: | | |
| echo "${{ secrets.TEST_KS_B64 }}" | base64 -d > ./test.keystore | |
| - name: Align and sign latest APK | |
| shell: bash | |
| env: | |
| KEY_ALIAS: ${{ secrets.TEST_KS_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.TEST_KS_KEY }} | |
| run: | | |
| APK_INPUT="owncloud-latest.apk" | |
| APK_ALIGNED="owncloud-latest-aligned.apk" | |
| APK_SIGNED="owncloudSigned-latest.apk" | |
| KEYSTORE="./test.keystore" | |
| echo "Aligning APK..." | |
| $ANDROID_SDK_ROOT/build-tools/${{ env.BUILD_TOOLS_VERSION }}/zipalign -v -p 4 "$APK_INPUT" "$APK_ALIGNED" | |
| echo "Signing APK..." | |
| $ANDROID_SDK_ROOT/build-tools/${{ env.BUILD_TOOLS_VERSION }}/apksigner sign \ | |
| --ks "$KEYSTORE" \ | |
| --ks-pass pass:"$KEY_PASSWORD" \ | |
| --key-pass pass:"$KEY_PASSWORD" \ | |
| --ks-key-alias "$KEY_ALIAS" \ | |
| --ks-type PKCS12 \ | |
| --out "$APK_SIGNED" \ | |
| "$APK_ALIGNED" | |
| $ANDROID_SDK_ROOT/build-tools/${{ env.BUILD_TOOLS_VERSION }}/apksigner verify "$APK_SIGNED" | |
| rm -f "$APK_ALIGNED" | |
| rm -f ./test.keystore | |
| - name: Upload signed latest APK | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: owncloudSigned-latest | |
| path: ./owncloudSigned-latest.apk | |
| retention-days: 2 | |
| sign_master: | |
| name: Align and sign master APK | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build_apk_master | |
| env: | |
| BUILD_TOOLS_VERSION: "34.0.0" | |
| steps: | |
| - name: Download master APK artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| name: ${{ needs.build_apk_master.outputs.artifact_name }} | |
| path: ./ | |
| - name: Move master APK to root directory | |
| run: cp ./${{ needs.build_apk_master.outputs.artifact_name }} ./owncloud-master.apk | |
| - name: Restore keystore | |
| run: | | |
| echo "${{ secrets.TEST_KS_B64 }}" | base64 -d > ./test.keystore | |
| - name: Align and sign master APK | |
| shell: bash | |
| env: | |
| KEY_ALIAS: ${{ secrets.TEST_KS_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.TEST_KS_KEY }} | |
| run: | | |
| APK_INPUT="owncloud-master.apk" | |
| APK_ALIGNED="owncloud-master-aligned.apk" | |
| APK_SIGNED="owncloudSigned-master.apk" | |
| KEYSTORE="./test.keystore" | |
| echo "Aligning APK..." | |
| $ANDROID_SDK_ROOT/build-tools/${{ env.BUILD_TOOLS_VERSION }}/zipalign -v -p 4 "$APK_INPUT" "$APK_ALIGNED" | |
| echo "Signing APK..." | |
| $ANDROID_SDK_ROOT/build-tools/${{ env.BUILD_TOOLS_VERSION }}/apksigner sign \ | |
| --ks "$KEYSTORE" \ | |
| --ks-pass pass:"$KEY_PASSWORD" \ | |
| --key-pass pass:"$KEY_PASSWORD" \ | |
| --ks-key-alias "$KEY_ALIAS" \ | |
| --ks-type PKCS12 \ | |
| --out "$APK_SIGNED" \ | |
| "$APK_ALIGNED" | |
| $ANDROID_SDK_ROOT/build-tools/${{ env.BUILD_TOOLS_VERSION }}/apksigner verify "$APK_SIGNED" | |
| rm -f "$APK_ALIGNED" | |
| rm -f ./test.keystore | |
| - name: Upload signed master APK | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: owncloudSigned-master | |
| path: ./owncloudSigned-master.apk | |
| retention-days: 2 | |
| update_test: | |
| name: Update test | |
| runs-on: ubuntu-latest | |
| needs: | |
| - sign_latest | |
| - sign_master | |
| - create_ocis | |
| env: | |
| BUILD_TOOLS_VERSION: "34.0.0" | |
| steps: | |
| # Checkout repo | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Show current branch and commit | |
| run: | | |
| echo "=== Current branch and commit info ===" | |
| git rev-parse --abbrev-ref HEAD | |
| git rev-parse HEAD | |
| echo "======================================" | |
| # Download the APK artifact published by sign_latest job | |
| - name: Download signed APK from latest | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| name: owncloudSigned-latest | |
| path: ./ | |
| # Download the APK artifact published by sign_master job | |
| - name: Download signed APK from master | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| name: owncloudSigned-master | |
| path: ./ | |
| # Move apk to resources folder | |
| - name: Move and rename APKs to resources directory | |
| run: | | |
| mv ./owncloudSigned-latest ./src/test/resources/owncloudSignedLatest.apk | |
| mv ./owncloudSigned-master ./src/test/resources/owncloudSignedMaster.apk | |
| ls -al ./src/test/resources | |
| # Start Appium server | |
| - name: Start Appium | |
| run: | | |
| mkdir -p logs video | |
| chmod +x ./runAppium.sh | |
| ./runAppium.sh | |
| # Enable KVM for emulator acceleration | |
| - name: Enable KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| # Shorten the commit hash to use to compare in the UI | |
| - name: Shorten the built commit hash | |
| shell: bash | |
| run: | | |
| COMMIT_HASH="${{ needs.build_apk.outputs.commit_hash }}" | |
| SHORT_HASH=${COMMIT_HASH:0:7} | |
| echo Hash shortened: $SHORT_HASH | |
| echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_ENV | |
| # Run tests over emulator and catch crash logs | |
| - name: Run Emulator & Execute tests | |
| uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a | |
| id: execution | |
| env: | |
| URL: ${{ secrets.OC_SERVER_URL }} | |
| USER: ${{ secrets.OC_SERVER_USERNAME_TEST }} | |
| PASSWORD: ${{ secrets.OC_SERVER_PASSWORD_TEST }} | |
| SHORT_HASH: ${{ env.SHORT_HASH }} | |
| with: | |
| api-level: 31 | |
| target: google_apis | |
| arch: x86_64 | |
| profile: pixel_5 | |
| avd-name: test-avd | |
| force-avd-creation: true | |
| disable-animations: true | |
| emulator-options: -no-snapshot -no-window -no-audio -no-boot-anim -accel on -memory 4096 | |
| script: | | |
| # To catch only crashes in background | |
| adb logcat -b crash *:E > crash_log.txt 2>&1 & | |
| LOGCAT_PID=$! | |
| ./gradlew --no-daemon clean test -Dserver="$URL" -Dusername="$USER" -Dpassword="$PASSWORD" -Dcommit="$SHORT_HASH" | |
| # Kill logcat to serve crash_log.txt | |
| kill $LOGCAT_PID || true | |
| # If crash happened, upload crash log | |
| - name: Upload crash log artifact | |
| if: always() && hashFiles('crash_log.txt') != '' | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: crash-log | |
| path: crash_log.txt | |
| # Prepare crash log file to be uploaded | |
| - name: Rename log file | |
| if: always() | |
| run: | | |
| cp logs/*.log logs/log.log || true | |
| # Upload log file | |
| - name: Upload Execution Log | |
| if: always() | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: logs | |
| path: ./logs/log.log | |
| # Upload appium log | |
| - name: Upload Appium Log | |
| if: always() | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: appium | |
| path: ./appium.log | |
| # Prepare video file to be uploaded by compressing it | |
| - name: Zip video files | |
| if: always() | |
| run: zip -r -9 test-recording.zip video || true | |
| # Upload video file | |
| - name: Upload Video | |
| if: always() | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: video-recording | |
| path: ./test-recording.zip | |
| cleanup: | |
| needs: | |
| - update_test | |
| if: always() | |
| uses: ./.github/workflows/cleanup.yml | |
| secrets: | |
| ssh_host: ${{ secrets.SSH_HOST }} | |
| ssh_user: ${{ secrets.SSH_USER }} | |
| ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} |