Eat your own dog food #4
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: Eat your own dog food | |
on: | |
workflow_run: | |
workflows: ["CD"] | |
types: | |
- completed | |
jobs: | |
grade-test-data: | |
name: Run autograding with test data | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
check-latest: true | |
cache: 'maven' | |
- name: Set up Maven | |
uses: stCarolas/[email protected] | |
with: | |
maven-version: 3.9.5 | |
- name: Run Autograding with test data | |
uses: uhafner/autograding-github-action@main | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
checks-name: "Autograding with Test Data" | |
config: > | |
{ | |
"tests": { | |
"tools": [ | |
{ | |
"id": "test", | |
"name": "Unittests", | |
"pattern": "**/src/test/resources/**/TEST*.xml" | |
} | |
], | |
"name": "JUnit", | |
"passedImpact": 10, | |
"skippedImpact": -1, | |
"failureImpact": -5, | |
"maxScore": 100 | |
}, | |
"analysis": [ | |
{ | |
"name": "Style", | |
"id": "style", | |
"tools": [ | |
{ | |
"id": "checkstyle", | |
"name": "CheckStyle", | |
"pattern": "**/src/test/resources/**/checkstyle*.xml" | |
}, | |
{ | |
"id": "pmd", | |
"name": "PMD", | |
"pattern": "**/src/test/resources/**/pmd*.xml" | |
} | |
], | |
"errorImpact": 1, | |
"highImpact": 2, | |
"normalImpact": 3, | |
"lowImpact": 4, | |
"maxScore": 100 | |
}, | |
{ | |
"name": "Bugs", | |
"id": "bugs", | |
"icon": "bug", | |
"tools": [ | |
{ | |
"id": "spotbugs", | |
"name": "SpotBugs", | |
"pattern": "**/src/test/resources/**/spotbugs*.xml" | |
} | |
], | |
"errorImpact": -11, | |
"highImpact": -12, | |
"normalImpact": -13, | |
"lowImpact": -14, | |
"maxScore": 100 | |
} | |
], | |
"coverage": [ | |
{ | |
"tools": [ | |
{ | |
"id": "jacoco", | |
"name": "Line Coverage", | |
"metric": "line", | |
"pattern": "**/src/test/resources/**/jacoco.xml" | |
}, | |
{ | |
"id": "jacoco", | |
"name": "Branch Coverage", | |
"metric": "branch", | |
"pattern": "**/src/test/resources/**/jacoco.xml" | |
} | |
], | |
"name": "JaCoCo", | |
"maxScore": 100, | |
"coveredPercentageImpact": 1, | |
"missedPercentageImpact": -1 | |
}, | |
{ | |
"tools": [ | |
{ | |
"id": "pit", | |
"name": "Mutation Coverage", | |
"metric": "mutation", | |
"pattern": "**/src/test/resources/**/mutations.xml" | |
} | |
], | |
"name": "PIT", | |
"maxScore": 100, | |
"coveredPercentageImpact": 1, | |
"missedPercentageImpact": -1 | |
} | |
] | |
} | |
grade-github-action: | |
name: Run autograding for the GitHub Autograding Action | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
check-latest: true | |
cache: 'maven' | |
- name: Set up Maven | |
uses: stCarolas/[email protected] | |
with: | |
maven-version: 3.9.5 | |
- name: Build | |
run: mvn -ntp clean verify -Ppit | |
- name: Run Autograding | |
uses: uhafner/autograding-github-action@main | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
checks-name: "Autograding GitHub Action" | |
config: > | |
{ | |
"tests": { | |
"tools": [ | |
{ | |
"id": "test", | |
"name": "Unittests", | |
"pattern": "**/target/*-reports/TEST*.xml" | |
} | |
], | |
"name": "JUnit", | |
"passedImpact": 0, | |
"skippedImpact": -1, | |
"failureImpact": -5, | |
"maxScore": 100 | |
}, | |
"analysis": [ | |
{ | |
"name": "Style", | |
"id": "style", | |
"tools": [ | |
{ | |
"id": "checkstyle", | |
"name": "CheckStyle", | |
"pattern": "**/target/checkstyle-result.xml" | |
}, | |
{ | |
"id": "pmd", | |
"name": "PMD", | |
"pattern": "**/target/pmd.xml" | |
} | |
], | |
"errorImpact": 1, | |
"highImpact": 2, | |
"normalImpact": 3, | |
"lowImpact": 4, | |
"maxScore": 100 | |
}, | |
{ | |
"name": "Bugs", | |
"id": "bugs", | |
"icon": "bug", | |
"tools": [ | |
{ | |
"id": "spotbugs", | |
"name": "SpotBugs", | |
"sourcePath": "src/main/java", | |
"pattern": "**/target/spotbugsXml.xml" | |
} | |
], | |
"errorImpact": -11, | |
"highImpact": -12, | |
"normalImpact": -13, | |
"lowImpact": -14, | |
"maxScore": 100 | |
} | |
], | |
"coverage": [ | |
{ | |
"tools": [ | |
{ | |
"id": "jacoco", | |
"sourcePath": "src/main/java", | |
"name": "Line Coverage", | |
"metric": "line", | |
"pattern": "**/target/site/jacoco/jacoco.xml" | |
}, | |
{ | |
"id": "jacoco", | |
"sourcePath": "src/main/java", | |
"name": "Branch Coverage", | |
"metric": "branch", | |
"pattern": "**/target/site/jacoco/jacoco.xml" | |
} | |
], | |
"name": "JaCoCo", | |
"maxScore": 100, | |
"coveredPercentageImpact": 1, | |
"missedPercentageImpact": -1 | |
}, | |
{ | |
"tools": [ | |
{ | |
"id": "pit", | |
"name": "Mutation Coverage", | |
"metric": "mutation", | |
"sourcePath": "src/main/java", | |
"pattern": "**/target/pit-reports/mutations.xml" | |
} | |
], | |
"name": "PIT", | |
"maxScore": 100, | |
"coveredPercentageImpact": 1, | |
"missedPercentageImpact": -1 | |
} | |
] | |
} | |
- name: Write metrics to GitHub output | |
id: metrics | |
run: | | |
cat metrics.env >> "${GITHUB_OUTPUT}" | |
mkdir -p badges | |
- name: Generate the badge SVG image for the line coverage | |
uses: emibcn/[email protected] | |
with: | |
label: 'Lines' | |
status: ${{ steps.metrics.outputs.line }}% | |
color: 'green' | |
path: badges/line-coverage.svg | |
- name: Generate the badge SVG image for the branch coverage | |
uses: emibcn/[email protected] | |
with: | |
label: 'Branches' | |
status: ${{ steps.metrics.outputs.branch }}% | |
color: 'green' | |
path: badges/branch-coverage.svg | |
- name: Generate the badge SVG image for the mutation coverage | |
uses: emibcn/[email protected] | |
with: | |
label: 'Mutations' | |
status: ${{ steps.metrics.outputs.mutation }}% | |
color: 'green' | |
path: badges/mutation-coverage.svg | |
- name: Generate the badge SVG image for the style warnings | |
uses: emibcn/[email protected] | |
with: | |
label: 'Warnings' | |
status: ${{ steps.metrics.outputs.style }} | |
color: 'orange' | |
path: badges/style-warnings.svg | |
- name: Generate the badge SVG image for the potential bugs | |
uses: emibcn/[email protected] | |
with: | |
label: 'Bugs' | |
status: ${{ steps.metrics.outputs.bugs }} | |
color: 'red' | |
path: badges/bugs.svg | |
- name: Generate progress SVG | |
id: chart | |
uses: robiningelbrecht/[email protected] | |
with: | |
width: 256 | |
height: 256 | |
pass-options-as: string | |
chart-option: '{ "tooltip": { "trigger": "item", "formatter": "null of null" }, "series": [ { "type": "pie", "radius": [ "70%", "100%" ], "avoidLabelOverlap": false, "color": [ "#1ea64b", "#D0D0D0 " ], "hoverAnimation": false, "label": { "show": true, "position": "center", "fontSize": "38", "fontWeight": "bold", "color": "#000", "formatter": "92%" }, "labelLine": { "normal": { "show": false } }, "data": [ { "value": 92, "name": "Filled" }, { "value": 8, "name": "NotFilled" } ] } ] }' | |
- name: Save generated SVG | |
run: | | |
cat <<EOF > badges/progress.svg | |
${{ steps.chart.outputs.svg }} | |
EOF | |
- name: Commit updated badges | |
continue-on-error: true | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add badges/*.svg | |
git commit -m "Update badges with results from latest autograding" || true | |
- name: Push updated badges to GitHub repository | |
uses: ad-m/github-push-action@master | |
if: ${{ success() }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |