Adds CI #2
Workflow file for this run
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
name: Lint and Test | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
lint_and_test: | ||
name: Lint and Test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 21 | ||
distribution: adopt | ||
architecture: x64 | ||
- name: Lint | ||
run: mvn spotless:check -f spotless.xml | ||
- name: Test | ||
run: mvn test jacoco:report | ||
- name: Jacoco Report to PR | ||
id: jacoco | ||
uses: madrapps/jacoco-report@v1.7.0 | ||
with: | ||
paths: target/site/jacoco/jacoco.xml | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
min-coverage-overall: 80 | ||
min-coverage-changed-files: 80 | ||
title: Code Coverage | ||
update-comment: true | ||
- name: Generate JaCoCo Badge | ||
id: jacoco | ||
Check failure on line 38 in .github/workflows/lint_and_test.yaml
|
||
uses: cicirello/jacoco-badge-generator@v2 | ||
if: github.ref == 'refs/heads/main' | ||
- name: Log coverage percentage | ||
run: | | ||
echo "coverage = ${{ steps.jacoco.outputs.coverage }}" | ||
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}" | ||
if: github.ref == 'refs/heads/main' | ||
- name: Commit the badge (if it changed) | ||
run: | | ||
if [[ `git status --porcelain` ]]; then | ||
git config --global user.name 'Github Action' | ||
git config --global user.email 'githubaction@githubaction.githubaction' | ||
git add -A | ||
git commit -m "Autogenerated JaCoCo coverage badge" | ||
git push | ||
fi | ||
if: github.ref == 'refs/heads/main' | ||
- name: Upload JaCoCo coverage report | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: jacoco-report | ||
path: reports/jacoco/ | ||
if: github.ref == 'refs/heads/main' |