Skip to content

fix: include caller job name in coverage artifact names - #139

Open
lengau wants to merge 4 commits into
mainfrom
work/fix-coverage-artifact-naming
Open

fix: include caller job name in coverage artifact names#139
lengau wants to merge 4 commits into
mainfrom
work/fix-coverage-artifact-naming

Conversation

@lengau

@lengau lengau commented May 12, 2026

Copy link
Copy Markdown
Contributor

Problem

When test-python.yaml is called multiple times in the same workflow run (e.g. in craft-parts), the coverage artifact names collide because they only include platform and Python version. This causes 409 Conflict: an artifact with this name already exists on the workflow run errors on upload.

Fix

Include ${{ github.job }} in all coverage artifact names. In reusable workflows, github.job resolves to the caller's job key, making names unique across callers:

Before After
coverage-slow-ubuntu-24.04-3.12 coverage-test-common-slow-ubuntu-24.04-3.12
coverage-slow-ubuntu-24.04-3.12 ❌ conflict coverage-test-java-plugins-slow-ubuntu-24.04-3.12

Testing

The existing self-test-qa.yaml already exercises this scenario — test-python-custom and test-python-as-root call test-python.yaml with overlapping parameters (ubuntu-latest, Python 3.14, lowest 3.8). Added a comment documenting this intentional overlap.

lengau and others added 3 commits May 12, 2026 15:16
When test-python.yaml is called multiple times in the same workflow run
(e.g. test-common, test-java-plugins, test-python-plugins), the coverage
artifact names collide because they only include platform and Python
version. This causes 409 Conflict errors on upload.

Add ${{ github.job }} to all coverage artifact names so each caller
gets unique artifact names (e.g. coverage-test-common-slow-ubuntu-24.04-3.12
vs coverage-test-java-plugins-slow-ubuntu-24.04-3.12).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds a verify-coverage-artifacts job that runs after all test jobs and
uses the GitHub API to check that:
- No duplicate coverage artifact names exist
- Each caller job (test-python, test-python-custom, test-python-as-root)
  produced fast, slow, and lowest coverage artifacts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github.job returns the job ID within the reusable workflow (e.g. 'fast',
'slow'), not the caller's job key. Instead, use the recently-shipped
job.check_run_id context property to look up the full compound job name
via the REST API (e.g. 'test-common / Fast tests') and extract the
caller's job key for unique artifact naming.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lengau
lengau marked this pull request as ready for review May 12, 2026 15:04
@lengau
lengau requested review from Copilot, mr-cal and tigarmo May 12, 2026 15:04
slow-test-python-versions: '["3.14"]'
lowest-python-version: "3.8"
lowest-python-platform: '["jammy", "arm64"]'
lowest-python-platform: '["focal", "amd64"]'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Drive-by: test that we work on Canonical's focal runners :-)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 aims to prevent GitHub Actions coverage artifact upload collisions when the reusable test-python.yaml workflow is invoked multiple times in a single workflow run by making artifact names unique per caller job.

Changes:

  • Adds a “Resolve caller job name” step in test-python.yaml and prefixes coverage artifact names with the resolved caller identifier.
  • Updates self-test-qa.yaml to document intentional parameter overlap, and adds a job that verifies coverage artifacts are present and unique.

Reviewed changes

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

File Description
.github/workflows/test-python.yaml Prefixes coverage artifact names with a resolved “caller job” value to avoid name collisions across multiple callers.
.github/workflows/self-test-qa.yaml Adjusts self-test inputs, documents overlap intent, and adds an artifacts verification job to catch collisions/missing uploads.

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

Comment thread .github/workflows/test-python.yaml
Comment thread .github/workflows/test-python.yaml
Comment thread .github/workflows/test-python.yaml
Comment thread .github/workflows/self-test-qa.yaml
Comment thread .github/workflows/self-test-qa.yaml Outdated
Comment thread .github/workflows/self-test-qa.yaml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
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.

3 participants