Add branch policy (#1805) #1505
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: Mobile-Wallet CI[Master/Dev] | |
on: | |
push: | |
branches: [ dev, master, payment_hub ] | |
pull_request: | |
concurrency: | |
group: build-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- uses: gradle/actions/setup-gradle@v4 | |
- name: Cache Gradle and build outputs | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
build | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: ${{ runner.os }}-gradle- | |
checks: | |
needs: setup | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
check: [ build_logic, spotless, detekt ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: Run ${{ matrix.check }} | |
id: run_check | |
run: | | |
if [ "${{ matrix.check }}" = "build_logic" ]; then | |
./gradlew check -p build-logic | |
elif [ "${{ matrix.check }}" = "spotless" ]; then | |
./gradlew spotlessCheck --no-configuration-cache --no-daemon | |
elif [ "${{ matrix.check }}" = "detekt" ]; then | |
./gradlew detekt | |
fi | |
- name: Upload Detekt Reports | |
if: ${{ matrix.check == 'detekt' && steps.run_check.outcome == 'success' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: detekt-reports | |
path: | | |
**/build/reports/detekt/detekt.md | |
dependency_guard: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: Check Dependency Guard | |
id: dependencyguard_verify | |
continue-on-error: true | |
run: ./gradlew dependencyGuard | |
- name: Prevent updating Dependency Guard baselines if this is a fork | |
id: checkfork_dependencyguard | |
if: steps.dependencyguard_verify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository | |
run: | | |
echo "::error::Dependency Guard failed, please update baselines with: ./gradlew dependencyGuardBaseline" && exit 1 | |
# Runs if previous job failed | |
- name: Generate new Dependency Guard baselines if verification failed and it's a PR | |
id: dependencyguard_baseline | |
if: steps.dependencyguard_verify.outcome == 'failure' && github.event_name == 'pull_request' | |
run: | | |
./gradlew dependencyGuardBaseline | |
- name: Push new Dependency Guard baselines if available | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
if: steps.dependencyguard_baseline.outcome == 'success' | |
with: | |
file_pattern: '**/dependencies/*.txt' | |
disable_globbing: true | |
commit_message: "🤖 Updates baselines for Dependency Guard" | |
tests_and_lint: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: Run tests | |
run: | | |
./gradlew testDemoDebug :lint:test :mifospay:lintProdRelease :lint:lint | |
- name: Upload reports | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-and-lint-reports | |
path: | | |
**/build/reports/lint-results-*.html | |
**/build/test-results/test*UnitTest/**.xml | |
build: | |
needs: [ checks, dependency_guard, tests_and_lint ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: Build APKs | |
run: ./gradlew :mifospay:assembleDemoDebug | |
- name: Check badging | |
# This step is allowed to fail, as it's not critical for the build | |
continue-on-error: true | |
run: ./gradlew :mifospay:checkProdReleaseBadging | |
- name: Upload APKs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: APKs | |
path: '**/build/outputs/apk/**/*.apk' | |