From 0d9ef272a630221a20d06c3cb82b2d0d4958d84e Mon Sep 17 00:00:00 2001 From: vil02 Date: Sat, 6 Apr 2024 17:38:37 +0200 Subject: [PATCH 1/3] chore: update `codecov/codecov-action` to `v4` --- .github/workflows/build.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b617a86dca2..b8a8e59447b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,8 +16,18 @@ jobs: distribution: 'adopt' - name: Build with Maven run: mvn --batch-mode --update-snapshots verify - - name: Upload coverage to codecov - uses: codecov/codecov-action@v3 + - name: Upload coverage to codecov (tokenless) + if: >- + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository + uses: codecov/codecov-action@v4 with: - files: "${{ env.REPORT_NAME }}" + files: "${{ env.COVERAGE_REPORT_PATH }}" + fail_ci_if_error: true + - name: Upload coverage to codecov (with token) + if: "! github.event.pull_request.head.repo.fork " + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: "${{ env.COVERAGE_REPORT_PATH }}" fail_ci_if_error: true From 25453f8e2f45b3c360ab7f01f1707223c4272f60 Mon Sep 17 00:00:00 2001 From: vil02 Date: Sat, 6 Apr 2024 18:12:53 +0200 Subject: [PATCH 2/3] fix: upload with token only for main repository --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8a8e59447b5..8e307473d27d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,10 @@ jobs: files: "${{ env.COVERAGE_REPORT_PATH }}" fail_ci_if_error: true - name: Upload coverage to codecov (with token) - if: "! github.event.pull_request.head.repo.fork " + if: > + github.repository == 'TheAlgorithms/Java' && + (github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name == github.repository) uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} From ee1ad00604233141021ef26c4b2cb03422b15029 Mon Sep 17 00:00:00 2001 From: vil02 Date: Sat, 6 Apr 2024 20:13:02 +0200 Subject: [PATCH 3/3] style: `COVERAGE_REPORT_PATH` is not needed --- .github/workflows/build.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e307473d27d..19f84e023a5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,6 @@ name: Build on: [push, pull_request] -env: - COVERAGE_REPORT_PATH: "target/site/jacoco/jacoco.xml" - jobs: build: runs-on: ubuntu-latest @@ -22,7 +19,6 @@ jobs: github.event.pull_request.head.repo.full_name != github.repository uses: codecov/codecov-action@v4 with: - files: "${{ env.COVERAGE_REPORT_PATH }}" fail_ci_if_error: true - name: Upload coverage to codecov (with token) if: > @@ -32,5 +28,4 @@ jobs: uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - files: "${{ env.COVERAGE_REPORT_PATH }}" fail_ci_if_error: true