Update Test #181
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,3,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: Sign latest APK | |
| needs: | |
| - build_apk_latest | |
| uses: ./.github/workflows/sign-apk.yml | |
| with: | |
| version: latest | |
| unsigned_artifact_name: ${{ needs.build_apk_latest.outputs.artifact_name }} | |
| secrets: inherit | |
| sign_master: | |
| name: Sign master APK | |
| needs: | |
| - build_apk_master | |
| uses: ./.github/workflows/sign-apk.yml | |
| with: | |
| version: master | |
| unsigned_artifact_name: ${{ needs.build_apk_master.outputs.artifact_name }} | |
| secrets: inherit | |
| update_test: | |
| name: Update test | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build_apk_master | |
| - build_apk_latest | |
| - 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: | | |
| ls -al . | |
| mv ./owncloudSigned-latest.apk ./src/test/resources/owncloudSignedLatest.apk | |
| mv ./owncloudSigned-master.apk ./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_master.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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| 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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: logs | |
| path: ./logs/log.log | |
| # Upload appium log | |
| - name: Upload Appium Log | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| 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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| 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 }} |