Skip to content

Maven CI

Maven CI #69

Workflow file for this run

name: Maven CI
on:
schedule:
- cron: '42 0 * * 1'
push:
branches:
- master
pull_request:
branches:
- master
pull_request_target:
types:
- labeled
branches:
- master
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'release' || !startsWith(github.event.release.tag_name, 'javax/') }}
permissions:
checks: write
security-events: write
contents: write
strategy:
matrix:
java:
- 11
- 17
event:
- ${{ github.event_name }}
exclude:
- event: pull_request_target
java: 11
steps:
- uses: actions/checkout@v3
if: ${{ github.event_name != 'pull_request_target' }}
with:
fetch-depth: 0
persist-credentials: ${{ !startsWith(github.event_name, 'pull_request') }}
- uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request_target' }}
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
persist-credentials: false
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
if: ${{ matrix.java == '11' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: github/codeql-action/init@v2
with:
languages: java
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: Setup Git
run: >
git config --global user.email "actions@github.com" &&
git config --global user.name "GitHub Actions"
if: ${{ !startsWith(github.event_name, 'pull_request') }}
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-${{ matrix.java }}-
${{ runner.os }}-m2-
if: ${{ !startsWith(github.event_name, 'pull_request') }}
- name: Build with Maven
run: mvn -B -V -e clean install
- name: Run integration tests agains JEE 10
run: mvn -B -V -e -f integration-tests -Pee10 clean verify
- name: Publish Test Report
if: ${{ (success() || failure()) && matrix.java == '17' && github.event_name == 'pull_request' }}
uses: scacap/action-surefire-report@v1
with:
report_paths: "**/target/*-reports/TEST-*.xml"
- name: Unittest Coverage
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report
- name: Unittest Codecov
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: codecov/codecov-action@v3.1.0
with:
flags: unittests
- name: Integrationstest Coverage
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report-integration@report-integration
- name: Integrationstest Codecov
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: codecov/codecov-action@v3.1.0
with:
flags: integration
- name: Perform CodeQL Analysis
if: ${{ matrix.java == '11' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: github/codeql-action/analyze@v2
- name: Sonar Report
if: ${{ matrix.java == '17' && (!startsWith(github.event_name, 'pull_request') || !github.event.pull_request.head.repo.fork || contains(github.event.pull_request.labels.*.name, 'sonar')) }}
run: >
if [ "$GITHUB_EVENT_NAME" == "pull_request_target" ];
then
export GITHUB_EVENT_NAME=pull_request;
export GITHUB_REF=refs/pull/$GITHUB_PULL_REQUEST/merge;
fi &&
mvn -B -e jacoco:report jacoco:report-integration@report-integration sonar:sonar -Dsonar.organization=jonasrutishauser-github
env:
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_TOKEN: ${{ github.token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
- name: Deploy Site
if: ${{ matrix.java == '11' && github.event_name != 'release' && !startsWith(github.event_name, 'pull_request') }}
run: mvn -B -e site-deploy
env:
GITHUB_TOKEN: ${{ github.token }}
update-pr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'sonar') }}
steps:
- name: Remove Sonar Label
uses: peter-murray/remove-labels-action@v1
with:
labels: sonar