diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index c947ca08ace0..732feab71377 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -5,7 +5,7 @@ inputs: description: "Java version to setup" default: 17 cache: - description: "Cache Maven repo" + description: "Cache Maven repo (true/false/restore)" default: true download_dependencies: description: "Download all Maven dependencies so Maven can work in offline mode" @@ -38,7 +38,7 @@ runs: with: distribution: 'temurin' # use same JDK distro as in Trino docker images java-version: ${{ inputs.java-version }} - - name: Cache local Maven repo + - name: Cache and Restore local Maven repo id: cache if: ${{ format('{0}', inputs.cache) == 'true' }} uses: actions/cache@v3 @@ -47,6 +47,15 @@ runs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Restore local Maven repo + id: cache_restore + if: ${{ format('{0}', inputs.cache) == 'restore' }} + uses: actions/cache/restore@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- - name: Fetch any missing dependencies shell: bash if: ${{ format('{0}', inputs.download_dependencies) == 'true' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9241a7f3c3c..965b8df72a67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -186,6 +186,8 @@ jobs: github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha && format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }} - uses: ./.github/actions/setup + with: + cache: restore - name: Maven Package run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -198,10 +200,6 @@ jobs: # The main Error Prone run $MAVEN ${MAVEN_TEST} -T 1C clean verify -DskipTests -P gib,errorprone-compiler \ -pl '!:trino-docs,!:trino-server,!:trino-server-rpm' - - name: Clean local Maven repo - # Avoid creating a cache entry because this job doesn't download all dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: rm -rf ~/.m2/repository web-ui-checks: runs-on: ubuntu-latest @@ -231,6 +229,8 @@ jobs: github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha && format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }} - uses: ./.github/actions/setup + with: + cache: restore - name: Maven Install run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -275,10 +275,6 @@ jobs: path: | **/*.hprof retention-days: ${{ env.HEAP_DUMP_RETENTION_DAYS }} - - name: Clean local Maven repo - # Avoid creating a cache entry because this job doesn't download all dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: rm -rf ~/.m2/repository hive-tests: runs-on: ubuntu-latest @@ -300,6 +296,8 @@ jobs: github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha && format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }} - uses: ./.github/actions/setup + with: + cache: restore - name: Install Hive Module run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -426,10 +424,6 @@ jobs: check_name: ${{ github.job }} (${{ matrix.config }}) with secrets conclusion: ${{ job.status }} github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Clean local Maven repo - # Avoid creating a cache entry because this job doesn't download all dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: rm -rf ~/.m2/repository test-other-modules: runs-on: ubuntu-latest @@ -445,6 +439,8 @@ jobs: github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha && format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }} - uses: ./.github/actions/setup + with: + cache: restore - name: Maven Install run: | export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}" @@ -516,10 +512,6 @@ jobs: path: | **/*.hprof retention-days: ${{ env.HEAP_DUMP_RETENTION_DAYS }} - - name: Clean local Maven repo - # Avoid creating a cache entry because this job doesn't download all dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: rm -rf ~/.m2/repository build-test-matrix: runs-on: ubuntu-latest @@ -534,6 +526,8 @@ jobs: github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha && format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }} - uses: ./.github/actions/setup + with: + cache: restore - name: Update PR check uses: ./.github/actions/update-check if: >- @@ -603,10 +597,6 @@ jobs: ./.github/bin/build-matrix-from-impacted.py -v -i gib-impacted.log -m .github/test-matrix.yaml -o matrix.json echo "Matrix: $(jq '.' matrix.json)" echo "matrix=$(jq -c '.' matrix.json)" >> $GITHUB_OUTPUT - - name: Clean local Maven repo - # Avoid creating a cache entry because this job doesn't download all dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: rm -rf ~/.m2/repository test: runs-on: ubuntu-latest @@ -628,6 +618,7 @@ jobs: format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }} - uses: ./.github/actions/setup with: + cache: restore java-version: ${{ matrix.jdk != '' && matrix.jdk || '17' }} - name: Cleanup node # This is required as a virtual environment update 20210219.1 left too little space for MemSQL to work @@ -816,10 +807,6 @@ jobs: check_name: ${{ github.job }} with secrets conclusion: ${{ job.status }} github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Clean local Maven repo - # Avoid creating a cache entry because this job doesn't download all dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: rm -rf ~/.m2/repository build-pt: runs-on: ubuntu-latest @@ -835,6 +822,8 @@ jobs: github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha && format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }} - uses: ./.github/actions/setup + with: + cache: restore - uses: dorny/paths-filter@v2 id: filter with: @@ -1053,10 +1042,6 @@ jobs: run: | echo "Matrix: $(jq '.' matrix.json)" echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT - - name: Clean local Maven repo - # Avoid creating a cache entry because this job doesn't download all dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: rm -rf ~/.m2/repository pt: runs-on: ubuntu-latest