Skip to content

Commit

Permalink
[bug, CI] fix issues with forks, force green, and concurrency in code…
Browse files Browse the repository at this point in the history
…cov report uploading (#2225)

* Update codecov.yml

* Create .codecov.yml

* Update .codecov.yml

* Update .codecov.yml

* Update .codecov.yml
  • Loading branch information
icfaust authored Dec 13, 2024
1 parent 4071d10 commit ded94bf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
30 changes: 30 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#===============================================================================
# Copyright contributors to the oneDAL project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================
coverage:
status:
project:
default:
target: 0
# Set targets to zero so that it will always stay green. Also leave
# information on thresholds so that future coverage percentage
# enforcement can be easily implemented by only adjusting the threshold
# and setting target: auto.
# threshold: 50
patch:
default:
target: 0
# Allow for diffs to have no code coverage.
# threshold: 50
23 changes: 14 additions & 9 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ on:

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
upload_coverage:
name: Codecov
Expand All @@ -50,9 +46,18 @@ jobs:
chmod +x codecov
- name: Upload to codecov
run: |
export PR=${{ github.event.workflow_run.pull_requests[0].number }}
export SHA=${{ github.event.workflow_run.head_sha }}
export VARARGS="-n github"
# if a PR, pass proper information to codecov about SHA and PR, otherwise use main branch info
if [ -n "${PR}" ]; then export VARARGS="${VARARGS}-${PR}-${SHA} -P ${PR} -C ${SHA}"; fi
# github's webhooks for workflow_run are unreliable, this guarantees to pull the PR number if a PR
OWNER="${FULL_NAME%/$NAME}"
if [ "${{ github.repository_owner }}" != "${OWNER}" ]; then BRANCH="${OWNER}:${BRANCH}"; fi
if [ $(git branch --show-current) != $BRANCH ]; then PR=$(gh pr view $BRANCH --json number -q .number); fi
echo uploading $BRANCH
SHA=${{ github.event.workflow_run.head_sha }}
VARARGS="-C ${SHA} -n github-${SHA}"
# if a PR, pass proper information to codecov-cli about the PR number
if [ -n "${PR}" ]; then VARARGS="${VARARGS}-${PR} -P ${PR}"; fi
./codecov -v upload-process -Z -t ${{ secrets.CODECOV_TOKEN }} $VARARGS -F github -s ./coverage
env:
GH_TOKEN: ${{ github.token }}
BRANCH: ${{ github.event.workflow_run.head_branch }}
NAME: ${{ github.event.workflow_run.head_repository.name }}
FULL_NAME: ${{ github.event.workflow_run.head_repository.full_name }}

0 comments on commit ded94bf

Please sign in to comment.