From efa334c1029a54412acb99c7accac2e6a5e7e709 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 19 Nov 2024 16:49:15 -0500 Subject: [PATCH] Update codecov to check during PR (#995) * Update codecov to check during PR Signed-off-by: Peter Zhu --- .github/workflows/CI.yml | 80 +++++++++++++++++++++++++--------------- codecov.yml | 13 ++----- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 48fedeecf..f1b997db7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -6,12 +6,11 @@ on: branches: - "*" - "feature/**" - pull_request: + pull_request_target: + types: [opened, synchronize, reopened] branches: - "*" - "feature/**" -env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: Get-CI-Image-Tag: @@ -33,16 +32,24 @@ jobs: # this image tag is subject to change as more dependencies and updates will arrive over time image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} # need to switch to root so that github actions can install runner binary on container without permission issues. - options: --user root - + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: - - name: Checkout neural-search - uses: actions/checkout@v1 + - name: Run start commands + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} + + - uses: actions/checkout@v4 + if: github.event_name == 'push' || github.event_name == 'schedule' + + - uses: actions/checkout@v4 + if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Setup Java ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'temurin' java-version: ${{ matrix.java }} - name: Run build @@ -51,7 +58,8 @@ jobs: su `id -un 1000` -c "./gradlew check" - name: Upload Coverage Report - uses: codecov/codecov-action@v3 + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -65,23 +73,24 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Checkout neural-search - uses: actions/checkout@v1 + - uses: actions/checkout@v4 + if: github.event_name == 'push' || github.event_name == 'schedule' + + - uses: actions/checkout@v4 + if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Setup Java ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'temurin' java-version: ${{ matrix.java }} - name: Run build run: | ./gradlew check - - name: Upload Coverage Report - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - Precommit-neural-search-linux: needs: Get-CI-Image-Tag strategy: @@ -96,15 +105,24 @@ jobs: # this image tag is subject to change as more dependencies and updates will arrive over time image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} # need to switch to root so that github actions can install runner binary on container without permission issues. - options: --user root + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: - - name: Checkout neural-search - uses: actions/checkout@v1 + - name: Run start commands + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} + + - uses: actions/checkout@v4 + if: github.event_name == 'push' || github.event_name == 'schedule' + + - uses: actions/checkout@v4 + if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Setup Java ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'temurin' java-version: ${{ matrix.java }} - name: Run build @@ -113,7 +131,8 @@ jobs: su `id -un 1000` -c "./gradlew precommit --parallel" - name: Upload Coverage Report - uses: codecov/codecov-action@v1 + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -127,19 +146,20 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Checkout neural-search - uses: actions/checkout@v1 + - uses: actions/checkout@v4 + if: github.event_name == 'push' || github.event_name == 'schedule' + + - uses: actions/checkout@v4 + if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Setup Java ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'temurin' java-version: ${{ matrix.java }} - name: Run build run: | ./gradlew precommit --parallel - - - name: Upload Coverage Report - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/codecov.yml b/codecov.yml index 47c109f3d..a71e6bdd6 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,15 +1,10 @@ +--- coverage: - # displays different colors depending on below, between, or above the range - range: 50..90 + precision: 2 + round: down + range: '70...90' status: project: - enabled: yes default: target: auto - # allows 5% coverage reduction without failing threshold: 5% - patch: yes - changes: yes - -# disable comments in PRs -comment: yes