Skip to content

Commit

Permalink
Merge pull request #4179 from Coduz/feat-improvedGitHubActionCaching
Browse files Browse the repository at this point in the history
♻️  [CI] Improved Kapua CI workflow artifacts and dependency caching
  • Loading branch information
Coduz authored Jan 24, 2025
2 parents d009ce5 + 3d876da commit 4a6c79b
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 135 deletions.
38 changes: 11 additions & 27 deletions .github/actions/runTestsTaggedAs/action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Execute tests tagged in a certain way'
name: 'Execute tests'
description: 'Execute tests suite for tests tagged as specified'
inputs:
tag:
Expand All @@ -20,47 +20,31 @@ inputs:
runs:
using: "composite"
steps:
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11
- name: Setup Node
uses: actions/setup-node@v4 # Installs Node and NPM
with:
node-version: 16
- name: Install Swagger CLI # Installs Swagger CLI to bundle OpenAPI files
run: 'npm install -g @apidevtools/swagger-cli'
shell: bash
- name: Reuse cached maven artifacts dependencies
if: ${{ inputs.run-junit == 'false' }}
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ github.run_id }}-${{ github.run_number }}-maven-cache
- name: Set up runner
uses: ./.github/actions/setUpRunner

- name: Set up Maven caches
uses: ./.github/actions/setUpMavenCaches

- name: Docker images creation
if: ${{ inputs.needs-docker-images == 'true' }}
run: mvn clean install -pl ${APP_PROJECTS} && mvn clean install -Pdocker -f assembly/pom.xml -pl '!:kapua-assembly-api' #api container not used in the tests at all se we don't need to build it here
shell: bash

- name: Docker rest-api image creation
if: ${{ inputs.needs-api-docker-image == 'true' }}
run: mvn clean install -Pdocker -pl :kapua-assembly-api
shell: bash
- name: Dns look-up containers needed for tests - message-broker
if: ${{ inputs.needs-docker-images == 'true' }}
run: echo "127.0.0.1 message-broker" | sudo tee -a /etc/hosts
shell: bash
- name: Dns look-up containers needed for tests - job-engine
if: ${{ inputs.needs-docker-images == 'true' }}
run: echo "127.0.0.1 job-engine" | sudo tee -a /etc/hosts
shell: bash

- name: Cucumber tests execution step
if: ${{ inputs.run-junit == 'false' }}
run: mvn -B -Dgroups='!org.eclipse.kapua.qa.markers.junit.JUnitTests' -Dcucumber.filter.tags="${{ inputs.tag }}" -pl ${TEST_PROJECTS} verify
shell: bash

- name: Junit tests execution step
if: ${{ inputs.run-junit == 'true' }}
run: mvn -B -Dgroups='org.eclipse.kapua.qa.markers.junit.JUnitTests' verify
shell: bash

- name: Code coverage results upload
uses: codecov/codecov-action@v4
17 changes: 17 additions & 0 deletions .github/actions/saveBuiltKapuaArtifacts/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Save built Kapua Artifacts'
description: |
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
run: |
mkdir --parents ~/.m2/kapua-repository/org/eclipse/
mv ~/.m2/repository/org/eclipse/kapua ~/.m2/kapua-repository/org/eclipse/kapua
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
31 changes: 31 additions & 0 deletions .github/actions/setUpMavenCaches/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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/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' }}
run: mv ~/.m2/kapua-repository/org/eclipse/kapua ~/.m2/repository/org/eclipse/kapua
shell: bash

30 changes: 30 additions & 0 deletions .github/actions/setUpRunner/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Set Up Runner'
description: |
Set up runner with tools required for the build
- Setup Java 11
- Setup Node 16
- Install Swagger CLI
- Add entries to /etc/hosts for tests
runs:
using: "composite"
steps:
- name: Setup Java 11
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11

- name: Setup Node 16
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install Swagger CLI # Required to bundle OpenAPI files
run: 'npm install -g @apidevtools/swagger-cli'
shell: bash

- name: Dns look-up Docker containers needed for tests
run: |
echo "127.0.0.1 message-broker" | sudo tee -a /etc/hosts
echo "127.0.0.1 job-engine" | sudo tee -a /etc/hosts
shell: bash
Loading

0 comments on commit 4a6c79b

Please sign in to comment.