Skip to content

ci: plumb CODECOV_TOKEN into the reusable test workflow - #3274

Open
vpetersson-bot wants to merge 2 commits into
Screenly:masterfrom
vpetersson-bot:fix/codecov-token-plumbing
Open

ci: plumb CODECOV_TOKEN into the reusable test workflow#3274
vpetersson-bot wants to merge 2 commits into
Screenly:masterfrom
vpetersson-bot:fix/codecov-token-plumbing

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Contributor

Issues Fixed

No associated issue. Surfaced by the Codecov comment on #3270: "Please upload report for BASE (master@82c5def)".

Description

Coverage has never been uploaded from master. The upload is rejected on every master push, and the step reports success anyway, so nothing has stored a baseline and every PR gets that warning.

From the master run for 82c5def (run 31085544289):

CODECOV_TOKEN:
 -> Token length: 0
==> Running upload-coverage
info  -- Upload queued for processing complete
error -- Upload queued for processing failed:
         {"message":"Token required because branch is protected"}
##[end-action outcome=success;conclusion=success]

Master is a protected branch, Codecov requires a token for protected refs, the token was empty, and codecov-action defaults to fail_ci_if_error: false — so the step went green and the failure was invisible.

Note what this is not: nothing is wrong with the coverage in #3270 or any other PR. Codecov explicitly reported "All modified and coverable lines are covered by tests" there. The only broken thing is the base-report upload, which makes the coverage delta uncomputable.

Two independent causes — both have to be fixed

  1. workflow_call does not inherit secrets. docker-test.yaml called test-runner.yml with only with:, no secrets: block, so secrets.CODECOV_TOKEN inside the reusable workflow was empty however the repository was configured. Fixed here.
  2. The repo has no CODECOV_TOKEN secret at all — the configured secrets are BALENA_TOKEN, DOCKER_PASSWORD, DOCKER_USERNAME. This PR is inert until that secret is added, and adding it is the half I cannot do.

Fixing either alone achieves nothing, which is presumably how this survived so long.

The change

  • Declare CODECOV_TOKEN as an optional workflow_call secret in test-runner.yml, and pass it explicitly from the python job only in docker-test.yaml. Explicit rather than secrets: inherit so the test workflow receives just the one secret it needs, and so the dependency is visible at both ends. Optional so tokenless uploads from fork PRs keep working on unprotected refs.
  • Also pass it via the action's documented token: input, alongside the existing env export (the bundled CLI reads CODECOV_TOKEN from the environment).
  • Stop the silence. A new step emits a GitHub warning annotation when the token is empty on a push. fail_ci_if_error deliberately stays false — a Codecov outage must never block a merge — but a misconfiguration should not be invisible for months either. This is the part that makes the class of bug self-reporting next time.

Verification

Both files parse as valid YAML, and the secret lands on exactly the intended job:

run-typescript-tests: secrets=[]
run-python-tests:     secrets=['CODECOV_TOKEN']

The typescript job does not upload coverage (if: inputs.test-type == 'python'), so it correctly receives nothing.

What I could not verify: the upload actually succeeding, because that needs the secret to exist. Once it is added, the next master push should log a non-zero token length and no "Token required" error, and the following PR should show a real coverage delta instead of the missing-BASE warning.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

CI-configuration change only — no application code, so the test and device boxes do not apply. The change is validated by YAML parsing and by inspecting which job receives the secret; end-to-end validation is blocked on the repo secret.

Coverage has never been uploaded from master. The master run for
82c5def logged:

    CODECOV_TOKEN:
    -> Token length: 0
    error -- Upload queued for processing failed:
             {"message":"Token required because branch is protected"}
    ##[end-action outcome=success]

so no baseline was ever stored and every PR reports "Please upload
report for BASE". The step still passed because codecov-action defaults
to fail_ci_if_error: false.

Two independent causes, both needed:

- `workflow_call` does NOT inherit secrets, so `secrets.CODECOV_TOKEN`
  inside test-runner.yml was empty however the repo was configured.
  Declared as an optional workflow_call secret and passed explicitly
  from the python job only — least privilege, and it documents the
  dependency at both ends rather than relying on `secrets: inherit`.
- the repo has no CODECOV_TOKEN secret at all (only BALENA_TOKEN,
  DOCKER_PASSWORD, DOCKER_USERNAME). That has to be added separately;
  this change is inert until it is.

Also stop the failure being silent: warn via a GitHub annotation when
the token is empty on a push. fail_ci_if_error deliberately stays false
so a Codecov outage cannot block a merge — but a misconfiguration should
not be invisible for months either. Left optional so tokenless uploads
from fork PRs keep working.
@vpetersson-bot
vpetersson-bot requested a review from a team as a code owner August 7, 2026 08:38
@vpetersson-bot vpetersson-bot self-assigned this Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@82c5def). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3274   +/-   ##
=========================================
  Coverage          ?   90.71%           
=========================================
  Files             ?       76           
  Lines             ?     8440           
  Branches          ?      896           
=========================================
  Hits              ?     7656           
  Misses            ?      563           
  Partials          ?      221           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Codecov baseline uploads from the protected master branch by explicitly plumbing CODECOV_TOKEN into the reusable CI test workflow, so Codecov can accept coverage uploads and compute PR deltas correctly.

Changes:

  • Declares CODECOV_TOKEN as an optional workflow_call secret in the reusable test-runner.yml.
  • Passes CODECOV_TOKEN explicitly from the run-python-tests job in docker-test.yaml (instead of relying on implicit secret inheritance).
  • Adds a “missing token” warning step and provides the token to codecov/codecov-action via both the token: input and CODECOV_TOKEN env var.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/test-runner.yml Accepts an optional Codecov token secret, adds a (currently mis-gated) warning step, and uses the token in the Codecov upload step.
.github/workflows/docker-test.yaml Passes CODECOV_TOKEN into the reusable workflow for the Python test job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/test-runner.yml
Comment thread .github/workflows/test-runner.yml
- pass the caller's event name as an explicit workflow_call input rather
  than reading github.event_name inside the called workflow. I believe
  the context does carry the caller's event through, but the failure mode
  of being wrong is that the token warning silently never fires — which
  is precisely the bug class this change exists to stop, so it is not
  worth betting on. An explicit input cannot be wrong.
- set fail_ci_if_error: false explicitly instead of relying on the
  action's default. The comment already claimed we depend on that
  behaviour; defaults can change across major versions, so pin it.

Also keeps the bind-mount comment attached to the upload step it
describes rather than the new warning step.
@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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.

2 participants