Skip to content

Update Test

Update Test #187

Workflow file for this run

name: Update Test
on:
workflow_dispatch:
schedule:
# Runs every work day at 01:00 UTC, which is 02:00 CET / 03:00 CEST in Europe
- cron: "0 1 * * 1-5"
permissions:
# Only need read access to repository contents
contents: read
jobs:
# Firstly, check if there were changes the day before. If not, aborting
check_repo_changes:
name: Check changes in Android app
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.check.outputs.has_changes }}
steps:
- name: Checkout external repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
repository: owncloud/android
ref: master
fetch-depth: 0
path: android-repo
- name: Check commits from previous day
id: check
shell: bash
run: |
cd android-repo
export TZ="Europe/Madrid"
SINCE=$(date -d "yesterday" +"%Y-%m-%d 00:00:00")
UNTIL=$(date -d "today" +"%Y-%m-%d 00:00:00")
echo "Checking commits in external repo between:"
echo "SINCE=$SINCE"
echo "UNTIL=$UNTIL"
COMMITS=$(git rev-list --count --since="$SINCE" --until="$UNTIL" origin/master)
echo "Commits found: $COMMITS"
if [ "$COMMITS" -gt 0 ]; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
else
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi
# Creates oCIS server
create_ocis:
name: Provision of oCIS server
needs:
- check_repo_changes
if: github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true'
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 }}
# Builds the apk to install from the "latest" tag (current stable)
build_apk_latest:
name: Build latest APK
needs:
- check_repo_changes
if: github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true'
uses: owncloud/android/.github/workflows/build-apk.yml@master
with:
build_variant: qaRelease
version: latest
# Builds the apk to install from the current master
build_apk_master:
name: Build master APK
needs:
- check_repo_changes
if: github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true'
uses: owncloud/android/.github/workflows/build-apk.yml@master
with:
build_variant: qaRelease
version: master
# Signs build from latest
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
# Signs build from master
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
# Launches the test
update_test:
name: Update test
needs:
- build_apk_master
- sign_latest
- sign_master
- create_ocis
runs-on: ubuntu-latest
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
# Cleans up the server
cleanup:
name: Clean Up
needs:
- update_test
- create_ocis
- check_repo_changes
if: always() && (github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true')
uses: ./.github/workflows/cleanup.yml
secrets:
ssh_host: ${{ secrets.SSH_HOST }}
ssh_user: ${{ secrets.SSH_USER }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}