Unverified Commit c3568cc9 authored by Bruno Borges's avatar Bruno Borges Committed by GitHub
Browse files

Consolidate cache-dependency-path e2e workflow and add maven/sbt coverage (#1124)

* Merge cache-dependency-path e2e workflow into e2e-cache

Fold the standalone 'Validate cache with cache-dependency-path option'
workflow into e2e-cache.yml and delete the separate file. The three
gradle1-save/gradle1-restore/gradle2-restore jobs are copied verbatim,
preserving their matrix, cache-dependency-path inputs, and needs
relationships. No change in test coverage.

Co-authored-by: default avatarCopilot App <[email protected]>
Copilot-Session: 635b89fa-5c35-49e1-a257-dc9001ebb8db

* Add cache-dependency-path e2e coverage for maven and sbt

Previously only gradle exercised the cache-dependency-path input. Mirror
the gradle save/restore(hit)/restore(miss) pattern for maven and sbt:

- maven1-save/maven1-restore/maven2-restore
- sbt1-save/sbt1-restore/sbt2-restore

Each save+restore pair uses the same cache-dependency-path so the restore
is a hit, while the second restore points at a new maven2/sbt2 fixture
whose different dependencies produce a different hash, so the cache is a
miss (directory not created). New fixtures added under __tests__/cache.

Co-authored-by: default avatarCopilot App <[email protected]>
Copilot-Session: 635b89fa-5c35-49e1-a257-dc9001ebb8db

---------

Co-authored-by: default avatarCopilot App <[email protected]>
parent 81c13a41
Loading
Loading
Loading
Loading
−102

File deleted.

+307
Changes for .github/workflows/e2e-cache.yml: 307 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -222,3 +222,310 @@ jobs:
            exit 1
          fi
          ls ~/.cache/coursier
  gradle1-save:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '17'
          cache: gradle
          cache-dependency-path: __tests__/cache/gradle1/*.gradle*
      - name: Create files to cache
        # Need to avoid using Gradle daemon to stabilize the save process on Windows
        # https://github.com/actions/cache/issues/454#issuecomment-840493935
        run: |
          gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
          if [ ! -d ~/.gradle/caches ]; then
            echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
            exit 1
          fi
  gradle1-restore:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    needs: gradle1-save
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: gradle
          cache-dependency-path: __tests__/cache/gradle1/*.gradle*
      - name: Confirm that ~/.gradle/caches directory has been made
        run: |
          if [ ! -d ~/.gradle/caches ]; then
            echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
            exit 1
          fi
          ls ~/.gradle/caches/
  gradle2-restore:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    needs: gradle1-save
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: gradle
          cache-dependency-path: __tests__/cache/gradle2/*.gradle*
      - name: Confirm that ~/.gradle/caches directory has not been made
        run: |
          if [ -d ~/.gradle/caches ]; then
            echo "::error::The ~/.gradle/caches directory exists unexpectedly"
            exit 1
          fi
  maven1-save:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-15-intel, windows-latest, ubuntu-latest]
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for maven
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: maven
          cache-dependency-path: __tests__/cache/maven/pom.xml
      - name: Create files to cache
        run: |
          mvn verify -f __tests__/cache/maven/pom.xml
          if [ ! -d ~/.m2/repository ]; then
            echo "::error::The ~/.m2/repository directory does not exist unexpectedly"
            exit 1
          fi
  maven1-restore:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-15-intel, windows-latest, ubuntu-latest]
    needs: maven1-save
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for maven
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: maven
          cache-dependency-path: __tests__/cache/maven/pom.xml
      - name: Confirm that ~/.m2/repository directory has been made
        run: |
          if [ ! -d ~/.m2/repository ]; then
            echo "::error::The ~/.m2/repository directory does not exist unexpectedly"
            exit 1
          fi
          ls ~/.m2/repository
  maven2-restore:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-15-intel, windows-latest, ubuntu-latest]
    needs: maven1-save
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for maven
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: maven
          cache-dependency-path: __tests__/cache/maven2/pom.xml
      - name: Confirm that ~/.m2/repository directory has not been made
        run: |
          if [ -d ~/.m2/repository ]; then
            echo "::error::The ~/.m2/repository directory exists unexpectedly"
            exit 1
          fi
  sbt1-save:
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash
        working-directory: __tests__/cache/sbt
    strategy:
      fail-fast: false
      matrix:
        os: [macos-15-intel, windows-latest, ubuntu-22.04]
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for sbt
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: sbt
          cache-dependency-path: __tests__/cache/sbt/*.sbt
      - name: Setup SBT
        if: matrix.os == 'macos-15-intel'
        run: |
          echo ""Installing SBT...""
          brew install sbt
      - name: Create files to cache
        run: sbt update

      - name: Check files to cache on macos-latest
        if: matrix.os == 'macos-15-intel'
        run: |
          if [ ! -d ~/Library/Caches/Coursier ]; then
            echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
            exit 1
          fi
      - name: Check files to cache on windows-latest
        if: matrix.os == 'windows-latest'
        run: |
          if [ ! -d ~/AppData/Local/Coursier/Cache ]; then
            echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
            exit 1
          fi
      - name: Check files to cache on ubuntu-latest
        if: matrix.os == 'ubuntu-22.04'
        run: |
          if [ ! -d ~/.cache/coursier ]; then
            echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
            exit 1
          fi
  sbt1-restore:
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash
        working-directory: __tests__/cache/sbt
    strategy:
      fail-fast: false
      matrix:
        os: [macos-15-intel, windows-latest, ubuntu-22.04]
    needs: sbt1-save
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for sbt
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: sbt
          cache-dependency-path: __tests__/cache/sbt/*.sbt

      - name: Confirm that ~/Library/Caches/Coursier directory has been made
        if: matrix.os == 'macos-15-intel'
        run: |
          if [ ! -d ~/Library/Caches/Coursier ]; then
            echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
            exit 1
          fi
          ls ~/Library/Caches/Coursier
      - name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
        if: matrix.os == 'windows-latest'
        run: |
          if [ ! -d ~/AppData/Local/Coursier/Cache ]; then
            echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
            exit 1
          fi
          ls ~/AppData/Local/Coursier/Cache
      - name: Confirm that ~/.cache/coursier directory has been made
        if: matrix.os == 'ubuntu-22.04'
        run: |
          if [ ! -d ~/.cache/coursier ]; then
            echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
            exit 1
          fi
          ls ~/.cache/coursier
  sbt2-restore:
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash
        working-directory: __tests__/cache/sbt2
    strategy:
      fail-fast: false
      matrix:
        os: [macos-15-intel, windows-latest, ubuntu-22.04]
    needs: sbt1-save
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for sbt
        uses: ./
        id: setup-java
        with:
          distribution: 'adopt'
          java-version: '11'
          cache: sbt
          cache-dependency-path: __tests__/cache/sbt2/*.sbt

      - name: Confirm that ~/Library/Caches/Coursier directory has not been made
        if: matrix.os == 'macos-15-intel'
        run: |
          if [ -d ~/Library/Caches/Coursier ]; then
            echo "::error::The ~/Library/Caches/Coursier directory exists unexpectedly"
            exit 1
          fi
      - name: Confirm that ~/AppData/Local/Coursier/Cache directory has not been made
        if: matrix.os == 'windows-latest'
        run: |
          if [ -d ~/AppData/Local/Coursier/Cache ]; then
            echo "::error::The ~/AppData/Local/Coursier/Cache directory exists unexpectedly"
            exit 1
          fi
      - name: Confirm that ~/.cache/coursier directory has not been made
        if: matrix.os == 'ubuntu-22.04'
        run: |
          if [ -d ~/.cache/coursier ]; then
            echo "::error::The ~/.cache/coursier directory exists unexpectedly"
            exit 1
          fi
+11
Changes for __tests__/cache/maven2/.gitignore: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
+15
Changes for __tests__/cache/maven2/pom.xml: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.actions</groupId>
    <artifactId>setup-java-maven2-example</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
    </dependencies>
</project>
+1
Changes for __tests__/cache/sbt2/.gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
target/
Loading