WIP Fix codacy workflow #106
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 | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for better analysis relevancy | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
cache: 'gradle' | |
- name: Validate Gradle Wrapper | |
run: ./gradlew --version | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Cache Gradle dependencies | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.GRADLE_HOME }}/caches | |
key: | | |
gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} | |
-${{ hashFiles('**/*.gradle*') }} | |
-${{ hashFiles('**/buildSrc/**') }} | |
-${{ github.sha }} | |
restore-keys: | | |
gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} | |
-${{ hashFiles('**/*.gradle*') }} | |
-${{ hashFiles('**/buildSrc/**') }} | |
- name: Run checks and test | |
run: ./gradlew detekt ktlintCheck diktatCheck jacocoTestReport --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME" | |
- name: Run jacocoTestReport | |
run: ./gradlew jacocoTestReport | |
- name: Build with Gradle and test | |
run: ./gradlew build -x koverVerify # Skipping koverVerify to avoid failure if coverage has lowered | |
- name: Run Codacy Analysis CLI | |
uses: codacy/codacy-analysis-cli-action@master | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
upload: true | |
max-allowed-issues: 100 | |
- name: Generate Test Coverage Xml Report | |
run: ./gradlew koverXmlReport | |
- name: Coveralls Parallel | |
uses: coverallsapp/github-action@v2 | |
with: | |
parallel: true | |
flag-name: run-${{ join(matrix.*, '-') }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./build/reports/jacoco/test/jacocoTestReport.xml | |
debug: false | |
measure: true | |
format: jacoco | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
directory: ./build/reports/kover/ | |
files: ./build/reports/kover/report.xml | |
verbose: true | |
- name: Upload test coverage to Code Climate | |
uses: paambaati/[email protected] | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
JACOCO_SOURCE_PATH: "${{github.workspace}}/src/main/kotlin" | |
with: | |
coverageCommand: ./gradlew test jacocoTestReport | |
coverageLocations: ./build/reports/jacoco/test/jacocoTestReport.xml:jacoco | |
debug: true | |
- name: Run codacy-coverage-reporter | |
uses: codacy/[email protected] | |
run: du -k ./build/reports/jacoco/test/jacocoTestReport.xml | cut -f1 | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: ./build/reports/jacoco/test/jacocoTestReport.xml |