Skip to content

Commit ded94bf

Browse files
authored
[bug, CI] fix issues with forks, force green, and concurrency in codecov report uploading (#2225)
* Update codecov.yml * Create .codecov.yml * Update .codecov.yml * Update .codecov.yml * Update .codecov.yml
1 parent 4071d10 commit ded94bf

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

.github/.codecov.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#===============================================================================
2+
# Copyright contributors to the oneDAL project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#===============================================================================
16+
coverage:
17+
status:
18+
project:
19+
default:
20+
target: 0
21+
# Set targets to zero so that it will always stay green. Also leave
22+
# information on thresholds so that future coverage percentage
23+
# enforcement can be easily implemented by only adjusting the threshold
24+
# and setting target: auto.
25+
# threshold: 50
26+
patch:
27+
default:
28+
target: 0
29+
# Allow for diffs to have no code coverage.
30+
# threshold: 50

.github/workflows/codecov.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ on:
2323

2424
permissions: read-all
2525

26-
concurrency:
27-
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }}
28-
cancel-in-progress: true
29-
3026
jobs:
3127
upload_coverage:
3228
name: Codecov
@@ -50,9 +46,18 @@ jobs:
5046
chmod +x codecov
5147
- name: Upload to codecov
5248
run: |
53-
export PR=${{ github.event.workflow_run.pull_requests[0].number }}
54-
export SHA=${{ github.event.workflow_run.head_sha }}
55-
export VARARGS="-n github"
56-
# if a PR, pass proper information to codecov about SHA and PR, otherwise use main branch info
57-
if [ -n "${PR}" ]; then export VARARGS="${VARARGS}-${PR}-${SHA} -P ${PR} -C ${SHA}"; fi
49+
# github's webhooks for workflow_run are unreliable, this guarantees to pull the PR number if a PR
50+
OWNER="${FULL_NAME%/$NAME}"
51+
if [ "${{ github.repository_owner }}" != "${OWNER}" ]; then BRANCH="${OWNER}:${BRANCH}"; fi
52+
if [ $(git branch --show-current) != $BRANCH ]; then PR=$(gh pr view $BRANCH --json number -q .number); fi
53+
echo uploading $BRANCH
54+
SHA=${{ github.event.workflow_run.head_sha }}
55+
VARARGS="-C ${SHA} -n github-${SHA}"
56+
# if a PR, pass proper information to codecov-cli about the PR number
57+
if [ -n "${PR}" ]; then VARARGS="${VARARGS}-${PR} -P ${PR}"; fi
5858
./codecov -v upload-process -Z -t ${{ secrets.CODECOV_TOKEN }} $VARARGS -F github -s ./coverage
59+
env:
60+
GH_TOKEN: ${{ github.token }}
61+
BRANCH: ${{ github.event.workflow_run.head_branch }}
62+
NAME: ${{ github.event.workflow_run.head_repository.name }}
63+
FULL_NAME: ${{ github.event.workflow_run.head_repository.full_name }}

0 commit comments

Comments
 (0)