diff --git a/.github/actions/runTestsTaggedAs/action.yaml b/.github/actions/runTestsTaggedAs/action.yaml index f70cfda6e83..cf9fefc4275 100644 --- a/.github/actions/runTestsTaggedAs/action.yaml +++ b/.github/actions/runTestsTaggedAs/action.yaml @@ -23,22 +23,8 @@ runs: - name: Set up runner uses: ./.github/actions/setUpRunner - - name: Cache Maven repository - External dependencies # Cache of external Maven dependencies built from 'build' job - uses: actions/cache@v4 - with: - path: ~/.m2/repository/ - key: ${{ runner.os }}-maven-develop-dependencies - - - name: Cache Maven repository - Kapua artifacts # Cache of Kapua artifacts built from 'build' job - uses: actions/cache@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 - run: mv ~/.m2/kapua-repository/org/eclipse/kapua ~/.m2/repository/org/eclipse/kapua - shell: bash + - name: Set up Maven caches + uses: ./.github/actions/setUpMavenCaches - name: Docker images creation if: ${{ inputs.needs-docker-images == 'true' }} diff --git a/.github/actions/setUpMavenCaches/action.yaml b/.github/actions/setUpMavenCaches/action.yaml new file mode 100644 index 00000000000..c0bc8ea5e5c --- /dev/null +++ b/.github/actions/setUpMavenCaches/action.yaml @@ -0,0 +1,29 @@ +name: 'Set Up Maven caches' +description: | + Set up maven caches to speedup build time and reuse built artifacts +inputs: + kapua-artifact-cache-enabled: + description: Whether to enable Kapua artifacts cache or not. If not enable you'll be required to build Kapua Artifacts on the runner + default: 'true' +runs: + using: "composite" + steps: + - name: Cache Maven repository - External dependencies # Cache of external Maven dependencies to speed up build time + id: cache-maven-external-deps + uses: actions/cache@v4 + with: + path: ~/.m2/repository/ + key: ${{ runner.os }}-maven-develop-dependencies + + - 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 + with: + path: ~/.m2/kapua-repository/org/eclipse/kapua + key: ${{ runner.os }}-maven-${{ github.run_number }}-kapua-artifacts + + - 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' }} + run: mv ~/.m2/kapua-repository/org/eclipse/kapua ~/.m2/repository/org/eclipse/kapua + shell: bash diff --git a/.github/workflows/kapua-ci.yaml b/.github/workflows/kapua-ci.yaml index 7622a1efc01..9689d282115 100755 --- a/.github/workflows/kapua-ci.yaml +++ b/.github/workflows/kapua-ci.yaml @@ -19,23 +19,8 @@ jobs: - name: Set up runner uses: ./.github/actions/setUpRunner - - name: Cache Maven repository - External dependencies # Cache of external Maven dependencies to speed up build time - id: cache-maven-external-deps - uses: actions/cache@v4 - with: - path: ~/.m2/repository/ - key: ${{ runner.os }}-maven-develop-dependencies - - - name: Cache Maven repository - Kapua artifacts # Cache of Kapua artifacts be reused in following jobs - id: cache-maven-kapua-artifacts - uses: actions/cache@v4 - with: - path: ~/.m2/kapua-repository/org/eclipse/kapua - key: ${{ runner.os }}-maven-${{ github.run_number }}-kapua-artifacts - - - 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: steps.cache-maven-kapua-artifacts.outputs.cache-hit == 'true' - run: mv ~/.m2/kapua-repository/org/eclipse/kapua ~/.m2/repository/org/eclipse/kapua + - name: Set up Maven caches + uses: ./.github/actions/setUpMavenCaches - name: Maven version run: mvn --version @@ -361,15 +346,14 @@ jobs: steps: - name: Checkout repository # Checks out a copy of the repository on the runner uses: actions/checkout@v4 + - name: Set up runner uses: ./.github/actions/setUpRunner - - name: Cache Maven repository - External dependencies # Cache of external Maven dependencies to speed up build time - id: cache-maven-external-deps - uses: actions/cache@v4 + - name: Set up Maven caches + uses: ./.github/actions/setUpMavenCaches with: - path: ~/.m2/repository/ - key: ${{ runner.os }}-maven-develop-dependencies + kapua-artifact-cache-enabled: 'false' - name: Build Kapua Javadoc run: mvn -B -DskipTests install javadoc:jar diff --git a/.github/workflows/security-scan.yaml b/.github/workflows/security-scan.yaml index d5a6f191d5c..03ff73f959c 100755 --- a/.github/workflows/security-scan.yaml +++ b/.github/workflows/security-scan.yaml @@ -23,12 +23,10 @@ jobs: - name: Set up runner uses: ./.github/actions/setUpRunner - - name: Cache Maven repository - External dependencies # Cache of external Maven dependencies to speed up build time - id: cache-maven-external-deps - uses: actions/cache@v4 + - name: Set up Maven caches + uses: ./.github/actions/setUpMavenCaches with: - path: ~/.m2/repository/ - key: ${{ runner.os }}-maven-develop-dependencies + kapua-artifact-cache-enabled: 'false' - name: Run Owasp Security Scan run: mvn -B ${BUILD_OPTS} -DskipTests -Psecurity-scan verify \ No newline at end of file diff --git a/.github/workflows/sonarCloud-scan.yaml b/.github/workflows/sonarCloud-scan.yaml index b64667a1f8d..78a1c42d297 100644 --- a/.github/workflows/sonarCloud-scan.yaml +++ b/.github/workflows/sonarCloud-scan.yaml @@ -23,12 +23,10 @@ jobs: - name: Set up runner uses: ./.github/actions/setUpRunner - - name: Cache Maven repository - External dependencies # Cache of external Maven dependencies to speed up build time - id: cache-maven-external-deps - uses: actions/cache@v4 + - name: Set up Maven caches + uses: ./.github/actions/setUpMavenCaches with: - path: ~/.m2/repository/ - key: ${{ runner.os }}-maven-develop-dependencies + kapua-artifact-cache-enabled: 'false' - name: Cache SonarQube packages uses: actions/cache@v4