diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 2a6a4bc..2442b6a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -20,50 +20,6 @@ on: jobs: - test: - name: Test - runs-on: ubuntu-latest - - permissions: - contents: write - checks: write - - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Cache Gradle - uses: actions/cache@v5 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Set up GraalVM JDK 21 - uses: actions/setup-java@v5 - with: - distribution: graalvm - java-version: 21 - cache: gradle - - - name: Make gradlew executable - run: chmod +x ./gradlew - - - name: Run Tests with Gradle - run: ./gradlew test --no-daemon --stacktrace - - - name: Report test results - uses: dorny/test-reporter@v2 - if: always() - with: - name: Gradle Tests - path: build/test-results/test/*.xml - reporter: java-junit - fail-on-error: true - build: name: Build runs-on: ubuntu-latest diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..266ebc4 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,52 @@ +name: Coverage Check + +on: + pull_request: + paths-ignore: + - ".gitignore" + - "LICENSE" + - "README.md" + - ".coderabbit.yaml" + - ".github/renovate.json" + branches: [ '**' ] + push: + paths-ignore: + - ".gitignore" + - "LICENSE" + - "README.md" + - ".coderabbit.yaml" + - ".github/renovate.json" + branches: [ 'master' ] + +jobs: + coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Set up GraalVM JDK 21 + uses: actions/setup-java@v5 + with: + distribution: graalvm + java-version: 21 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v5 + + - name: Run unit tests + run: ./gradlew jacocoTestReport --refresh-dependencies --no-daemon + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: build/test-results/test/TEST-*.xml + codecov_yml_path: ./codecov.yml \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 625b297..d7259e4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ plugins { id("xyz.jpenilla.run-paper") version "3.0.2" id("com.gradleup.shadow") version "9.3.1" id("maven-publish") + id("jacoco") } val minecraftVersion: String by project @@ -84,6 +85,23 @@ tasks { } } + check { + dependsOn(jacocoTestReport) + } + + jacocoTestReport { + dependsOn(test) + reports { + xml.required.set(true) + html.required.set(true) + html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml")) + } + } + + jacoco { + toolVersion = "0.8.14" + } + javadoc { isFailOnError = false options.encoding = "UTF-8" diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..7ddfe77 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +github_checks: true + +comment: + layout: "header, diff, flags, components" \ No newline at end of file