Skip to content

feat(codecov-upload): add checksum-verified Codecov CLI upload action - #21

Open
MichaelGHSeg wants to merge 2 commits into
twilio:mainfrom
MichaelGHSeg:feat/codecov-upload
Open

MichaelGHSeg wants to merge 2 commits into
twilio:mainfrom
MichaelGHSeg:feat/codecov-upload

Conversation

@MichaelGHSeg

Copy link
Copy Markdown

Why

codecov/codecov-action cannot 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 referencing codecov/codecov-action
fails the entire workflow with startup_failure before any step executes — SHA-pinning
does not help. I confirmed this policy is identical on segmentio/fql-ts,
analytics-php, analytics-next and analytics-java, so it is org-wide rather than
per-repo.

Actions inside this enterprise are exempt from that allowlist — which is exactly why
twilio/sdk-actions/artifactory-oidc works today. So a codecov-upload action here is
consumable 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 hardened ci.yml keeps coverage as a build
artifact with the comment "codecov/codecov-action is not allow-listed either, so
coverage is kept"
. That leaves any non-informational gate in codecov.yml permanently
without data. Two other repos (analytics-java, analytics_flutter) still shell out to
curl -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-party
action in the dependency chain.

Design notes

  • Version pinned, not latest — cli.codecov.io/latest/... is mutable and would
    silently change what executes in CI. Defaults to v11.3.1.
  • Checksum verified before execution. expected-sha256 pins 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 not
    substitution, 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.
  • Token via CODECOV_TOKEN env, never argv — so it cannot leak through the process
    list. The CLI picks it up automatically.
  • --disable-search so the uploaded set is exactly the named files, not whatever
    Codecov's search happens to find.
  • fail-on-error defaults to true. A silently skipped upload is precisely how a
    coverage 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, not sha256sum — the latter is Linux-only and would break a
    macOS consumer.

Against the Coding Rules

  • ✅ Valid YAML — python3 -c "import yaml; yaml.safe_load(open('codecov-upload/action.yml'))"
    passes, verified against the file as it exists on this branch.
  • ✅ Portable shell — shell: bash throughout; no mapfile or other bash 4+
    builtins. Argument lists are built positionally with set --.
  • ✅ Pin by SHA — not applicable; this action references no other actions.
  • ✅ Untrusted input — no ${{ inputs.* }} or ${{ github.* }} is interpolated into
    any run: script. Every value is passed through an intermediate env: var and read as
    "$VAR".
  • ⚠️ Test against a consumer — see below; it passed, with one caveat I want to be
    straight about.

Validation

Exercised in a real green CI run on segmentio/fql-ts:
run 36447521558. From the log:

##[notice]verifying the Codecov CLI against the pinned checksum
codecov: OK
##[notice]uploading coverage to Codecov for segmentio/fql-ts
info -- Found 1 coverage files to report
info -- > /home/runner/work/fql-ts/fql-ts/coverage/lcov.info
info -- Sending upload (5198 bytes) to storage
info -- Upload queued for processing complete
{"result": "RequestResult(error=None, warnings=[], status_code=200, text='')"}

The caveat: that run consumed a byte-identical local copy at
.github/actions/codecov-upload, not twilio/sdk-actions/codecov-upload@<sha>. The
runs: block is identical and every input's required/default matches; only three
input 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 genuine
branch-SHA test needs the branch to live in twilio/sdk-actions itself. Happy to re-run
it that way if a maintainer pushes the branch here, and to fix anything it turns up.

Note on process

CONTRIBUTING.md asks that major changes be discussed in an issue first. A new action is
arguably 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant