From 58ef407e96568454495d0f81a715c370ac6be242 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Wed, 22 Jan 2025 17:55:12 +0100 Subject: [PATCH 01/10] :recycle: [CI] Improved chaching of dependencies for Kapua CI workflow Signed-off-by: Alberto Codutti --- .github/actions/runTestsTaggedAs/action.yaml | 32 ++++++-- .github/workflows/kapua-ci.yaml | 78 ++++++++++++++++---- 2 files changed, 88 insertions(+), 22 deletions(-) diff --git a/.github/actions/runTestsTaggedAs/action.yaml b/.github/actions/runTestsTaggedAs/action.yaml index 0b449e091eb..c916b7a2f98 100644 --- a/.github/actions/runTestsTaggedAs/action.yaml +++ b/.github/actions/runTestsTaggedAs/action.yaml @@ -20,47 +20,67 @@ inputs: runs: using: "composite" steps: - - name: Setup java + - name: Setup Java 11 uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 - - name: Setup Node + + - name: Setup Node 16 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' }} + + - 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/repository - key: ${{ github.run_id }}-${{ github.run_number }}-maven-cache + 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: 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 \ No newline at end of file diff --git a/.github/workflows/kapua-ci.yaml b/.github/workflows/kapua-ci.yaml index 670bdb0e063..aaf588b69b0 100755 --- a/.github/workflows/kapua-ci.yaml +++ b/.github/workflows/kapua-ci.yaml @@ -13,23 +13,57 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v4 # Checks out a copy of the repository on the ubuntu-latest machine - - uses: actions/setup-java@v4 + - name: Checkout repository # Checks out a copy of the repository on the worker + uses: actions/checkout@v4 + + - name: Setup Java 11 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 - - uses: actions/setup-node@v4 # Installs Node and NPM + + - name: Setup Node 16 # Installs Node and NPM + uses: actions/setup-node@v4 with: node-version: 16 + - name: Install Swagger CLI # Installs Swagger CLI to bundle OpenAPI files run: 'npm install -g @apidevtools/swagger-cli' - - uses: actions/cache@v4 # Cache local Maven repository to reuse dependencies + shell: bash + + - 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: ${{ github.run_id }}-${{ github.run_number }}-maven-cache - - run: mvn -v - - run: docker images -a # used as log (should show only GitHub environment standard docker images; if kapua images are present, something is wrong) - - run: mvn -B -DskipTests clean install -T 1C + 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: Maven version + run: mvn --version + + - name: Build Kapua project + run: mvn -B -DskipTests clean install -T 1C + + - name: Download all dependencies of the project # Downloading all referenced dependencies to build a complete cache if not present + if: steps.cache-maven-external-deps.outputs.cache-hit != 'true' + run: mvn dependency:go-offline + + - 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 + test-brokerAcl: needs: build runs-on: ubuntu-latest @@ -291,18 +325,30 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 + - name: Clones Kapua repo inside the runner + uses: actions/checkout@v4 + + - name: Setup Java 11 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 - - uses: actions/setup-node@v4 # Installs Node and NPM + + - name: Setup Node 16 + 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' - - uses: actions/cache@v4 # Cache local Maven repository to reuse dependencies + shell: bash + + - 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: ${{ github.run_id }}-${{ github.run_number }}-maven-cache - - run: mvn -B -DskipTests install javadoc:jar + path: ~/.m2/repository/ + key: ${{ runner.os }}-maven-develop-dependencies + + - name: Build Kapua Javadoc + run: mvn -B -DskipTests install javadoc:jar From 48e771b1f9b91f98ae35227497b073bc897d0972 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 14:23:48 +0100 Subject: [PATCH 02/10] :recycle: [CI] Aligned chaching of dependencies for Security Scan workflow Signed-off-by: Alberto Codutti --- .github/workflows/security-scan.yaml | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/security-scan.yaml b/.github/workflows/security-scan.yaml index 8f7c3eb4efb..84b825003c6 100755 --- a/.github/workflows/security-scan.yaml +++ b/.github/workflows/security-scan.yaml @@ -4,6 +4,7 @@ on: branches: - 'develop' - 'release-**' + - 'feat-improvedGitHubActionCaching' env: BUILD_OPTS: "" @@ -14,22 +15,32 @@ jobs: owasp-dependency-check: name: Owasp Dependency Check runs-on: ubuntu-latest + timeout-minutes: 45 steps: - - uses: actions/checkout@v4 # Checks out a copy of the repository on the ubuntu-latest machine - - uses: actions/setup-java@v4 + - name: Clones Kapua repo inside the runner + uses: actions/checkout@v4 + + - name: Setup Java 11 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 - cache: 'maven' - - uses: actions/setup-node@v4 # Installs Node and NPM + + - name: Setup Node 16 + 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' - - uses: actions/cache@v4 # Cache local Maven repository to reuse dependencies + shell: bash + + - 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-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - run: mvn -B ${BUILD_OPTS} -DskipTests -Psecurity-scan verify \ No newline at end of file + path: ~/.m2/repository/ + key: ${{ runner.os }}-maven-develop-dependencies + + - name: Run Owasp Security Scan + run: mvn -B ${BUILD_OPTS} -DskipTests -Psecurity-scan verify \ No newline at end of file From 486d70d5568c022383db58da54be32edf19ad32e Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 14:33:00 +0100 Subject: [PATCH 03/10] :recycle: [CI] Aligned chaching of dependencies for Sonar Scan workflow Signed-off-by: Alberto Codutti --- .github/workflows/sonarCloud-scan.yaml | 35 +++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/sonarCloud-scan.yaml b/.github/workflows/sonarCloud-scan.yaml index 5c1104b2b76..b019c51a7ff 100644 --- a/.github/workflows/sonarCloud-scan.yaml +++ b/.github/workflows/sonarCloud-scan.yaml @@ -5,6 +5,7 @@ on: branches: - 'develop' - 'release-**' + - 'feat-improvedGitHubActionCaching' pull_request: branches: - 'develop' @@ -14,33 +15,39 @@ jobs: build: name: Analyze runs-on: ubuntu-latest + timeout-minutes: 45 steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up JDK 11 + - name: Clones Kapua repo inside the runner + uses: actions/checkout@v4 + + - name: Setup Java 11 uses: actions/setup-java@v4 with: - java-version: 11 distribution: 'zulu' - - name: Set up Node 16 - uses: actions/setup-node@v4 + java-version: 11 + + - name: Setup Node 16 + 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: 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 SonarQube packages uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 + - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3deba26736e9b01f8a00b16eb5520876c9eae7fa Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 14:50:41 +0100 Subject: [PATCH 04/10] :recycle: [CI] Added a common action to perform runner setup Signed-off-by: Alberto Codutti --- .github/actions/runTestsTaggedAs/action.yaml | 16 +-- .github/actions/setUpRunner/action.yaml | 23 ++++ .github/workflows/kapua-ci.yaml | 129 +++++++++++-------- .github/workflows/security-scan.yaml | 18 +-- .github/workflows/sonarCloud-scan.yaml | 18 +-- 5 files changed, 106 insertions(+), 98 deletions(-) create mode 100644 .github/actions/setUpRunner/action.yaml diff --git a/.github/actions/runTestsTaggedAs/action.yaml b/.github/actions/runTestsTaggedAs/action.yaml index c916b7a2f98..f70cfda6e83 100644 --- a/.github/actions/runTestsTaggedAs/action.yaml +++ b/.github/actions/runTestsTaggedAs/action.yaml @@ -20,20 +20,8 @@ inputs: 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 # 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: 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 diff --git a/.github/actions/setUpRunner/action.yaml b/.github/actions/setUpRunner/action.yaml new file mode 100644 index 00000000000..613a18838c2 --- /dev/null +++ b/.github/actions/setUpRunner/action.yaml @@ -0,0 +1,23 @@ +name: 'Set Up Runner' +description: | + Set up runner with tools required for the build + - Setup Java 11 + - Setup Node 16 + - Install Swagger CLI +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 # 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 \ No newline at end of file diff --git a/.github/workflows/kapua-ci.yaml b/.github/workflows/kapua-ci.yaml index aaf588b69b0..7622a1efc01 100755 --- a/.github/workflows/kapua-ci.yaml +++ b/.github/workflows/kapua-ci.yaml @@ -13,23 +13,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Checkout repository # Checks out a copy of the repository on the worker + - name: Checkout repository # Checks out a copy of the repository on the runner uses: actions/checkout@v4 - - name: Setup Java 11 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: 11 - - - name: Setup Node 16 # Installs Node and NPM - uses: actions/setup-node@v4 - 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: 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 @@ -69,8 +57,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@brokerAcl' @@ -80,8 +70,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@tag' @@ -91,8 +83,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@broker' @@ -102,8 +96,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@device' @@ -113,8 +109,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@deviceManagement' @@ -124,8 +122,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@connection' @@ -135,8 +135,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@datastore' @@ -146,8 +148,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@user' @@ -157,8 +161,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@userIntegrationBase' @@ -168,8 +174,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@userIntegration' @@ -179,8 +187,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@security' @@ -190,8 +200,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '(@job or @scheduler) and not @it' @@ -201,8 +213,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@job and @it' @@ -212,8 +226,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@jobEngine' @@ -223,8 +239,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@jobsIntegration' @@ -234,8 +252,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@account or @translator' @@ -245,8 +265,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@role or @group' @@ -256,8 +278,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@deviceRegistry' @@ -267,8 +291,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@endpoint' @@ -278,8 +304,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@rest_auth' @@ -290,8 +318,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@rest_cors' @@ -302,8 +332,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: tag: '@rest_parsing' @@ -314,8 +346,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - 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 - uses: ./.github/actions/runTestsTaggedAs with: needs-docker-images: 'false' @@ -325,23 +359,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - name: Checkout repository # Checks out a copy of the repository on the runner uses: actions/checkout@v4 - - - name: Setup Java 11 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: 11 - - - name: Setup Node 16 - 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: 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 diff --git a/.github/workflows/security-scan.yaml b/.github/workflows/security-scan.yaml index 84b825003c6..d5a6f191d5c 100755 --- a/.github/workflows/security-scan.yaml +++ b/.github/workflows/security-scan.yaml @@ -17,23 +17,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - name: Checkout repository # Checks out a copy of the repository on the runner uses: actions/checkout@v4 - - name: Setup Java 11 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: 11 - - - name: Setup Node 16 - 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: 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 diff --git a/.github/workflows/sonarCloud-scan.yaml b/.github/workflows/sonarCloud-scan.yaml index b019c51a7ff..b64667a1f8d 100644 --- a/.github/workflows/sonarCloud-scan.yaml +++ b/.github/workflows/sonarCloud-scan.yaml @@ -17,23 +17,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Clones Kapua repo inside the runner + - name: Checkout repository # Checks out a copy of the repository on the runner uses: actions/checkout@v4 - - name: Setup Java 11 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: 11 - - - name: Setup Node 16 - 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: 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 From 944202bb3b2820dfea8246504526ba3c3fe0ce18 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 15:31:34 +0100 Subject: [PATCH 05/10] :recycle: [CI] Added a common action to perform maven cache setup Signed-off-by: Alberto Codutti --- .github/actions/runTestsTaggedAs/action.yaml | 18 ++---------- .github/actions/setUpMavenCaches/action.yaml | 29 ++++++++++++++++++++ .github/workflows/kapua-ci.yaml | 28 ++++--------------- .github/workflows/security-scan.yaml | 8 ++---- .github/workflows/sonarCloud-scan.yaml | 8 ++---- 5 files changed, 43 insertions(+), 48 deletions(-) create mode 100644 .github/actions/setUpMavenCaches/action.yaml 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 From ac36de562448684fec9d84674ae93e602483b422 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 15:51:11 +0100 Subject: [PATCH 06/10] :recycle: [CI] Optimized adding entries to /etc/hosts for tests Signed-off-by: Alberto Codutti --- .github/actions/runTestsTaggedAs/action.yaml | 10 ---------- .github/actions/setUpRunner/action.yaml | 7 +++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/actions/runTestsTaggedAs/action.yaml b/.github/actions/runTestsTaggedAs/action.yaml index cf9fefc4275..1a3303e7e05 100644 --- a/.github/actions/runTestsTaggedAs/action.yaml +++ b/.github/actions/runTestsTaggedAs/action.yaml @@ -36,16 +36,6 @@ runs: 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 diff --git a/.github/actions/setUpRunner/action.yaml b/.github/actions/setUpRunner/action.yaml index 613a18838c2..31495b0e34c 100644 --- a/.github/actions/setUpRunner/action.yaml +++ b/.github/actions/setUpRunner/action.yaml @@ -4,6 +4,7 @@ description: | - Setup Java 11 - Setup Node 16 - Install Swagger CLI + - Add entries to /etc/hosts runs: using: "composite" steps: @@ -20,4 +21,10 @@ runs: - name: Install Swagger CLI # Installs Swagger CLI 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 \ No newline at end of file From 1a922f7639162b5ef452eeb00baeb9227bfd2fbc Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 16:13:30 +0100 Subject: [PATCH 07/10] :recycle: [CI] Added a common action to prepare m2 repo for caching Signed-off-by: Alberto Codutti --- .../prepareMavenRepoForCache/action.yaml | 11 +++ .github/actions/setUpMavenCaches/action.yaml | 1 + .github/workflows/kapua-ci.yaml | 76 +++++++++---------- 3 files changed, 49 insertions(+), 39 deletions(-) create mode 100644 .github/actions/prepareMavenRepoForCache/action.yaml diff --git a/.github/actions/prepareMavenRepoForCache/action.yaml b/.github/actions/prepareMavenRepoForCache/action.yaml new file mode 100644 index 00000000000..934d3df8131 --- /dev/null +++ b/.github/actions/prepareMavenRepoForCache/action.yaml @@ -0,0 +1,11 @@ +name: 'Prepare Maven Repo' +description: | + Prepares ~/.m2/repository/ for caching +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 \ No newline at end of file diff --git a/.github/actions/setUpMavenCaches/action.yaml b/.github/actions/setUpMavenCaches/action.yaml index c0bc8ea5e5c..acf857790a8 100644 --- a/.github/actions/setUpMavenCaches/action.yaml +++ b/.github/actions/setUpMavenCaches/action.yaml @@ -27,3 +27,4 @@ runs: 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 9689d282115..aaa6bf629d2 100755 --- a/.github/workflows/kapua-ci.yaml +++ b/.github/workflows/kapua-ci.yaml @@ -28,14 +28,43 @@ jobs: - name: Build Kapua project run: mvn -B -DskipTests clean install -T 1C - - name: Download all dependencies of the project # Downloading all referenced dependencies to build a complete cache if not present - if: steps.cache-maven-external-deps.outputs.cache-hit != 'true' - run: mvn dependency:go-offline + - name: Prepare Maven repo for caching + uses: ./.github/actions/prepareMavenRepoForCache - - 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 + build-javadoc: + needs: build + name: Build Javadoc + runs-on: ubuntu-latest + timeout-minutes: 45 + 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: Set up Maven caches + uses: ./.github/actions/setUpMavenCaches + with: + kapua-artifact-cache-enabled: 'false' + + - name: Build Kapua Javadoc + run: mvn -B -DskipTests install javadoc:jar + + junit-tests: + needs: build + name: Run jUnit Tests + runs-on: ubuntu-latest + timeout-minutes: 45 + 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 + - uses: ./.github/actions/runTestsTaggedAs + with: + needs-docker-images: 'false' + run-junit: 'true' test-brokerAcl: needs: build @@ -325,35 +354,4 @@ jobs: with: tag: '@rest_parsing' needs-docker-images: 'true' - needs-api-docker-image: 'true' - junit-tests: - needs: build - runs-on: ubuntu-latest - timeout-minutes: 45 - 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 - - uses: ./.github/actions/runTestsTaggedAs - with: - needs-docker-images: 'false' - run-junit: 'true' - build-javadoc: - needs: build - runs-on: ubuntu-latest - timeout-minutes: 45 - 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: Set up Maven caches - uses: ./.github/actions/setUpMavenCaches - with: - kapua-artifact-cache-enabled: 'false' - - - name: Build Kapua Javadoc - run: mvn -B -DskipTests install javadoc:jar + needs-api-docker-image: 'true' \ No newline at end of file From 6d374d90a7058da031f91aae82b59bb30e4812a0 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 16:21:57 +0100 Subject: [PATCH 08/10] :recycle: [CI] Added a common action to prepare m2 repo for caching Signed-off-by: Alberto Codutti --- .github/actions/prepareMavenRepoForCache/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/prepareMavenRepoForCache/action.yaml b/.github/actions/prepareMavenRepoForCache/action.yaml index 934d3df8131..b4aa1539149 100644 --- a/.github/actions/prepareMavenRepoForCache/action.yaml +++ b/.github/actions/prepareMavenRepoForCache/action.yaml @@ -5,6 +5,7 @@ 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 From 0d2ff28c9a24c73e615acd65f98671511bbd86a7 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Thu, 23 Jan 2025 16:50:41 +0100 Subject: [PATCH 09/10] :recycle: [CI] Changed to use cache/restore and cache/save GitHub Actions Signed-off-by: Alberto Codutti --- .../action.yaml | 12 ++++++++---- .github/actions/setUpMavenCaches/action.yaml | 5 +++-- .github/workflows/kapua-ci.yaml | 6 ++++-- 3 files changed, 15 insertions(+), 8 deletions(-) rename .github/actions/{prepareMavenRepoForCache => saveBuiltKapuaArtifacts}/action.yaml (53%) diff --git a/.github/actions/prepareMavenRepoForCache/action.yaml b/.github/actions/saveBuiltKapuaArtifacts/action.yaml similarity index 53% rename from .github/actions/prepareMavenRepoForCache/action.yaml rename to .github/actions/saveBuiltKapuaArtifacts/action.yaml index b4aa1539149..ef43bf76fcd 100644 --- a/.github/actions/prepareMavenRepoForCache/action.yaml +++ b/.github/actions/saveBuiltKapuaArtifacts/action.yaml @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/.github/actions/setUpMavenCaches/action.yaml b/.github/actions/setUpMavenCaches/action.yaml index acf857790a8..7563468ba36 100644 --- a/.github/actions/setUpMavenCaches/action.yaml +++ b/.github/actions/setUpMavenCaches/action.yaml @@ -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 diff --git a/.github/workflows/kapua-ci.yaml b/.github/workflows/kapua-ci.yaml index aaa6bf629d2..e2e848b2f4e 100755 --- a/.github/workflows/kapua-ci.yaml +++ b/.github/workflows/kapua-ci.yaml @@ -21,6 +21,8 @@ jobs: - name: Set up Maven caches uses: ./.github/actions/setUpMavenCaches + with: + kapua-artifact-cache-enabled: 'false' - name: Maven version run: mvn --version @@ -28,8 +30,8 @@ jobs: - 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 From 3d876daa22e7d0f5989c1d4b1d23c6decdfcf5f2 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Fri, 24 Jan 2025 11:22:46 +0100 Subject: [PATCH 10/10] :recycle: [CI] Cleanup Signed-off-by: Alberto Codutti --- .github/actions/runTestsTaggedAs/action.yaml | 2 +- .../saveBuiltKapuaArtifacts/action.yaml | 1 + .github/actions/setUpRunner/action.yaml | 6 ++-- .github/workflows/kapua-ci.yaml | 29 ++++++++++++++----- .github/workflows/security-scan.yaml | 2 -- .github/workflows/sonarCloud-scan.yaml | 3 -- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/actions/runTestsTaggedAs/action.yaml b/.github/actions/runTestsTaggedAs/action.yaml index 1a3303e7e05..47d2f447241 100644 --- a/.github/actions/runTestsTaggedAs/action.yaml +++ b/.github/actions/runTestsTaggedAs/action.yaml @@ -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: diff --git a/.github/actions/saveBuiltKapuaArtifacts/action.yaml b/.github/actions/saveBuiltKapuaArtifacts/action.yaml index ef43bf76fcd..5dbb51bb56f 100644 --- a/.github/actions/saveBuiltKapuaArtifacts/action.yaml +++ b/.github/actions/saveBuiltKapuaArtifacts/action.yaml @@ -9,6 +9,7 @@ runs: 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: diff --git a/.github/actions/setUpRunner/action.yaml b/.github/actions/setUpRunner/action.yaml index 31495b0e34c..1d3f119f6f6 100644 --- a/.github/actions/setUpRunner/action.yaml +++ b/.github/actions/setUpRunner/action.yaml @@ -4,7 +4,7 @@ description: | - Setup Java 11 - Setup Node 16 - Install Swagger CLI - - Add entries to /etc/hosts + - Add entries to /etc/hosts for tests runs: using: "composite" steps: @@ -15,11 +15,11 @@ runs: java-version: 11 - name: Setup Node 16 - uses: actions/setup-node@v4 # Installs Node and NPM + uses: actions/setup-node@v4 with: node-version: 16 - - name: Install Swagger CLI # Installs Swagger CLI to bundle OpenAPI files + - name: Install Swagger CLI # Required to bundle OpenAPI files run: 'npm install -g @apidevtools/swagger-cli' shell: bash diff --git a/.github/workflows/kapua-ci.yaml b/.github/workflows/kapua-ci.yaml index e2e848b2f4e..bb4c8038388 100755 --- a/.github/workflows/kapua-ci.yaml +++ b/.github/workflows/kapua-ci.yaml @@ -15,21 +15,16 @@ 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: 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: Save built Kapua Artifacts uses: ./.github/actions/saveBuiltKapuaArtifacts @@ -41,15 +36,12 @@ 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: Set up Maven caches uses: ./.github/actions/setUpMavenCaches with: kapua-artifact-cache-enabled: 'false' - - name: Build Kapua Javadoc run: mvn -B -DskipTests install javadoc:jar @@ -81,6 +73,7 @@ jobs: with: tag: '@brokerAcl' needs-docker-images: 'true' + test-tag: needs: build runs-on: ubuntu-latest @@ -94,6 +87,7 @@ jobs: with: tag: '@tag' needs-docker-images: 'false' + test-broker: needs: build runs-on: ubuntu-latest @@ -107,6 +101,7 @@ jobs: with: tag: '@broker' needs-docker-images: 'true' + test-device: needs: build runs-on: ubuntu-latest @@ -120,6 +115,7 @@ jobs: with: tag: '@device' needs-docker-images: 'true' + test-device-management: needs: build runs-on: ubuntu-latest @@ -133,6 +129,7 @@ jobs: with: tag: '@deviceManagement' needs-docker-images: 'true' + test-connection: needs: build runs-on: ubuntu-latest @@ -146,6 +143,7 @@ jobs: with: tag: '@connection' needs-docker-images: 'true' + test-datastore: needs: build runs-on: ubuntu-latest @@ -159,6 +157,7 @@ jobs: with: tag: '@datastore' needs-docker-images: 'true' + test-user: needs: build runs-on: ubuntu-latest @@ -172,6 +171,7 @@ jobs: with: tag: '@user' needs-docker-images: 'false' + test-userIntegrationBase: needs: build runs-on: ubuntu-latest @@ -185,6 +185,7 @@ jobs: with: tag: '@userIntegrationBase' needs-docker-images: 'true' + test-userIntegration: needs: build runs-on: ubuntu-latest @@ -198,6 +199,7 @@ jobs: with: tag: '@userIntegration' needs-docker-images: 'true' + test-security: needs: build runs-on: ubuntu-latest @@ -211,6 +213,7 @@ jobs: with: tag: '@security' needs-docker-images: 'false' + test-jobsAndScheduler: needs: build runs-on: ubuntu-latest @@ -224,6 +227,7 @@ jobs: with: tag: '(@job or @scheduler) and not @it' needs-docker-images: 'false' + test-job-IT: needs: build runs-on: ubuntu-latest @@ -237,6 +241,7 @@ jobs: with: tag: '@job and @it' needs-docker-images: 'true' + test-jobEngine-IT: needs: build runs-on: ubuntu-latest @@ -250,6 +255,7 @@ jobs: with: tag: '@jobEngine' needs-docker-images: 'true' + test-jobsIntegration: needs: build runs-on: ubuntu-latest @@ -263,6 +269,7 @@ jobs: with: tag: '@jobsIntegration' needs-docker-images: 'true' + test-accountAndTranslator: needs: build runs-on: ubuntu-latest @@ -276,6 +283,7 @@ jobs: with: tag: '@account or @translator' needs-docker-images: 'false' + test-RoleAndGroup: needs: build runs-on: ubuntu-latest @@ -289,6 +297,7 @@ jobs: with: tag: '@role or @group' needs-docker-images: 'false' + test-deviceRegistry: needs: build runs-on: ubuntu-latest @@ -302,6 +311,7 @@ jobs: with: tag: '@deviceRegistry' needs-docker-images: 'true' + test-endpoint: needs: build runs-on: ubuntu-latest @@ -315,6 +325,7 @@ jobs: with: tag: '@endpoint' needs-docker-images: 'true' + test-api-auth: needs: build runs-on: ubuntu-latest @@ -329,6 +340,7 @@ jobs: tag: '@rest_auth' needs-docker-images: 'true' needs-api-docker-image: 'true' + test-api-corsfilter: needs: test-endpoint # test suite dependent on the endpoint service (if it has failings it's useless to perform these tests) runs-on: ubuntu-latest @@ -343,6 +355,7 @@ jobs: tag: '@rest_cors' needs-docker-images: 'true' needs-api-docker-image: 'true' + test-api-parsing: needs: test-api-auth runs-on: ubuntu-latest diff --git a/.github/workflows/security-scan.yaml b/.github/workflows/security-scan.yaml index 03ff73f959c..5f038402956 100755 --- a/.github/workflows/security-scan.yaml +++ b/.github/workflows/security-scan.yaml @@ -3,8 +3,6 @@ on: push: branches: - 'develop' - - 'release-**' - - 'feat-improvedGitHubActionCaching' env: BUILD_OPTS: "" diff --git a/.github/workflows/sonarCloud-scan.yaml b/.github/workflows/sonarCloud-scan.yaml index 78a1c42d297..27dd2c44235 100644 --- a/.github/workflows/sonarCloud-scan.yaml +++ b/.github/workflows/sonarCloud-scan.yaml @@ -4,12 +4,9 @@ on: push: branches: - 'develop' - - 'release-**' - - 'feat-improvedGitHubActionCaching' pull_request: branches: - 'develop' - - 'release-**' jobs: build: