Add GitHub Action with Actions cache backend #5
Workflow file for this run
This file contains hidden or 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: Integration Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| # Job 1: Action restores (miss), Go test builds Gradle, action post-step saves. | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Activate Hermit | |
| run: echo "${GITHUB_WORKSPACE}/bin" >> "$GITHUB_PATH" | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - name: Build gradle-cache from source | |
| run: | | |
| go build -o gradle-cache ./cmd/gradle-cache | |
| echo "$PWD" >> "$GITHUB_PATH" | |
| - name: Prepare test project | |
| run: | | |
| cp -r cmd/gradle-cache/testdata/gradle-project "$RUNNER_TEMP/project" | |
| chmod +x "$RUNNER_TEMP/project/gradlew" | |
| # Use the actual repo checkout for git history (so both jobs resolve | |
| # the same commit SHAs). The Gradle project lives in RUNNER_TEMP. | |
| - uses: ./ | |
| with: | |
| cache-key: integration-test | |
| gradle-user-home: ${{ runner.temp }}/gradle-home | |
| ref: HEAD | |
| log-level: debug | |
| - name: Run Gradle build via Go test | |
| run: go test -v -run ^TestIntegrationGradleBuild$ -timeout 300s ./cmd/gradle-cache/ | |
| env: | |
| INTEGRATION_PROJECT_DIR: ${{ runner.temp }}/project | |
| GRADLE_USER_HOME: ${{ runner.temp }}/gradle-home | |
| # Action post-step saves the cache automatically. | |
| # Job 2: Action restores (hit), Go test verifies cache hits. | |
| verify-restore: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Activate Hermit | |
| run: echo "${GITHUB_WORKSPACE}/bin" >> "$GITHUB_PATH" | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - name: Build gradle-cache from source | |
| run: | | |
| go build -o gradle-cache ./cmd/gradle-cache | |
| echo "$PWD" >> "$GITHUB_PATH" | |
| - name: Prepare test project | |
| run: | | |
| cp -r cmd/gradle-cache/testdata/gradle-project "$RUNNER_TEMP/project" | |
| chmod +x "$RUNNER_TEMP/project/gradlew" | |
| - uses: ./ | |
| with: | |
| cache-key: integration-test | |
| gradle-user-home: ${{ runner.temp }}/gradle-home | |
| save: "false" | |
| ref: HEAD | |
| log-level: debug | |
| - name: Verify restore via Go test | |
| run: go test -v -run ^TestIntegrationVerifyRestore$ -timeout 300s ./cmd/gradle-cache/ | |
| env: | |
| INTEGRATION_PROJECT_DIR: ${{ runner.temp }}/project | |
| GRADLE_USER_HOME: ${{ runner.temp }}/gradle-home |