From 4943894a688c38c4322b0725493607451d917a0f Mon Sep 17 00:00:00 2001 From: Thomas Kioko Date: Fri, 17 Nov 2023 15:37:23 +0100 Subject: [PATCH 1/2] Restructure github actions --- .github/workflows/build.yml | 79 +++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65a770376..0065bf219 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,11 +2,9 @@ name: CI on: push: - branches: - - main + branches: [ main ] pull_request: - branches: - - main + types: [ opened, synchronize ] concurrency: group: ci-${{ github.ref }}-${{ github.head_ref }} @@ -29,7 +27,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Install JDK + - name: Set up JDK uses: actions/setup-java@v3 with: distribution: 'zulu' @@ -46,20 +44,77 @@ jobs: echo -e "\TRAKT_CLIENT_SECRET=$TRAKT_CLIENT_SECRET" >> ./local.properties echo -e "\TRAKT_REDIRECT_URI=$TRAKT_REDIRECT_URI" >> ./local.properties - - name: Check lint + android-lint: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 18 + + - name: lintDebug run: ./gradlew lint - - name: Check spotless + - uses: actions/upload-artifact@v3 + with: + name: android-lint-report + path: ~/**/build/reports/lint-results*.html + + spotless: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 18 + distribution: 'zulu' + + - name: spotless run: ./gradlew spotlessCheck --init-script tooling/checks/spotless.gradle.kts --no-configuration-cache - - name: Build with gradle - run: ./gradlew assemble + - uses: actions/upload-artifact@v3 + with: + name: detekt-report + path: ./**/build/reports/detekt/detekt.* + + unit-test: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 18 + distribution: 'zulu' - - name: Run local tests + - name: unitTest run: ./gradlew testDemoDebug - - name: Build - run: ./gradlew assembleDemoDebug + - uses: actions/upload-artifact@v3 + with: + name: unit-test-report + path: ./**/build/reports/tests/ + + create-release: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 18 + distribution: 'zulu' - name: Create release uses: softprops/action-gh-release@v1 From 5d3d3e9cbc6bcfe6b9ac8222dde3ea8a39a56359 Mon Sep 17 00:00:00 2001 From: Thomas Kioko Date: Fri, 17 Nov 2023 15:50:52 +0100 Subject: [PATCH 2/2] Require all jobs to complete before creating a release. --- .github/workflows/build.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0065bf219..96fccbcfc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,9 @@ jobs: echo -e "\TRAKT_CLIENT_SECRET=$TRAKT_CLIENT_SECRET" >> ./local.properties echo -e "\TRAKT_REDIRECT_URI=$TRAKT_REDIRECT_URI" >> ./local.properties + - name: Build with gradle + run: ./gradlew assemble + android-lint: runs-on: ubuntu-latest steps: @@ -106,6 +109,13 @@ jobs: create-release: runs-on: ubuntu-latest + needs: [ + build, + android-lint, + spotless, + unit-test + ] + if: ${{ always() && !cancelled() && needs.build.result == 'success' }} steps: - name: checkout uses: actions/checkout@v4