rewrite java CI to add integration test #134
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description | |
# =========== | |
# This workflow is triggered each time | |
# commits are pushed to GitHub or a pull request is opened. | |
# It launches three jobs in parallel : a build with java 8, | |
# a build with java 17 and a SonarCloud analysis. | |
--- | |
name: Java CI | |
on: [push, pull_request] | |
env: | |
MVN_USR: ${{ secrets.MVN_USR }} | |
MVN_PWD: ${{ secrets.MVN_PWD }} | |
jobs: | |
build: | |
permissions: | |
packages: read | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ '17', '21' ] | |
name: Java ${{ matrix.Java }} CI | |
steps: | |
# the latest version at https://github.com/marketplace/actions/checkout | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# the latest version at https://github.com/marketplace/actions/setup-java-jdk | |
- name: Setup java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: ${{ matrix.java }} | |
cache: 'maven' | |
# the latest version at https://github.com/actions/cache | |
- name: Cache target folders | |
uses: actions/cache@v4 | |
with: | |
path: "**/target/" | |
key: ${{ runner.os }}-cache-java-${{ matrix.java }}-${{ github.sha }} | |
- name: Build with Maven | |
run: mvn -B clean install -s settings.xml | |
env: | |
MVN_USR: dummy | |
MVN_PWD: ${{ secrets.GITHUB_TOKEN }} | |
code-analysis: | |
permissions: | |
packages: read | |
runs-on: ubuntu-latest | |
needs: build | |
name: SonarCloud Code Analysis | |
# It's not possible to launch an analysis on external pull requests | |
# if: ${{ github.repository_owner == 'cnescatlab' }} | |
steps: | |
# the latest version at https://github.com/marketplace/actions/checkout | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# the latest version at https://github.com/actions/cache | |
- name: Restore cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: "**/target/" | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-cache-java-21-${{ github.sha }} | |
# the latest version at https://github.com/marketplace/actions/official-sonarqube-scan | |
# Triggering SonarQube analysis as results of it are required by Quality Gate check. | |
- name: SonarQube Scan | |
uses: SonarSource/sonarqube-scan-action@v6 | |
with: | |
args: > | |
-Dsonar.qualitygate.wait=true | |
-Dsonar.qualitygate.timeout=600 | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
integration-test: | |
permissions: | |
packages: read | |
runs-on: ubuntu-latest | |
needs: build | |
name: TI for SonarQube ${{ matrix.sonarQube }} | |
strategy: | |
matrix: | |
sonarQube: [ '25.1.0.102122-community', 'community'] | |
steps: | |
# the latest version at https://github.com/marketplace/actions/docker-setup-compose | |
- name: Set up Docker Compose | |
uses: docker/setup-compose-action@v1 | |
with: | |
version: latest | |
# the latest version at https://github.com/marketplace/actions/checkout | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# the latest version at https://github.com/actions/cache | |
- name: Restore cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: "**/target/" | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-cache-java-21-${{ github.sha }} | |
- name: Integration test | |
run: | | |
cd it | |
./it.sh -S ${{ matrix.sonarQube }} |