Avoid caching of Keycloak artifacts (#17465)
Also, only create the cache on build, not when running the tests Closes #17461
This commit is contained in:
parent
837c64de3d
commit
4bfa3c7a1a
2 changed files with 29 additions and 18 deletions
11
.github/actions/build-keycloak/action.yml
vendored
11
.github/actions/build-keycloak/action.yml
vendored
|
@ -32,6 +32,8 @@ runs:
|
|||
- id: maven-cache
|
||||
name: Maven cache
|
||||
uses: ./.github/actions/maven-cache
|
||||
with:
|
||||
create-cache-if-it-doesnt-exist: true
|
||||
|
||||
- id: phantomjs-cache
|
||||
name: PhantomJS cache
|
||||
|
@ -44,9 +46,10 @@ runs:
|
|||
- id: build-keycloak
|
||||
name: Build Keycloak
|
||||
shell: bash
|
||||
# By using "dependency:resolve", it will download all dependencies used in later stages for running the tests
|
||||
run: |
|
||||
MVN_HTTP_CONFIG="-Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120"
|
||||
./mvnw install -nsu -B -e -DskipTests -DskipExamples $MVN_HTTP_CONFIG
|
||||
./mvnw install dependency:resolve -nsu -B -e -DskipTests -DskipExamples $MVN_HTTP_CONFIG
|
||||
|
||||
- id: compress-keycloak-maven-repository
|
||||
name: Compress Keycloak Maven artifacts
|
||||
|
@ -74,9 +77,3 @@ runs:
|
|||
name: keycloak-dist
|
||||
path: quarkus/dist/target/keycloak*.tar.gz
|
||||
retention-days: 1
|
||||
|
||||
- id: maven-cache-cleanup
|
||||
name: Maven cache cleanup
|
||||
if: steps.maven-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: rm -rf ~/.m2/repository/org/keycloak
|
||||
|
|
36
.github/actions/maven-cache/action.yml
vendored
36
.github/actions/maven-cache/action.yml
vendored
|
@ -1,6 +1,14 @@
|
|||
name: Maven Cache
|
||||
description: Caches Maven artifacts
|
||||
|
||||
inputs:
|
||||
create-cache-if-it-doesnt-exist:
|
||||
description: >
|
||||
Only those callers which fill the cache with the right contents should set this to true to avoid creating a cache
|
||||
which contains too few or too many entries.
|
||||
required: false
|
||||
default: false
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
|
@ -12,20 +20,26 @@ runs:
|
|||
- id: cache-maven-repository
|
||||
name: Maven cache
|
||||
uses: actions/cache@v3
|
||||
if: inputs.create-cache-if-it-doesnt-exist == 'true'
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
# Two asterisks are needed to make the follow-up exclusion work
|
||||
# see https://github.com/actions/toolkit/issues/713 for the upstream issue
|
||||
path: |
|
||||
~/.m2/repository/*/*
|
||||
!~/.m2/repository/org/keycloak
|
||||
key: ${{ steps.weekly-cache-key.outputs.key }}
|
||||
|
||||
- id: check-maven-cache
|
||||
name: Check cache has no Keycloak artifacts
|
||||
if: steps.cache-maven-repository.outputs.cache-hit == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
if ( stat ~/.m2/repository/org/keycloak &>/dev/null ); then
|
||||
echo "Found org/keycloak artifacts in Maven repository cache"
|
||||
ls ~/.m2/repository/org/keycloak
|
||||
exit 1
|
||||
fi
|
||||
- id: restore-maven-repository
|
||||
name: Maven cache
|
||||
uses: actions/cache/restore@v3
|
||||
if: inputs.create-cache-if-it-doesnt-exist == 'false'
|
||||
with:
|
||||
# Two asterisks are needed to make the follow-up exclusion work
|
||||
# see https://github.com/actions/toolkit/issues/713 for the upstream issue
|
||||
path: |
|
||||
~/.m2/repository/*/*
|
||||
!~/.m2/repository/org/keycloak
|
||||
key: ${{ steps.weekly-cache-key.outputs.key }}
|
||||
|
||||
- name: Cache Maven Wrapper
|
||||
uses: actions/cache@v3
|
||||
|
|
Loading…
Reference in a new issue