Skip to content

Feature/improve ci #113

Feature/improve ci

Feature/improve ci #113

# 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 11 and a SonarCloud analysis.
---
name: Java CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11', '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
quality:
runs-on: ubuntu-latest
needs: build
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@v4
with:
args: >
-Dsonar.qualitygate.wait=true
-Dsonar.qualitygate.timeout=600
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}