Skip to content

Extract coverage information for SonarQube (hopefully) #56

Extract coverage information for SonarQube (hopefully)

Extract coverage information for SonarQube (hopefully) #56

Workflow file for this run

# This workflow builds PLM with Maven and runs its test suite.
# See https://docs.github.com/actions/automating-builds-and-tests/building-and-testing-java-with-maven
name: Java CI
on:
push:
branches: [ javaUI ]
pull_request:
branches: [ javaUI ]
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install gettext (needed by the i18n message-bundle generation)
run: sudo apt-get update && sudo apt-get install -y gettext
# Scala 2.12's compiler bridge does not run on JDK 22+, and maven.compiler.release is 17.
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'zulu'
cache: maven
- name: Download dependencies
run: mvn -B dependency:go-offline
- name: Build the self-contained jar with Maven
run: mvn -B -DskipTests package
- name: Upload jar
uses: actions/upload-artifact@v6
with:
path: target/*.jar
sonarcloud:
name: SonarQube analysis
runs-on: ubuntu-latest
steps:
- name: Install gettext (needed by the i18n message-bundle generation)
run: sudo apt-get update && sudo apt-get install -y gettext xvfb jython
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarQube packages
uses: actions/cache@v4.3.0
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4.3.0
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Download dependencies
run: mvn -B dependency:go-offline
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: xvfb-run -a mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BuggleInc_PLM
test:
name: test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: maven
# The i18n message-bundle generation needs gettext (msgfmt) on PATH.
- name: Install gettext + xvfb (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt install -y gettext xvfb jython
- name: Install gettext (macOS)
if: runner.os == 'macOS'
run: |
brew install gettext jython
echo "$(brew --prefix gettext)/bin" >> "$GITHUB_PATH"
- name: Install gettext (Windows)
if: runner.os == 'Windows'
run: choco install gettext --yes --no-progress
- name: Download dependencies
run: mvn -B dependency:go-offline
# Linux runners are headless -> run the Swing tests under a virtual display.
# Windows and macOS runners have a real display, so run them directly.
- name: Run tests (Linux, under xvfb)
if: runner.os == 'Linux'
run: xvfb-run -a mvn -B test
- name: Run tests (Windows / macOS)
if: runner.os != 'Linux'
run: mvn -B test
- name: Publish Test Report
uses: dorny/test-reporter@v3
if: always() # Build the report even if tests fail
with:
name: JUnit 5 Tests Summary
path: "**/surefire-reports/TEST-*.xml"
reporter: java-junit