Repository navigation
feat(codecov-upload): add checksum-verified Codecov CLI upload action - #21
Open
MichaelGHSeg wants to merge 2 commits into
Open
MichaelGHSeg wants to merge 2 commits into
MichaelGHSeg wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
codecov/codecov-actioncannot run on our public SDK repos. Their Actions policy is:{ "enabled": true, "allowed_actions": "selected", "sha_pinning_required": true } { "github_owned_allowed": true, "patterns_allowed": [], "verified_allowed": false }Only GitHub-owned
actions/*are permitted, so referencingcodecov/codecov-actionfails the entire workflow with
startup_failurebefore any step executes — SHA-pinningdoes not help. I confirmed this policy is identical on
segmentio/fql-ts,analytics-php,analytics-nextandanalytics-java, so it is org-wide rather thanper-repo.
Actions inside this enterprise are exempt from that allowlist — which is exactly why
twilio/sdk-actions/artifactory-oidcworks today. So acodecov-uploadaction here isconsumable by every SDK repo, while the upstream Codecov action is not.
The gap this closes: repos are currently working around it by dropping Codecov
entirely.
segmentio/analytics-php's hardenedci.ymlkeeps coverage as a buildartifact with the comment "codecov/codecov-action is not allow-listed either, so
coverage is kept". That leaves any non-informational gate in
codecov.ymlpermanentlywithout data. Two other repos (
analytics-java,analytics_flutter) still shell out tocurl -s https://codecov.io/bash, the deprecated v1.0.6 bash uploader.What it does
Downloads a pinned Codecov CLI, verifies it, and runs
upload-process. No third-partyaction in the dependency chain.
Design notes
latest—cli.codecov.io/latest/...is mutable and wouldsilently change what executes in CI. Defaults to
v11.3.1.expected-sha256pins the binary hash(strongest). With it empty the action falls back to the checksum published next to the
binary and emits a
::warning::— that detects corruption and truncation but notsubstitution, since an attacker who could replace the binary could replace its
checksum too. The docstring says so plainly rather than implying the fallback is
equivalent.
CODECOV_TOKENenv, never argv — so it cannot leak through the processlist. The CLI picks it up automatically.
--disable-searchso the uploaded set is exactly the named files, not whateverCodecov's search happens to find.
fail-on-errordefaults totrue. A silently skipped upload is precisely how acoverage gate rots unnoticed — the repo that prompted this had no successful CI run
for 9 months. Consumers who would rather a Codecov outage not break the build can set
it to
false.shasum -a 256, notsha256sum— the latter is Linux-only and would break amacOS consumer.
Against the Coding Rules
python3 -c "import yaml; yaml.safe_load(open('codecov-upload/action.yml'))"passes, verified against the file as it exists on this branch.
shell: bashthroughout; nomapfileor other bash 4+builtins. Argument lists are built positionally with
set --.${{ inputs.* }}or${{ github.* }}is interpolated intoany
run:script. Every value is passed through an intermediateenv:var and read as"$VAR".straight about.
Validation
Exercised in a real green CI run on
segmentio/fql-ts:run 36447521558. From the log:
The caveat: that run consumed a byte-identical local copy at
.github/actions/codecov-upload, nottwilio/sdk-actions/codecov-upload@<sha>. Theruns:block is identical and every input'srequired/defaultmatches; only threeinput descriptions differ in wording.
I could not do a true branch-SHA consumer test, and the reason is the same policy this
action exists for: my branch lives on a personal fork, which is neither GitHub-owned nor
inside this enterprise, so any repo referencing it gets
startup_failure. A genuinebranch-SHA test needs the branch to live in
twilio/sdk-actionsitself. Happy to re-runit that way if a maintainer pushes the branch here, and to fix anything it turns up.
Note on process
CONTRIBUTING.mdasks that major changes be discussed in an issue first. A new action isarguably more than a small change, so if you would rather this started as an issue, say
so and I will open one and close this — I led with the PR because the implementation is
small and the failure it fixes is concrete.