Skip to content

Cleaner code

Cleaner code #682

name: Maven CI build
env:
OWASP_NVD_API_KEY: ${{ secrets.OWASP_NVD_API_KEY }}
# Workaround for: https://github.com/earthly/earthly/issues/4220
EARTHLY_DISABLE_REMOTE_REGISTRY_PROXY: true
on:
push:
paths-ignore:
- '*.md'
- 'images/**'
# These ignores are specific to a cross-build against Gradle
- 'build.gradle'
- 'gradle*'
- '.gradle'
# These ignores are specific to this project
- 'run-with-gradle.sh'
- '.github/workflows/*gradle*'
pull_request:
paths-ignore:
- '*.md'
- 'images/**'
# These ignores are specific to a cross-build against Gradle
- 'build.gradle'
- 'gradle*'
- '.gradle'
# These ignores are specific to this project
- 'run-with-gradle.sh'
- '.github/workflows/*gradle*'
workflow_dispatch:
jobs:
build:
name: Builds and tests
runs-on: ubuntu-latest
# First run in GitHub actions - verify this
# Afterwards, change to a comment
strategy:
matrix:
include:
- java: 21
steps:
- name: Use Earthly
uses: earthly/actions-setup@v1
with:
# The version in CI should match the version you use locally.
# This is a manual step.
version: v0.8
- name: Clone repository
uses: actions/checkout@v4
- name: Restore Maven caches
uses: actions/cache@master
env:
cache-name: maven-cache
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build and test
run: earthly --secret OWASP_NVD_API_KEY +build-with-maven
- name: Execute run script
run: earthly --secret OWASP_NVD_API_KEY +run-with-maven
- name: Generate coverage badge
# if: ${{ github.ref == 'refs/head/master' }}
uses: cicirello/jacoco-badge-generator@v2
with:
badges-directory: images
generate-branches-badge: false
generate-summary: false
- name: Save coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: target/site/jacoco
# Can this colide with the Gradle build when both finish about the same
# time?
- name: Add coverage to repo
# if: ${{ github.ref == 'refs/head/master' }}
run: |
cd images
if [[ ! -z "$(git status --porcelain *.svg)" ]]; then
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add *.svg
git commit -m 'Autogenerated coverage badge'
git push || echo "$0: Another build won for coverage badge" >&2
fi
- name: Add coverage to repo
# if: ${{ github.ref == 'refs/head/master' }}
run: |
cd images
if [[ ! -z "$(git status --porcelain *.svg)" ]]; then
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add *.svg
git commit -m 'Autogenerated coverage badge'
git push || echo "$0: Another build won for coverage badge" >&2
fi