Skip to content

Commit

Permalink
♻️ [CI] Changed to use cache/restore and cache/save GitHub Actions
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <[email protected]>
  • Loading branch information
Coduz committed Jan 24, 2025
1 parent 6d374d9 commit 0d2ff28
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: 'Prepare Maven Repo'
name: 'Save built Kapua Artifacts'
description: |
Prepares ~/.m2/repository/ for caching
Saves the built Kapua artifacts for later usage
runs:
using: "composite"
steps:
- name: Extract built Kapua artifacts # This splits the built Kapua artifact of this run from the cached repository of external dependencies for caching
if: ${{ steps.cache-maven-kapua-artifacts.outputs.cache-hit != 'true' }}
run: |
mkdir --parents ~/.m2/kapua-repository/org/eclipse/
mv ~/.m2/repository/org/eclipse/kapua ~/.m2/kapua-repository/org/eclipse/kapua
shell: bash
shell: bash
- name: Save built Kapua artifacts
uses: actions/cache/save@v4
with:
path: ~/.m2/kapua-repository/org/eclipse/kapua
key: ${{ runner.os }}-maven-${{ github.run_number }}-kapua-artifacts
5 changes: 3 additions & 2 deletions .github/actions/setUpMavenCaches/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ runs:
- name: Cache Maven repository - Kapua artifacts # Cache of built Kapua artifacts be reused in other jobs
if: ${{ inputs.kapua-artifact-cache-enabled == 'true' }}
id: cache-maven-kapua-artifacts
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: ~/.m2/kapua-repository/org/eclipse/kapua
key: ${{ runner.os }}-maven-${{ github.run_number }}-kapua-artifacts
fail-on-cache-miss: 'true'

- name: Build full cached Maven repository # This adds the built Kapua artifact of this run to the cached repository of external dependencies. Used when re-running a job
if: ${{ inputs.kapua-artifact-cache-enabled == 'true' && steps.cache-maven-kapua-artifacts.outputs.cache-hit == 'true' }}
if: ${{ inputs.kapua-artifact-cache-enabled == 'true' }}
run: mv ~/.m2/kapua-repository/org/eclipse/kapua ~/.m2/repository/org/eclipse/kapua
shell: bash

6 changes: 4 additions & 2 deletions .github/workflows/kapua-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ jobs:

- name: Set up Maven caches
uses: ./.github/actions/setUpMavenCaches
with:
kapua-artifact-cache-enabled: 'false'

- name: Maven version
run: mvn --version

- name: Build Kapua project
run: mvn -B -DskipTests clean install -T 1C

- name: Prepare Maven repo for caching
uses: ./.github/actions/prepareMavenRepoForCache
- name: Save built Kapua Artifacts
uses: ./.github/actions/saveBuiltKapuaArtifacts

build-javadoc:
needs: build
Expand Down

0 comments on commit 0d2ff28

Please sign in to comment.