niklas2810/my-discord-butler

View on GitHub
.github/workflows/coverage-and-pages.yml

Summary

Maintainability
Test Coverage
# https://github.com/paambaati/codeclimate-action#example-with-jacoco
name: Publish Code Coverage

on:
  push:
    branches:
      - main
    paths:
      - 'src/**'
      - '**.xml'
      - '**.yml'

jobs:
  generate-coverage:
    runs-on: ubuntu-latest

    steps:
      - name: ⏬ Checkout code
        uses: actions/checkout@v2
      - name: ⚙️ Set up JDK 14
        uses: actions/setup-java@v1
        with:
          java-version: 14
      - name: 💽 Restore Maven cache
        uses: actions/cache@v2
        with:
          path: ~/.m2/repository
          key: maven-coverage-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            maven-coverage-${{ runner.os }}-
      - name: 🤖 Generate code coverage
        uses: paambaati/codeclimate-action@v2.6.0
        env:
          # Set CC_TEST_REPORTER_ID as secret of your repo
          CC_TEST_REPORTER_ID: ${{secrets.CODECLIMATE_REPORTER}}
          JACOCO_SOURCE_PATH: "src/main/java"
        with:
          # The report file must be there, otherwise Code Climate won't find it
          coverageCommand: mvn test
          coverageLocations: target/site/jacoco/jacoco.xml:jacoco
      - name: 🗑️ Clean + Move files
        run: |
          sudo apt-get install tidy -y
          find target/site/jacoco -type f -name '*.html' -exec tidy -config tidy-config.txt -o "{}" "{}" \;
          rm target/site/jacoco/jacoco.csv
          rm target/site/jacoco/jacoco.xml
          cp -r target/site/jacoco pages/coverage
      - name: 🚀 Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@3.5.9
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages
          FOLDER: pages