chore(build): Define property 'surefire.argLine' (#176) (#178) #10
This file contains 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
# This workflow builds Operaton, and cache/restore any dependencies to improve the workflow execution time | |
name: build | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
checks: write | |
id-token: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ubuntu-latest] # If needed multi-OS add macos-13, windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Prevent Shallow Clone to satisfy Sonarqube | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Maven Build | |
shell: bash | |
run: | | |
echo "Creating a flag file 'executeJacoco' for each module containing tests. \ | |
This triggers activation of the 'coverage' profile." | |
find . -type d | while read -r dir; do | |
if [[ -d "$dir/src/test/java" || -d "$dir/target/generated-test-sources/java" ]]; then | |
# Create an empty file target/executeJacoco if the condition is met | |
mkdir -p "$dir/target" | |
touch "$dir/target/executeJacoco" | |
fi | |
done | |
./mvnw package | |
./mvnw --non-recursive org.jacoco:jacoco-maven-plugin:report-aggregate | |
- name: Publish Test Report | |
if: always() | |
uses: mikepenz/action-junit-report@v4 #https://github.com/marketplace/actions/junit-report-action | |
with: | |
report_paths: ${{ github.workspace }}/**/target/surefire-reports/*.xml | |
require_passed_tests: true | |
- name: Upload Surefire Reports | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: surefire-reports | |
path: ${{ github.workspace }}/**/target/surefire-reports/** | |
retention-days: 30 | |
- name: Sonarqube Analysis | |
if: env.SONAR_TOKEN && (github.ref == 'refs/heads/main' || github.event_name == 'pull_request') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: bash | |
run: ./mvnw org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=operaton_operaton | |
continue-on-error: true |