From 6c0ee7b7e821d691b07bfdd84708f28a4f98c313 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 09:53:05 -0500 Subject: [PATCH 1/9] fix: override commit and pr values for PR cases --- Makefile | 2 +- action.yml | 25 +++++++++++++++++++++++-- src/version | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a6bf4fd30..990840789 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ deploy: - $(eval VERSION := $(shell cat src/version | grep 'CODECOV_ACTION_VERSION=' | cut -d\" -f2)) + $(eval VERSION := $(shell cat src/version | grep 'CODECOV_ACTION_VERSION=' | cut -d\" -f2)) git tag -d v5 git push origin :v5 git tag v5 diff --git a/action.yml b/action.yml index a2959d073..2edf86903 100644 --- a/action.yml +++ b/action.yml @@ -194,6 +194,27 @@ runs: GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME: ${{ github.event.pull_request.repo.full_name }} GITHUB_REPOSITORY: ${{ github.repository }} + - name: Override commits and pr for pull requests + shell: bash + run: | + if [ -z "$CC_SHA" ]; + then + CC_SHA="$GITHUB_EVENT_PULL_REQUEST_HEAD_SHA" + fi + if [ -z "$CC_PR" ] && [ "${GITHUB_EVENT_NAME}" == "pull_request_target" ]; + then + CC_PR="$GITHUB_EVENT_NUMBER" + fi + + echo "CC_SHA=$CC_SHA" >> $GITHUB_ENV + echo "CC_PR=$CC_PR" >> $GITHUB_ENV + env: + CC_PR: ${{ inputs.override_pr }} + CC_SHA: ${{ inputs.override_commit }} + GITHUB_EVENT_NAME: ${{ github.event_name }} + GITHUB_EVENT_NUMBER: ${{ github.event.number }} + GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + - name: Upload coverage to Codecov run: ${GITHUB_ACTION_PATH}/dist/codecov.sh shell: bash @@ -229,9 +250,9 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} - CC_PR: ${{ inputs.override_pr }} + CC_PR: $CC_PR CC_REPORT_TYPE: ${{ inputs.report_type }} - CC_SHA: ${{ inputs.override_commit }} + CC_SHA: $CC_SHA CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} diff --git a/src/version b/src/version index 824b8f25f..5a7c4cd0f 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -CODECOV_ACTION_VERSION="5.0.1" +CODECOV_ACTION_VERSION="5.0.2" From 96d592f3f0393a44387df2f13de697ab8a8589b6 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:00:43 -0500 Subject: [PATCH 2/9] fix: remove unnecessary env vars --- action.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 2edf86903..8386e21cb 100644 --- a/action.yml +++ b/action.yml @@ -166,20 +166,20 @@ runs: if [ ${{ inputs.use_oidc }} == 'true' ]; then # {"count":1984,"value":"***"} - CODECOV_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | cut -d\' -f6) - echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> $GITHUB_ENV + CC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | cut -d\' -f6) + echo "CC_TOKEN=$CC_TOKEN" >> $GITHUB_ENV else if [ -n ${{ inputs.token }} ]; then - CODECOV_TOKEN=${{ inputs.token }} - echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> $GITHUB_ENV + CC_TOKEN=${{ inputs.token }} + echo "CC_TOKEN=$CC_TOKEN" >> $GITHUB_ENV fi fi - name: Override branch for forks shell: bash run: | - if [ -z "$CC_BRANCH" ] && [ -z "$CODECOV_TOKEN" ] && [ "${GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ]; + if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ "${GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ]; then echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" @@ -221,7 +221,6 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: $CC_BRANCH CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} @@ -250,13 +249,10 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} - CC_PR: $CC_PR CC_REPORT_TYPE: ${{ inputs.report_type }} - CC_SHA: $CC_SHA CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} - CC_TOKEN: $CODECOV_TOKEN CC_VERBOSE: ${{ inputs.verbose }} CC_VERSION: ${{ inputs.version }} CC_YML_PATH: ${{ inputs.codecov_yml_path }} From 3cb523711f4959d81ebc8c40b085ec4f7783077d Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:09:36 -0500 Subject: [PATCH 3/9] fix: add back in with env --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index 8386e21cb..f5296fc13 100644 --- a/action.yml +++ b/action.yml @@ -221,6 +221,7 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} + CC_BRANCH: ${{ env.CC_BRANCH }} CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} @@ -249,10 +250,14 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} + CC_PR: ${{ env.CC_PR }} CC_REPORT_TYPE: ${{ inputs.report_type }} + CC_SHA: ${{ env.CC_SHA }} CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} + CC_TOKEN: ${{ env.CC_TOKEN }} CC_VERBOSE: ${{ inputs.verbose }} CC_VERSION: ${{ inputs.version }} CC_YML_PATH: ${{ inputs.codecov_yml_path }} + TOKENLESS: ${{ env.TOKENLESS }} From c1ef7e1bbf6c8ff197d7d2386efeec6a162685a8 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:12:27 -0500 Subject: [PATCH 4/9] fix: try no env --- action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index f5296fc13..0eada1e15 100644 --- a/action.yml +++ b/action.yml @@ -221,7 +221,7 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: ${{ env.CC_BRANCH }} + CC_BRANCH: $CC_BRANCH CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} @@ -250,14 +250,14 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} - CC_PR: ${{ env.CC_PR }} + CC_PR: $CC_PR CC_REPORT_TYPE: ${{ inputs.report_type }} - CC_SHA: ${{ env.CC_SHA }} + CC_SHA: $CC_SHA CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} - CC_TOKEN: ${{ env.CC_TOKEN }} + CC_TOKEN: $CC_TOKEN CC_VERBOSE: ${{ inputs.verbose }} CC_VERSION: ${{ inputs.version }} CC_YML_PATH: ${{ inputs.codecov_yml_path }} - TOKENLESS: ${{ env.TOKENLESS }} + TOKENLESS: $TOKENLESS From 74b9e8f40d9b7d75afb4add66495f2e160017065 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:14:48 -0500 Subject: [PATCH 5/9] fix: do we need them at all? --- action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 0eada1e15..45db0f836 100644 --- a/action.yml +++ b/action.yml @@ -221,7 +221,7 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: $CC_BRANCH + # CC_BRANCH: $CC_BRANCH CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} @@ -250,14 +250,14 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} - CC_PR: $CC_PR + # CC_PR: $CC_PR CC_REPORT_TYPE: ${{ inputs.report_type }} - CC_SHA: $CC_SHA + # CC_SHA: $CC_SHA CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} - CC_TOKEN: $CC_TOKEN + # CC_TOKEN: $CC_TOKEN CC_VERBOSE: ${{ inputs.verbose }} CC_VERSION: ${{ inputs.version }} CC_YML_PATH: ${{ inputs.codecov_yml_path }} - TOKENLESS: $TOKENLESS + # TOKENLESS: $TOKENLESS From ef6f136962924ee862a41fd836f8420784df723e Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:17:04 -0500 Subject: [PATCH 6/9] fix: dollar curlies --- action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 45db0f836..0ea92ac05 100644 --- a/action.yml +++ b/action.yml @@ -221,7 +221,7 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - # CC_BRANCH: $CC_BRANCH + CC_BRANCH: ${CC_BRANCH} CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} @@ -250,14 +250,14 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} - # CC_PR: $CC_PR + CC_PR: ${CC_PR} CC_REPORT_TYPE: ${{ inputs.report_type }} - # CC_SHA: $CC_SHA + CC_SHA: ${CC_SHA} CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} - # CC_TOKEN: $CC_TOKEN + CC_TOKEN: ${CC_TOKEN} CC_VERBOSE: ${{ inputs.verbose }} CC_VERSION: ${{ inputs.version }} CC_YML_PATH: ${{ inputs.codecov_yml_path }} - # TOKENLESS: $TOKENLESS + TOKENLESS: ${TOKENLESS} From 273e415f7826a96089045431e9ee7cc1d2c1c957 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:19:51 -0500 Subject: [PATCH 7/9] fix: wrap github_env --- action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 0ea92ac05..cfa3efd6f 100644 --- a/action.yml +++ b/action.yml @@ -167,12 +167,12 @@ runs: then # {"count":1984,"value":"***"} CC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | cut -d\' -f6) - echo "CC_TOKEN=$CC_TOKEN" >> $GITHUB_ENV + echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV" else if [ -n ${{ inputs.token }} ]; then CC_TOKEN=${{ inputs.token }} - echo "CC_TOKEN=$CC_TOKEN" >> $GITHUB_ENV + echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV" fi fi @@ -184,10 +184,10 @@ runs: echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used" TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" CC_BRANCH="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL" - echo "TOKENLESS=$TOKENLESS" >> $GITHUB_ENV + echo "TOKENLESS=$TOKENLESS" >> "$GITHUB_ENV" fi - echo "CC_BRANCH=$CC_BRANCH" >> $GITHUB_ENV + echo "CC_BRANCH=$CC_BRANCH" >> "$GITHUB_ENV" env: CC_BRANCH: ${{ inputs.override_branch }} GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }} @@ -206,8 +206,8 @@ runs: CC_PR="$GITHUB_EVENT_NUMBER" fi - echo "CC_SHA=$CC_SHA" >> $GITHUB_ENV - echo "CC_PR=$CC_PR" >> $GITHUB_ENV + echo "CC_SHA=$CC_SHA" >> "$GITHUB_ENV" + echo "CC_PR=$CC_PR" >> "$GITHUB_ENV" env: CC_PR: ${{ inputs.override_pr }} CC_SHA: ${{ inputs.override_commit }} From 433757a346bed2adb818f217b80403b3e8cd8aa6 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:21:04 -0500 Subject: [PATCH 8/9] fix: remove dollar curlies --- action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index cfa3efd6f..a7a31e533 100644 --- a/action.yml +++ b/action.yml @@ -221,7 +221,7 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: ${CC_BRANCH} + CC_BRANCH: $CC_BRANCH CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} @@ -250,14 +250,14 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} - CC_PR: ${CC_PR} + CC_PR: $CC_PR CC_REPORT_TYPE: ${{ inputs.report_type }} - CC_SHA: ${CC_SHA} + CC_SHA: $CC_SHA CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} - CC_TOKEN: ${CC_TOKEN} + CC_TOKEN: $CC_TOKEN CC_VERBOSE: ${{ inputs.verbose }} CC_VERSION: ${{ inputs.version }} CC_YML_PATH: ${{ inputs.codecov_yml_path }} - TOKENLESS: ${TOKENLESS} + TOKENLESS: $TOKENLESS From 652054ed287510b9da675d0d4bd19c4a15f6e699 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 15 Nov 2024 10:23:06 -0500 Subject: [PATCH 9/9] fix: remove --- action.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/action.yml b/action.yml index a7a31e533..36e11f2fa 100644 --- a/action.yml +++ b/action.yml @@ -221,7 +221,6 @@ runs: working-directory: ${{ inputs.working-directory }} env: CC_BINARY: ${{ inputs.binary }} - CC_BRANCH: $CC_BRANCH CC_BUILD: ${{ inputs.override_build }} CC_BUILD_URL: ${{ inputs.override_build_url }} CC_CODE: ${{ inputs.report_code }} @@ -250,14 +249,10 @@ runs: CC_OS: ${{ inputs.os }} CC_PARENT_SHA: ${{ inputs.commit_parent }} CC_PLUGINS: ${{ inputs.plugins }} - CC_PR: $CC_PR CC_REPORT_TYPE: ${{ inputs.report_type }} - CC_SHA: $CC_SHA CC_SKIP_VALIDATION: ${{ inputs.skip_validation }} CC_SLUG: ${{ inputs.slug }} CC_SWIFT_PROJECT: ${{ inputs.swift_project }} - CC_TOKEN: $CC_TOKEN CC_VERBOSE: ${{ inputs.verbose }} CC_VERSION: ${{ inputs.version }} CC_YML_PATH: ${{ inputs.codecov_yml_path }} - TOKENLESS: $TOKENLESS