Merge pull request #61 from leinardi/feature/update-deps #291
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: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
# This allows a subsequently queued workflow run to interrupt previous runs | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
checks: | |
name: Checking manifest and deps | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
## Actual task | |
- name: Check merged manifests | |
run: ./gradlew copyMergedManifests | |
- id: merged_manifests | |
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_ENV | |
- name: Check if there are changes | |
if: steps.merged_manifests.outputs.changed != 0 | |
run: | | |
echo '::error::Uncommitted changes to the merged manifests!' | |
git diff | |
exit 1 | |
- name: Check compile dependencies report | |
run: ./gradlew generateRuntimeDependenciesReport | |
- id: compile_dependencies_report | |
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_ENV | |
- name: Check if there are changes | |
if: steps.compile_dependencies_report.outputs.changed != 0 | |
run: | | |
echo '::error::Uncommitted changes to the compile dependencies report!' | |
exit 1 | |
build-debug: | |
name: Build debug | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
cache-read-only: false | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
## Actual tasks | |
- name: Build | |
run: ./gradlew assembleDebug assembleDebugAndroidTest -PsaveBuildLogToFile=true | |
- name: Archiving violations report | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: violations-build-debug | |
path: ./**/build/logs/buildlog*.txt | |
build-release: | |
name: Build release | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
- name: Decrypt secrets | |
run: ./release/decrypt-secrets.sh | |
env: | |
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }} | |
## Actual task | |
- name: Build | |
env: | |
ORG_GRADLE_PROJECT_RELEASE_KEYSTORE_PWD: ${{ secrets.RELEASE_KEYSTORE_PWD }} | |
run: ./gradlew :apps:forlago:bundleRelease # analyzeReleaseBundle <- Disable due to https://github.com/spotify/ruler/issues/116 | |
- name: Clean secrets | |
if: always() | |
run: ./release/clean-secrets.sh | |
# Disable due to https://github.com/spotify/ruler/issues/116 | |
# - name: Upload Ruler report | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ruler | |
# path: apps/forlago/build/reports/ruler | |
detekt: | |
name: Detekt | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
## Actual tasks | |
- name: Detekt | |
run: ./gradlew detektDebug detektTest | |
- name: Archiving violations report | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: violations-detekt | |
path: ./**/reports/detekt/*.xml | |
spotless: | |
name: Spotless | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
## Actual tasks | |
- name: Spotless | |
run: ./gradlew spotlessCheck | |
android-lint: | |
name: Android Lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
## Actual tasks | |
- name: Lint | |
run: ./gradlew lint | |
- name: Upload Lint results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: android-lint-html-report | |
path: ./**/build/reports/lint-results-*.html | |
- name: Archiving violations report | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: violations-android-lint | |
path: ./**/reports/lint-results*.xml | |
unit-tests: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
## Actual tasks | |
- name: Unit tests | |
run: ./gradlew testDebugUnitTest | |
- name: Archiving violations report | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: violations-unit-tests | |
path: ./**/build/test-results/test*/*.xml | |
espresso-tests: | |
name: Espresso tests | |
# Android emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. | |
# The macOS VM provided by GitHub Actions is the only one that currently supports it. | |
runs-on: ubuntu-latest | |
timeout-minutes: 45 | |
env: | |
JAVA_TOOL_OPTIONS: -Xmx4g | |
TERM: dumb | |
strategy: | |
# Allow tests to continue on other devices if they fail on one device. | |
fail-fast: false | |
matrix: | |
device: [pixel2] | |
api-level: [29, 31] | |
system-image-source: [google] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Enable KVM group perms | |
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 | |
ls /dev/kvm | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
- name: Accept Android licenses | |
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true | |
- name: Run Espresso tests on ${{ matrix.device }}Api${{ matrix.api-level }}${{ matrix.system-image-source }} | |
run: ./gradlew :apps:forlago:${{ matrix.device }}Api${{ matrix.api-level }}${{ matrix.system-image-source }}DebugAndroidTest | |
- name: Make file path compatible with upload-artifact | |
run: find . -path '*/build/*' -name '*:*' -exec bash -c 'mv "$0" "${0//:/_}"' {} \; | |
- name: Upload results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: instrumentation-test-results-${{ matrix.device }}Api${{ matrix.api-level }}${{ matrix.system-image-source }} | |
path: | | |
**/build/reports/* | |
**/build/outputs/*/connected/* | |
publishing-violation: | |
name: Publishing violations to PR | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
needs: [build-debug, detekt, android-lint, unit-tests] | |
timeout-minutes: 40 | |
env: | |
TERM: dumb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.10 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
## This is needed by secrets-gradle-plugin | |
- name: Create Local Properties File | |
run: touch local.properties | |
- name: Fetching build-debug result | |
uses: actions/download-artifact@v4 | |
with: | |
name: violations-build-debug | |
- name: Fetching detekt result | |
uses: actions/download-artifact@v4 | |
with: | |
name: violations-detekt | |
- name: Fetching android-lint result | |
uses: actions/download-artifact@v4 | |
with: | |
name: violations-android-lint | |
- name: Fetching unit-tests result | |
uses: actions/download-artifact@v4 | |
with: | |
name: violations-unit-tests | |
## Actual tasks | |
- name: Publishing violation comments to PR | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
run: ./gradlew violationCommentsToGitHub -DGITHUB_PULLREQUESTID=${{ github.event.number }} -DGITHUB_OAUTH2TOKEN=${{ secrets.GITHUB_TOKEN }} --info |