Correctly setup cache to be able to make use of different restore keys (#11248)
Motivation: We should setup the caching so it will be able to use different restore keys and so almost never need to start from scratch Modifications: Adjust caching config to make use of different restore keys for maven caching but also docker caching Result: Better cache usage
This commit is contained in:
parent
d984d4422c
commit
c83601167f
8
.github/workflows/ci-build.yml
vendored
8
.github/workflows/ci-build.yml
vendored
@ -29,17 +29,19 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-${{ matrix.setup }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ matrix.setup }}-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
# Enable caching of Docker layers
|
||||
- uses: satackey/action-docker-layer-caching@v0.0.11
|
||||
continue-on-error: true
|
||||
with:
|
||||
key: build-${{ matrix.setup }}-docker-cache-{hash}
|
||||
key: build-docker-cache-${{ matrix.setup }}-{hash}
|
||||
restore-keys: |
|
||||
build-${{ matrix.setup }}-docker-cache-
|
||||
build-docker-cache-${{ matrix.setup }}-
|
||||
build-docker-cache-
|
||||
|
||||
- name: Build docker image
|
||||
run: docker-compose ${{ matrix.docker-compose-build }}
|
||||
|
6
.github/workflows/ci-deploy.yml
vendored
6
.github/workflows/ci-deploy.yml
vendored
@ -32,8 +32,9 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-${{ matrix.setup }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ matrix.setup }}-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
# Enable caching of Docker layers
|
||||
@ -79,8 +80,9 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-deploy-staged-snapshots-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-deploy-staged-snapshots-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
# Setup some env to re-use later.
|
||||
|
14
.github/workflows/ci-pr.yml
vendored
14
.github/workflows/ci-pr.yml
vendored
@ -21,8 +21,9 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-verify-pr-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-verify-pr-
|
||||
${{ runner.os }}-maven-
|
||||
- name: Verify with Maven
|
||||
run: mvn verify -B --file pom.xml -Pci -DskipTests=true
|
||||
@ -40,8 +41,9 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-build-pr-aarch64-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-build-pr-aarch64-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
- uses: uraimo/run-on-arch-action@v2.0.9
|
||||
@ -99,17 +101,19 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-${{ matrix.setup }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ matrix.setup }}-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
# Enable caching of Docker layers
|
||||
- uses: satackey/action-docker-layer-caching@v0.0.11
|
||||
continue-on-error: true
|
||||
with:
|
||||
key: build-${{ matrix.setup }}-docker-cache-{hash}
|
||||
key: build-docker-cache-${{ matrix.setup }}-{hash}
|
||||
restore-keys: |
|
||||
build-${{ matrix.setup }}-docker-cache-
|
||||
build-docker-cache-${{ matrix.setup }}-
|
||||
build-docker-cache-
|
||||
|
||||
- name: Build docker image
|
||||
run: docker-compose ${{ matrix.docker-compose-build }}
|
||||
|
30
.github/workflows/ci-release.yml
vendored
30
.github/workflows/ci-release.yml
vendored
@ -34,8 +34,9 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-prepare-release-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-prepare-release-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
- name: Prepare release with Maven
|
||||
@ -95,13 +96,12 @@ jobs:
|
||||
|
||||
# Enable caching of Docker layers
|
||||
- uses: satackey/action-docker-layer-caching@v0.0.11
|
||||
env:
|
||||
docker-cache-name: staging-${{ matrix.setup }}-cache-docker
|
||||
continue-on-error: true
|
||||
with:
|
||||
key: ${{ runner.os }}-staging-${{ env.docker-cache-name }}-{hash}
|
||||
key: ${{ runner.os }}-staging-docker-cache-${{ matrix.setup }}-{hash}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-staging-${{ env.docker-cache-name }}-
|
||||
${{ runner.os }}-staging-docker-cache-${{ matrix.setup }}-
|
||||
${{ runner.os }}-staging-docker-cache-
|
||||
|
||||
- uses: s4u/maven-settings-action@v2.2.0
|
||||
with:
|
||||
@ -112,6 +112,16 @@ jobs:
|
||||
"password": "${{ secrets.SONATYPE_PASSWORD }}"
|
||||
}]
|
||||
|
||||
# Cache .m2/repository
|
||||
- name: Cache local Maven repository
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ matrix.setup }-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ matrix.setup }-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
- name: Create local staging directory
|
||||
run: mkdir -p ~/local-staging
|
||||
|
||||
@ -196,6 +206,16 @@ jobs:
|
||||
"password": "${{ secrets.SONATYPE_PASSWORD }}"
|
||||
}]
|
||||
|
||||
# Cache .m2/repository
|
||||
- name: Cache local Maven repository
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-deploy-staged-release-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-deploy-staged-release-
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
- name: Deploy local staged artifacts
|
||||
working-directory: ./prepare-release-workspace/
|
||||
# If we don't want to close the repository we can add -DskipStagingRepositoryClose=true
|
||||
|
3
.github/workflows/codeql-analysis.yml
vendored
3
.github/workflows/codeql-analysis.yml
vendored
@ -41,8 +41,9 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
key: ${{ runner.os }}-maven-${{ matrix.language }} ${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ matrix.language }}
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
|
Loading…
Reference in New Issue
Block a user