diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..6e33e624 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,35 @@ +name: 'Generate Codecov coverage report' + +on: + push: + branches: + - master + - main + pull_request: + +jobs: + coverage: + + runs-on: ubuntu-latest + name: Create coverage report and upload results to Codecov on Ubuntu + + 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/setup-maven@v4.5 + with: + maven-version: 3.9.5 + - name: Build with Maven + run: mvn -V --color always -ntp clean verify + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: 'target/site/jacoco/jacoco.xml' + token: ${{secrets.CODECOV_TOKEN}} diff --git a/.github/workflows/quality-monitor.yml b/.github/workflows/quality-monitor.yml new file mode 100644 index 00000000..c395c81d --- /dev/null +++ b/.github/workflows/quality-monitor.yml @@ -0,0 +1,36 @@ +name: 'Quality Monitor PR' + +on: + pull_request: + +jobs: + build: + + runs-on: [ubuntu-latest] + name: Build, test and monitor quality on Ubuntu + + 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/setup-maven@v4.5 + with: + maven-version: 3.9.5 + - name: Build with Maven + env: + BROWSER: chrome-container + run: mvn -V --color always -ntp clean verify -Ppit | tee maven.log + - name: Extract pull request number + uses: jwalton/gh-find-current-pr@v1 + id: pr + - name: Run Quality Monitor + uses: uhafner/quality-monitor@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + pr-number: ${{ steps.pr.outputs.number }} diff --git a/.github/workflows/reporting.yml b/.github/workflows/reporting.yml deleted file mode 100644 index f05a5218..00000000 --- a/.github/workflows/reporting.yml +++ /dev/null @@ -1,156 +0,0 @@ -name: 'Generate reports' - -on: - push: - branches: - - main - -jobs: - coverage: - - runs-on: [ubuntu-latest] - name: Reporting on Ubuntu - - 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/setup-maven@v4.5 - with: - maven-version: 3.9.5 - - name: Build and test with Maven - run: mvn -V --color always -ntp clean verify --file pom.xml '-Dgpg.skip' '-Ppit' | tee maven.log - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.1.4 - with: - token: ${{secrets.CODECOV_TOKEN}} - - name: Run Autograding - uses: uhafner/autograding-github-action@v3 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - checks-name: 'Quality Checks' - config: > - { - "tests": { - "tools": [ - { - "id": "test", - "name": "Unittests", - "pattern": "**/target/*-reports/TEST*.xml" - } - ], - "name": "Tests" - }, - "analysis": { - "name": "Warnings", - "id": "warnings", - "tools": [ - { - "id": "checkstyle", - "name": "CheckStyle", - "pattern": "**/target/checkstyle-result.xml" - }, - { - "id": "pmd", - "name": "PMD", - "pattern": "**/target/pmd.xml" - }, - { - "id": "error-prone", - "name": "Error Prone", - "pattern": "**/maven.log" - }, - { - "id": "spotbugs", - "name": "SpotBugs", - "sourcePath": "src/main/java", - "pattern": "**/target/spotbugsXml.xml" - } - ] - }, - "coverage": [ - { - "tools": [ - { - "id": "jacoco", - "name": "Line Coverage", - "metric": "line", - "sourcePath": "src/main/java", - "pattern": "**/target/site/jacoco/jacoco.xml" - }, - { - "id": "jacoco", - "name": "Branch Coverage", - "metric": "branch", - "sourcePath": "src/main/java", - "pattern": "**/target/site/jacoco/jacoco.xml" - } - ], - "name": "Code Coverage" - }, - { - "tools": [ - { - "id": "pit", - "name": "Mutation Coverage", - "metric": "mutation", - "sourcePath": "src/main/java", - "pattern": "**/target/pit-reports/mutations.xml" - } - ], - "name": "Mutation Coverage" - } - ] - } - - 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/badge-action@v2.0.2 - 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/badge-action@v2.0.2 - 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/badge-action@v2.0.2 - with: - label: 'Mutations' - status: ${{ steps.metrics.outputs.mutation }}% - color: 'green' - path: badges/mutation-coverage.svg - - name: Generate the badge SVG image for the warnings - uses: emibcn/badge-action@v2.0.2 - with: - label: 'Warnings' - status: ${{ steps.metrics.outputs.warnings }} - color: 'orange' - path: badges/warnings.svg - - name: Commit updated badges - continue-on-error: true - run: | - git config --local user.email "action@github.com" - 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 diff --git a/.github/workflows/update-badges.yml b/.github/workflows/update-badges.yml new file mode 100644 index 00000000..8b6956e4 --- /dev/null +++ b/.github/workflows/update-badges.yml @@ -0,0 +1,78 @@ +name: 'Update project badges' + +on: + push: + branches: + - main + +jobs: + coverage: + + runs-on: [ubuntu-latest] + name: Update project quality badges on Ubuntu + + 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/setup-maven@v4.5 + with: + maven-version: 3.9.5 + - name: Build and test with Maven + run: mvn -V --color always -ntp clean verify --file pom.xml '-Dgpg.skip' '-Ppit' | tee maven.log + - name: Run Quality Monitor + uses: uhafner/quality-monitor@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + - 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/badge-action@v2.0.2 + 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/badge-action@v2.0.2 + 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/badge-action@v2.0.2 + with: + label: 'Mutations' + status: ${{ steps.metrics.outputs.mutation }}% + color: 'green' + path: badges/mutation-coverage.svg + - name: Generate the badge SVG image for the warnings + uses: emibcn/badge-action@v2.0.2 + with: + label: 'Warnings' + status: ${{ steps.metrics.outputs.warnings }} + color: 'orange' + path: badges/warnings.svg + - name: Commit updated badges + continue-on-error: true + run: | + git config --local user.email "action@github.com" + 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