chore: Add badges and update screenshots #2
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: Build CoffeeMaker with Github Actions | |
on: | |
pull_request: | |
branches: | |
- '**' | |
push: | |
branches: | |
- main | |
- master | |
- development | |
jobs: | |
Build-CoffeeMaker: | |
runs-on: self-hosted | |
permissions: write-all | |
steps: | |
- name: Publish reminder | |
uses: actions/[email protected] | |
if: github.event_name == 'pull_request' | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Reminder: Wait until GitHub Actions has finished running the build before merging this PR!' | |
}) | |
- name: Check out repository code | |
uses: actions/[email protected] | |
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | |
- run: echo "🖥️ The workflow is now ready to test your code on the runner." | |
- name: List files in the repository | |
run: | | |
ls -la ${{ github.workspace }} | |
- name: Setup JDK 17 | |
uses: actions/[email protected] | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Copy config files for Spring Boot | |
run: cp CoffeeMaker/src/main/resources/application.yml.template CoffeeMaker/src/main/resources/application.yml | |
- name: Edit config file with DB credentials (do not change this!) | |
run: sed -i 's/password\:/password\:\ root1234/g' CoffeeMaker/src/main/resources/application.yml | |
- name: Check to make sure DB is active | |
run: mysql -uroot -h localhost -P 3306 --protocol=tcp -proot1234 -e 'SELECT version()' | |
- name: Drop old database to get a fresh state | |
run: mysql -uroot -h localhost -P 3306 --protocol=tcp -proot1234 -e 'DROP DATABASE IF EXISTS CoffeeMaker;' | |
- name: Build CoffeeMaker with Maven | |
run: cd CoffeeMaker && mvn --batch-mode --update-snapshots clean test checkstyle:checkstyle | |
- name: Generate coverage badges | |
id: jacoco | |
run: > | |
python3 .github/generate_badge.py "CoffeeMaker/target/site/jacoco-ut/jacoco.csv" | |
".github/badges" "jacoco.svg" "branches.svg" "true" "true" | |
"fail" "70" "50" "false" "false" "100 90 80 70 60 0" "#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44" | |
- name: Log coverage percentage | |
if: always() | |
run: | | |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}" | |
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}" | |
- name: Publish Test Report | |
if: ${{ always() }} | |
uses: kpresler/action-surefire-report@master | |
- name: Add coverage to PR | |
id: publishJacoco | |
uses: Madrapps/[email protected] | |
with: | |
paths: ${{ github.workspace }}/CoffeeMaker/target/site/jacoco-ut/jacoco.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
min-coverage-overall: 70 | |
min-coverage-changed-files: 70 | |
- name: Publish CheckStyle Report | |
if: ${{ always() }} | |
uses: kpresler/checkstyle-github-action@master | |
with: | |
path: '**/checkstyle-result.xml' | |
- name: Commit the code coverage badge (if it changed) | |
if: always() | |
run: | | |
DETATCHED_HEAD_FOUND=$(git status | grep 'HEAD detached' | wc -l) | |
if [[ `git status --porcelain` && $DETATCHED_HEAD_FOUND -eq 0 ]]; then | |
git config --global user.name 'GitHub Actions Service Account' | |
git config --global user.email '[email protected]' | |
git add .github/ | |
git commit -m "Autogenerated JaCoCo coverage badge" | |
git push | |
fi |