From 1e661501eae75aa345749384398943d429d885d1 Mon Sep 17 00:00:00 2001 From: Javier Roman Date: Mon, 9 Dec 2024 18:10:12 +0100 Subject: [PATCH] Add github workflow to build and check the code coverage --- .github/workflows/main.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..d990715e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,35 @@ +name: Eventeum CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'openjdk' + cache: maven + + - name: Build with Maven + run: mvn clean package + + - name: Run tests + run: mvn verify + + - name: Check Coverage + run: | + COVERAGE=$(cat coverage/target/site/jacoco-aggregate/index.html | grep -o 'Total.*[0-9]\{1,3\}%' | grep -o '[0-9]\{1,3\}%' | head -1 | sed 's/%//') + if [ "$COVERAGE" -lt 25 ]; then + echo "Coverage below 25%: $COVERAGE%" + exit 1 + fi