Skip to content

Add automatic generation of documentation screens and version number #724

Add automatic generation of documentation screens and version number

Add automatic generation of documentation screens and version number #724

Workflow file for this run

name: Run tests
env:
# The name of the main module repository
main_project_module: app
# The name in the Play Store
playstore_name: Soundscape
on:
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
environment: development
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set Up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '19'
# Setting up the tile provider from secrets won't work for runners which are triggered from
# forks e.g. to test a pull request. The tests that require tiles check if the tile provider
# exists, so we leave in this code so that if it's triggered by "Run workflow" the tile
# provider will be available.
- name: Setup tile provider
env:
TILE_PROVIDER_API_KEY: ${{ secrets.TILE_PROVIDER_API_KEY }}
TILE_PROVIDER_URL: ${{ secrets.TILE_PROVIDER_URL }}
run: |
echo tileProviderUrl="$TILE_PROVIDER_URL" > local.properties
echo tileProviderApiKey="$TILE_PROVIDER_API_KEY" >> local.properties
- name: Run lint over the repo
run: ./gradlew lint
- name: Run tests
run: ./gradlew test
- name: Generate screenshots
run : ./gradlew updateDebugScreenshotTest
- name: Build debug version
run: ./gradlew assembleDebug
- 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
avdmanager list device
- name: Instrumentation Tests
id: instrumentation-tests
uses: reactivecircus/android-emulator-runner@v2
continue-on-error: true # IMPORTANT: allow pipeline to continue to Android Test Report step
with:
api-level: 34
target: default
profile: pixel_7
arch: x86_64
script: |
mkdir -p app/documentationScreens
adb logcat -c # clear logs
touch app/emulator.log # create log file
chmod 777 app/emulator.log # allow writing to log file
adb logcat >> app/emulator.log & # pipe all logcat messages into log file as a background process
./gradlew connectedCheck
# Get the screenshots from the documentationScreen tests from the emulator
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/homeScreen.png app/documentationScreens/homeScreen.png
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/homeScreenWithRoute.png app/documentationScreens/homeScreenWithRoute.png
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/routeDetails.png app/documentationScreens/routeDetails.png
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/routeEdit.png app/documentationScreens/routeEdit.png
- name: Upload documentation screens
uses: actions/upload-artifact@v4
with:
name: documentationScreens
path: app/documentationScreens/
- name: Upload Failing Test Report Log
if: steps.instrumentation-tests.outcome != 'success' # upload the generated log on failure of the tests job
uses: actions/upload-artifact@v4
with:
name: logs
path: app/emulator.log # path to where the log is
- name: Raise error on test fail # set a red tick on the workflow run if the tests failed
if: steps.instrumentation-tests.outcome != 'success'
run: exit 1