diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..c9ab2c665 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,48 @@ +name: Java Test Coverage + +on: + workflow_dispatch: + inputs: + pr_number: + description: 'PR number from upstream repo' + required: true + type: string + upstream_repo: + description: 'Upstream repo (owner/name)' + required: true + default: 'owner/repo-name' # Change this to your upstream + +jobs: + test-coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout fork + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Fetch and checkout upstream PR + run: | + git remote add upstream https://github.com/${{ inputs.upstream_repo }}.git + git fetch upstream pull/${{ inputs.pr_number }}/head:pr-${{ inputs.pr_number }} + git checkout pr-${{ inputs.pr_number }} + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + + - name: Run tests with coverage + run: mvn clean test jacoco:report + + - name: Upload coverage reports + uses: actions/upload-artifact@v4 + with: + name: coverage-pr-${{ inputs.pr_number }} + path: | + target/site/jacoco/ + target/coverage/ + retention-days: 30 diff --git a/pom.xml b/pom.xml index a3885fdcf..25932f928 100644 --- a/pom.xml +++ b/pom.xml @@ -169,6 +169,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.11 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + com.github.ekryd.sortpom sortpom-maven-plugin