|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: build-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +env: |
| 13 | + JAVA_TOOL_OPTIONS: -Xmx4g |
| 14 | + |
| 15 | +jobs: |
| 16 | + spotless: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 10 |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Validate Gradle Wrapper |
| 24 | + uses: gradle/wrapper-validation-action@v3 |
| 25 | + |
| 26 | + - name: Copy CI gradle.properties |
| 27 | + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties |
| 28 | + |
| 29 | + - name: Set up JDK 17 |
| 30 | + uses: actions/setup-java@v4 |
| 31 | + with: |
| 32 | + distribution: 'zulu' |
| 33 | + java-version: 17 |
| 34 | + |
| 35 | + - name: chmod cache key |
| 36 | + run: chmod +x ./scripts/checksum.sh |
| 37 | + |
| 38 | + - name: Generate cache key |
| 39 | + run: ./scripts/checksum.sh app checksum.txt |
| 40 | + |
| 41 | + - uses: actions/cache@v3 |
| 42 | + with: |
| 43 | + path: | |
| 44 | + ~/.gradle/caches/modules-* |
| 45 | + ~/.gradle/caches/jars-* |
| 46 | + ~/.gradle/caches/build-cache-* |
| 47 | + ~/.gradle/wrapper/ |
| 48 | + ~/.gradle/caches/transforms-* |
| 49 | + key: gradle-${{ hashFiles('checksum.txt') }} |
| 50 | + restore-keys: | |
| 51 | + gradle- |
| 52 | +
|
| 53 | + - name: Setup Gradle |
| 54 | + uses: gradle/gradle-build-action@v3 |
| 55 | + |
| 56 | + - name: Check Spotless |
| 57 | + run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache --no-daemon --stacktrace |
| 58 | + |
| 59 | + tests: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + timeout-minutes: 20 |
| 62 | + steps: |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Set up JDK 17 |
| 67 | + uses: actions/setup-java@v4 |
| 68 | + with: |
| 69 | + distribution: 'zulu' |
| 70 | + java-version: 17 |
| 71 | + |
| 72 | + - name: chmod cache key |
| 73 | + run: chmod +x ./scripts/checksum.sh |
| 74 | + |
| 75 | + - name: Generate cache key |
| 76 | + run: ./scripts/checksum.sh app checksum.txt |
| 77 | + |
| 78 | + - uses: actions/cache@v3 |
| 79 | + with: |
| 80 | + path: | |
| 81 | + ~/.gradle/caches/modules-* |
| 82 | + ~/.gradle/caches/jars-* |
| 83 | + ~/.gradle/caches/build-cache-* |
| 84 | + ~/.gradle/wrapper/ |
| 85 | + ~/.gradle/caches/transforms-* |
| 86 | + key: gradle-${{ hashFiles('checksum.txt') }} |
| 87 | + restore-keys: | |
| 88 | + gradle- |
| 89 | +
|
| 90 | + - name: Copy CI gradle.properties |
| 91 | + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties |
| 92 | + |
| 93 | + - name: Setup Gradle |
| 94 | + uses: gradle/gradle-build-action@v3 |
| 95 | + |
| 96 | + - name: UnitTest |
| 97 | + run: ./gradlew testDebugUnitTest --no-daemon --stacktrace |
| 98 | + |
| 99 | + - name: Check Kover |
| 100 | + run: ./gradlew koverXmlReportDebug --no-daemon |
| 101 | + |
| 102 | + - name: Display local test coverage |
| 103 | + uses: madrapps/jacoco-report@v1.6.1 |
| 104 | + with: |
| 105 | + title: test coverage report |
| 106 | + min-coverage-overall: 40 |
| 107 | + min-coverage-changed-files: 60 |
| 108 | + update-comment: true |
| 109 | + skip-if-no-changes: true |
| 110 | + continue-on-error: false |
| 111 | + paths: | |
| 112 | + ${{ github.workspace }}/feature/**/build/reports/kover/reportDebug.xml |
| 113 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 114 | + |
| 115 | + build: |
| 116 | + runs-on: ubuntu-latest |
| 117 | + timeout-minutes: 15 |
| 118 | + needs: [spotless, tests] |
| 119 | + steps: |
| 120 | + - name: Checkout |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Set up JDK 17 |
| 124 | + uses: actions/setup-java@v4 |
| 125 | + with: |
| 126 | + distribution: 'zulu' |
| 127 | + java-version: 17 |
| 128 | + |
| 129 | + - name: chmod cache key |
| 130 | + run: chmod +x ./scripts/checksum.sh |
| 131 | + |
| 132 | + - name: Generate cache key |
| 133 | + run: ./scripts/checksum.sh app checksum.txt |
| 134 | + |
| 135 | + - uses: actions/cache@v3 |
| 136 | + with: |
| 137 | + path: | |
| 138 | + ~/.gradle/caches/modules-* |
| 139 | + ~/.gradle/caches/jars-* |
| 140 | + ~/.gradle/caches/build-cache-* |
| 141 | + ~/.gradle/wrapper/ |
| 142 | + ~/.gradle/caches/transforms-* |
| 143 | + key: gradle-${{ hashFiles('checksum.txt') }} |
| 144 | + restore-keys: | |
| 145 | + gradle- |
| 146 | +
|
| 147 | + - name: Copy CI gradle.properties |
| 148 | + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties |
| 149 | + |
| 150 | + - name: Setup Gradle |
| 151 | + uses: gradle/gradle-build-action@v3 |
| 152 | + |
| 153 | + - name: Build Debug APK |
| 154 | + run: ./gradlew assembleDebug --no-daemon |
| 155 | + |
| 156 | + - name: Run Android Lint |
| 157 | + run: ./gradlew lintDebug --no-daemon |
| 158 | + |
| 159 | + - name: Upload build reports |
| 160 | + if: always() |
| 161 | + uses: actions/upload-artifact@v3 |
| 162 | + with: |
| 163 | + name: build-reports |
| 164 | + path: app/build/reports |
| 165 | + |
| 166 | + - name: Delete checksum.txt after build |
| 167 | + if: always() |
| 168 | + run: rm -f checksum.txt |
0 commit comments