Skip to content

Update azure-pipelines.yml for Azure Pipelines #41

Update azure-pipelines.yml for Azure Pipelines

Update azure-pipelines.yml for Azure Pipelines #41

Workflow file for this run

#This workflow will build a Java project with Maven - to generate coverage in the file jacaco.csv.
# This file is then parsed to generate a coverage percentage.
# readme.MD is then updated with this value to make a coverage badge.
name: coverage
on:
push:
branches: [ "master" ]
# runs tests and generate Jacoco report
#
jobs:
# This workflow contains a single job called "coverage"
coverage:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Set up JDK 1.17
uses: actions/setup-java@v1
with:
java-version: 1.17
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: run tests with Maven
run: |
mvn verify --file pom.xml
- name: Run coverage parse script
run: |
chmod +x scripts/coverage_percentage.sh
percent=`scripts/coverage_percentage.sh`
echo "percent="$percent
echo $percent > .github/coverage/percentage.txt
echo coverage = $percent
cat /home/runner/work/portal-core/portal-core/target/site/jacoco/jacoco.csv > .github/coverage/jacoco.csv
shell: bash
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Commit changes
uses: EndBug/add-and-commit@v8
with:
author_name: ${{ github.actor }}
author_email: ${{ github.event.commits[0].author.email }}
message: Autogenerated JaCoCo coverage badge
add: .github/coverage/percentage.txt .github/coverage/jacoco.csv .github/badges/jacoco.svg