Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug, CI] fix issues with forks, force green, and concurrency in codecov report uploading #2225

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading