Develop build of the app to check stuff on github public runners #62
This file contains 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: develop-build | |
run-name: Develop build of the app to check stuff on github public runners | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
BUILD_NUMBER: ${{ github.run_number }} | |
jobs: | |
build-app: | |
concurrency: | |
group: "develop-build" | |
cancel-in-progress: true | |
runs-on: "ubuntu-latest" | |
steps: | |
# Preparation | |
- name: Install screenshot test dependencies | |
run: "sudo apt-get install -y libfreetype6 fontconfig fonts-dejavu" | |
- name: Globally enable build cache and parallel execution | |
run: "mkdir -p ~/.gradle && echo -e 'org.gradle.caching=true\norg.gradle.parallel=true' >> ~/.gradle/gradle.properties" | |
- name: Force all tasks to be rerun when debug mode is on | |
# This allows us to force rerun the build if cache has gotten corrupted | |
run: 'if [[ "${{ runner.debug }}" == "1" ]]; then | |
echo "GLOBAL_FLAGS= --rerun-tasks" >> "$GITHUB_ENV"; | |
else | |
echo "GLOBAL_FLAGS=" >> "$GITHUB_ENV"; | |
fi | |
' | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
lfs: true | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: temurin | |
cache: gradle | |
- uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc | |
# Build app | |
- name: Compile app | |
run: "./gradlew -PtestAppWithProguard compileDebugKotlin assembleRelease$GLOBAL_FLAGS" | |
env: | |
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }} | |
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} | |
# Tests | |
- name: Lint | |
run: "./gradlew -PtestAppWithProguard lintRelease detektMain detektTest -x detektRelease -x detektBenchmark -x detektReleaseUnitTest -x detektBenchmarkUnitTest assertModuleGraph buildHealth detectTooManyFiles :app:verifyDebugDatabaseMigration debugComposeCompilerCheck reportMerge --continue$GLOBAL_FLAGS" | |
- name: Double check db with generated schema | |
run: "./gradlew :app:generateDebugDatabaseSchema :app:verifyDebugDatabaseMigration" | |
- name: Compile Unit Tests | |
run: "./gradlew -PtestAppWithProguard compileDebugUnitTestSources compileReleaseUnitTestSources assembleDebugAndroidTest$GLOBAL_FLAGS" | |
- name: Run Unit Tests | |
run: "./gradlew -PtestAppWithProguard test -x :app-screenshot-tests:testDebugUnitTest -x :app-screenshot-tests:testReleaseUnitTest$GLOBAL_FLAGS" | |
# This generally does not need to be done on develop, only on PRs. But since there is no PRs on this project, | |
# it is done all the same | |
- name: "Generate new Screenshot Tests" | |
run: "config/generate-screenshots.sh main" | |
- name: "Run Screenshot Tests" | |
run: "./gradlew -PtestAppWithProguard --continue verifyPaparazziDebug$GLOBAL_FLAGS" | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action/linux@v2 | |
if: always() | |
with: | |
comment_mode: failures | |
junit_files: | | |
**/build/outputs/*-results/**/*.xml | |
**/build/*-results/**/*.xml | |
- name: "Upload Screenshot test failures" | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: failed-screenshot-tests | |
path: app-screenshot-tests/build/paparazzi/failures | |
# Release | |
# This project has no actual release, but is kept in as an example | |
# - name: Generate Changelog | |
# uses: inovait/actions-common/changelog-since-last-build@v11 | |
# with: | |
# git_commit_url_prefix: 'https://github.com/inovait/test-genie-android/commit/' | |
# target_file: "CHANGELOG.MD" | |
# - name: Tag build | |
# env: | |
# TAG_BUILD: "1.0.0${{env.BUILD_NUMBER}}" | |
# run: | | |
# git tag ${{env.TAG_BUILD}} | |
# git push origin ${{env.TAG_BUILD}} | |
# - name: Publish to spotlight | |
# uses: inovait/actions-common/spotlight-publish@v11 | |
# with: | |
# api_key: ${{secrets.SPOTLIGHT_KEY}} | |
# destination: 'release' | |
# version: "1.0.0-alpha${{ github.run_number }}" | |
# track: "Develop" | |
# files: | | |
# app/build/outputs/**/*-release.apk | |
# CHANGELOG.MD | |
- name: "Upload proguard mappings" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mapping-app-release.txt | |
path: app/build/outputs/mapping/release/mapping.txt |