Skip to content

Commit

Permalink
Enable cache and standardize job names.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskioko committed Nov 18, 2024
1 parent e0ebf3d commit 8fd43b9
Showing 1 changed file with 105 additions and 16 deletions.
121 changes: 105 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ env:
JDK_VERSION: 21
DISTRIBUTION: 'zulu'
FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: 120
GRADLE_CACHE_PATH: |
~/.gradle/caches
~/.gradle/wrapper
SPM_CACHE_PATH: |
~/Library/Caches/org.swift.swiftpm
~/Library/Developer/Xcode/DerivedData
jobs:
build-android:
Expand All @@ -36,6 +42,14 @@ jobs:
distribution: ${{ env.DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}

- name: 📁 Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: 🐘 Setup Gradle 8.8
uses: gradle/actions/setup-gradle@v4
with:
Expand All @@ -52,7 +66,7 @@ jobs:
- name: Build with Gradle
run: ./gradlew assemble

android_lint:
android-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -61,11 +75,20 @@ jobs:
distribution: ${{ env.DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}

- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Lint Project
run: ./gradlew lint

- name: Upload Lint Report
uses: actions/upload-artifact@v4
if: always()
with:
name: android-lint-report
path: app/build/reports/lint-results*.html
Expand All @@ -79,15 +102,27 @@ jobs:
distribution: ${{ env.DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}

- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run Spotless
run: ./gradlew spotlessCheck

- uses: actions/upload-artifact@v4
- name: Upload Spotless Report
uses: actions/upload-artifact@v4
if: always()
with:
name: spotless-report
path: ./**/build/reports/spotless/spotless.*
path: |
**/build/reports/spotless
app/build/reports/spotless
dependency_health:
dependency-health:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -96,17 +131,27 @@ jobs:
distribution: ${{ env.DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}

- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Dependency Health
run: ./gradlew buildHealth

- uses: actions/upload-artifact@v4
- name: Upload Dependency Report
uses: actions/upload-artifact@v4
if: always()
with:
name: dependency-health-report
path: ./**/build/reports/tests/

android_screenshot_test:
runs-on: macos-latest

android-screenshot-test:
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: write
pull-requests: write
Expand All @@ -121,6 +166,14 @@ jobs:
distribution: ${{ env.DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}

- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Roborazzi screenshot tests
id: screenshotsverify
continue-on-error: true
Expand All @@ -138,7 +191,6 @@ jobs:
run: |
echo "::error::Screenshot tests failed, please create a PR in your fork first." && exit 1
# Runs if previous job failed
- name: Generate new screenshots if verification failed and it's a PR
id: screenshotsrecord
if: steps.screenshotsverify.outcome == 'failure' && github.event_name == 'pull_request'
Expand All @@ -160,7 +212,7 @@ jobs:
name: screenshot-test-results
path: '**/build/outputs/roborazzi/*_compare.png'

jvm_test:
jvm-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -169,15 +221,25 @@ jobs:
distribution: ${{ env.DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}

- name: Jvm Test
- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run JVM Tests
run: ./gradlew jvmTest

- uses: actions/upload-artifact@v4
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: always()
with:
name: jvm-test-report
path: ./**/build/reports/tests/

common_test:
common-test:
runs-on: macos-latest

steps:
Expand All @@ -190,6 +252,14 @@ jobs:
distribution: ${{ env.DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}

- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run Common iOS Unit Tests
run: |
if [[ $(uname -m) == 'arm64' ]]; then
Expand All @@ -200,14 +270,14 @@ jobs:
- name: Upload Common Test Report
uses: actions/upload-artifact@v4
if: always()
with:
name: common-test-report
path: ./**/build/reports/tests/

build-ios:
needs: [common-test]
runs-on: macos-latest
timeout-minutes: 180

steps:
- name: Checkout project
uses: actions/checkout@v4
Expand All @@ -223,9 +293,28 @@ jobs:
ruby-version: 3.3.0
bundler-cache: true

- name: Cache SPM dependencies
uses: actions/cache@v4
with:
path: ${{ env.SPM_CACHE_PATH }}
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Install dependencies with Bundler
run: bundle install

- name: Copy XCFramework
run: ./gradlew :shared:copyXCFramework

- name: Build iOS App
run: bundle exec fastlane build_tvmaniac

Expand All @@ -243,7 +332,7 @@ jobs:
path: fastlane/test_output

create-release:
needs: [build-android, android_lint, android_screenshot_test, common_test, build-ios, spotless, dependency_health, jvm_test]
needs: [build-android, android-lint, android-screenshot-test, common-test, build-ios, spotless, dependency-health, jvm-test]
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 8fd43b9

Please sign in to comment.