Skip to content

Refactor: extract device model, add CommandDispatcher, 145 tests #643

Refactor: extract device model, add CommandDispatcher, 145 tests

Refactor: extract device model, add CommandDispatcher, 145 tests #643

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate AsyncAPI spec
run: npx --yes @asyncapi/cli validate asyncapi.yaml
- name: Use Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Get the version
id: get_version
run: |
VERSION_NAME=$(grep versionName version.properties | cut -d= -f2)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_OUTPUT
echo "VERSION_CODE=${{ github.run_number }}" >> $GITHUB_OUTPUT
- name: Run unit tests
run: ./gradlew testDebugUnitTest -PversionCode=${{ github.run_number }}
- name: Archive performance report
if: always()
uses: actions/upload-artifact@v4
with:
name: ride-performance-report
path: app/build/reports/perf/
if-no-files-found: warn
- name: Build release apk
run: ./gradlew assembleRelease -q -PversionCode=${{ github.run_number }}
- name: Setup build tool version variable
shell: bash
run: |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION
- name: Check PR author permission
id: check_permission
if: github.event_name == 'pull_request'
run: |
if [[ "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
echo "IS_REPO_OWNER=true" >> $GITHUB_OUTPUT
else
echo "IS_REPO_OWNER=false" >> $GITHUB_OUTPUT
fi
- uses: r0adkll/sign-android-release@v1
name: Sign app APK (For trusted sources)
id: sign_app
if: github.repository == 'cagnulein/QZCompanionNordictrackTreadmill' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || steps.check_permission.outputs.IS_REPO_OWNER == 'true')
with:
releaseDirectory: app/build/outputs/apk/release/
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
- name: Find unsigned APK
if: github.repository != 'cagnulein/QZCompanionNordictrackTreadmill' || steps.sign_app.outcome == 'skipped'
id: find_apk
run: |
APK_PATH=$(find app/build/outputs/apk/release/ -name "*.apk" | head -n 1)
echo "UNSIGNED_APK=$APK_PATH" >> $GITHUB_OUTPUT
echo "Found unsigned APK at $APK_PATH"
- name: Archive apk
uses: actions/upload-artifact@v4
with:
name: apk
path: ${{ steps.sign_app.outputs.signedReleaseFile || steps.find_apk.outputs.UNSIGNED_APK }}
- name: Update the InstallPackage
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: cp ${{steps.sign_app.outputs.signedReleaseFile}} ./InstallPackage/QZCompanionNordictrackTreadmill.apk
- name: Commit InstallPackage
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: EndBug/add-and-commit@v9
with:
add: './InstallPackage/QZCompanionNordictrackTreadmill.apk'
message: 'Updating InstallPackage'
push: origin HEAD:master
- name: Create release and upload apk
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: underwindfall/create-release-with-debugapk@v2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION_NAME }}
release_name: ${{ steps.get_version.outputs.VERSION_NAME }} (build ${{ steps.get_version.outputs.VERSION_CODE }})
asset_path: ${{steps.sign_app.outputs.signedReleaseFile}}
asset_name: QZCompanionNordictrackTreadmill.apk
asset_content_type: application/zip