Skip to content

Commit

Permalink
Reuse gradle dependencies across all CI steps
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Dec 6, 2024
1 parent e66ab4b commit cef626b
Showing 1 changed file with 62 additions and 24 deletions.
86 changes: 62 additions & 24 deletions .github/workflows/test_and_release_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,78 @@ on:
pull_request:

jobs:
unit-tests:
name: Unit tests
runs-on: macos-latest
prepare:
name: Prepare workspace and cache dependencies
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v4

- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}
- name: Upload prepared workspace
uses: actions/upload-artifact@v4
with:
name: workspace
path: .

- uses: gradle/actions/setup-gradle@v4
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}

unit-tests:
name: Unit tests
runs-on: macos-latest
needs: prepare

steps:
- name: Download prepared workspace
uses: actions/download-artifact@v4
with:
name: workspace
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- name: Run unit tests and friends
run: ./gradlew check

screenshot-tests:
name: Android screenshot tests
runs-on: ubuntu-latest
needs: prepare

steps:
- uses: actions/checkout@v4
- name: Download prepared workspace
uses: actions/download-artifact@v4
with:
lfs: true
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v4
name: workspace
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v4
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}

- name: Run paparazzi screenshot tests
run: ./gradlew verifyPaparazziDebug
Expand All @@ -52,13 +92,8 @@ jobs:
**/out/failures/
paparazzi/paparazzi-gradle-plugin/src/test/projects/**/build/reports/paparazzi/images/
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}

- name: Run instrumented screenshot tests
env:
# https://docs.emulator.wtf/github/tokenless
EW_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew testDebugWithEmulatorWtf

Expand All @@ -79,18 +114,21 @@ jobs:
timeout-minutes: 10
if: github.repository == 'saket/telephoto' && github.ref == 'refs/heads/trunk'
needs: [unit-tests, screenshot-tests]

steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v3
- name: Download prepared workspace
uses: actions/download-artifact@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/[email protected]

name: workspace
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- name: Ensure snapshot version
run: ./gradlew throwIfVersionIsNotSnapshot

- name: Publish snapshot
run: ./gradlew clean publish --no-daemon --no-parallel --no-configuration-cache --stacktrace
env:
Expand Down

0 comments on commit cef626b

Please sign in to comment.