Skip to content

Update Test

Update Test #147

Workflow file for this run

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:
uses: owncloud/android/.github/workflows/build-apk.yml@master
with:
build_variant: qaRelease
version: master
update_test:
name: Update test
runs-on: ubuntu-latest
needs:
- build_apk
- create_ocis
env:
BUILD_TOOLS_VERSION: "34.0.0"
steps:
# Checkout repo
- name: Checkout repo
uses: actions/checkout@v5
- 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 build_apk job
- name: Download APK artifact
uses: actions/download-artifact@v7
with:
name: ${{ needs.build_apk.outputs.artifact_name }}
path: ./
# Move apk to root, making it easier to access
- name: Copy APK to root directory
run: cp ./${{ needs.build_apk.outputs.artifact_name }} ./owncloud-master.apk
- name: Restore keystore
env:
KEY_PASSWORD: ${{ secrets.TEST_KS_KEY }}
run: |
echo "${{ secrets.TEST_KS_B64 }}" | base64 -d > ./test.keystore
# Align and sign the APK
- name: Sign 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"
# Align APK for optimal performance
echo "Aligning APK..."
$ANDROID_SDK_ROOT/build-tools/${{ env.BUILD_TOOLS_VERSION }}/zipalign -v -p 4 "$APK_INPUT" "$APK_ALIGNED"
# Sign APK using keystore
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"
echo "Signed APK: $APK_SIGNED"
# Clean up temporary files
rm -f "$APK_ALIGNED"
rm -f ./test.keystore
# Upload the signed APK as an artifact
- name: Upload APK as artifact
uses: actions/upload-artifact@v6
with:
name: owncloudSigned-master
path: ./owncloudSigned-master.apk
retention-days: 2
# Move apk to test folder, making it easier to access
- name: Copy APK to test resources
run: cp ./owncloudSigned-master.apk ./src/test/resources/
# Download the latest successfully signed APK from the reference workflow
- name: Download latest signed APK
uses: dawidd6/action-download-artifact@v17
with:
workflow: build-apk-from-latest.yml
name: owncloudSigned-latest
workflow_conclusion: success
path: ./src/test/resources
# Rename APKs to standard names expected by tests
- name: Rename artifacts
run: |
ls -al ./src/test/resources
mv ./src/test/resources/owncloudSigned-latest.apk ./src/test/resources/owncloudSigned1.apk
mv ./src/test/resources/owncloudSigned-master.apk ./src/test/resources/owncloudSigned2.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@v2
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@v6
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@v6
with:
name: logs
path: ./logs/log.log
# Upload appium log
- name: Upload Appium Log
if: always()
uses: actions/upload-artifact@v6
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@v6
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 }}