Skip to content

rewrite java CI to add integration test #137

rewrite java CI to add integration test

rewrite java CI to add integration test #137

# 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: dummy
MVN_PWD: ${{ secrets.GITHUB_TOKEN }}
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
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 }}
- name: SonarQube Scan
run: mvn -s settings.xml -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -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 }}