Skip to content

ci: deduplicate snap packaging across spread and test workflows - #2978

Draft
LoweRAM wants to merge 1 commit into
canonical:mainfrom
LoweRAM:ci/deduplicate-snap-pack-spread
Draft

LoweRAM wants to merge 1 commit into
canonical:mainfrom
LoweRAM:ci/deduplicate-snap-pack-spread

Conversation

@LoweRAM

@LoweRAM LoweRAM commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Consolidate snap-dependent jobs into a single unified spread.yaml workflow so that the Charmcraft snap is built once and shared across all spread test jobs and PR snap publishing, eliminating redundant snap builds.

Problem

Previously, four separate workflows each defined independent snap-build jobs using action-build:

  • tests.yaml built the snap on every PR solely to publish it to edge/pr-*.
  • spread.yaml built the snap on every PR to run source and store spread tests.
  • spread-docs.yaml built the snap whenever doc code changed to run doc spread tests.
  • spread-manual.yaml built the snap whenever manual spread runs were triggered.

Across a single PR's lifecycle (PR creation and subsequent merge to main), the exact same snap was built up to 5 times, wasting runner time and delaying test completion.

Solution

  1. Consolidate snap-publish (from tests.yaml), docs-tests (from spread-docs.yaml), and manual-spread-tests (from spread-manual.yaml) into .github/workflows/spread.yaml.
  2. Add a fast filter step via dorny/paths-filter to detect whether source, docs, or manual spread runs are needed.
  3. Build the snap once in snap-build (upgraded to canonical/action-build@v1) only when needed, and share the build artifact across all downstream jobs.
  4. Remove the redundant tests.yaml, spread-docs.yaml, and spread-manual.yaml workflow files.
  5. Update the Tests badge in README.md to point to qa.yaml where unit and integration tests actually run.

Verification

  • Validated all workflow syntax with actionlint (0 errors).
  • Audited with zizmor (eliminated multiple unpinned/deprecated warnings and excessive permission warnings from removed workflows).
  • Verified local linting and tests pass with ruff check, ruff format --diff, ty check, and make test-fast.

Consolidate snap-publish from tests.yaml, docs spread tests from spread-docs.yaml, and manual spread tests from spread-manual.yaml into spread.yaml with a shared snap-build job so the snap is packed only once per workflow run.
submodules: true

- name: Download snap artifact
uses: actions/download-artifact@v8
mkdir "${{ github.workspace }}"

- name: Checkout charmcraft
uses: actions/checkout@v7
name: snap

- name: Set up Go
uses: actions/setup-go@v7
submodules: true

- name: Download snap artifact
uses: actions/download-artifact@v8
mkdir "${{ github.workspace }}"

- name: Checkout charmcraft
uses: actions/checkout@v7
Comment on lines +34 to +69
filter:
runs-on: ubuntu-latest
outputs:
source: ${{ steps.filter.outputs.source }}
docs: ${{ steps.filter.outputs.docs }}
manual: ${{ steps.filter.outputs.manual == 'true' || steps.manual-eval.outputs.manual == 'true' }}
snap-needed: ${{ steps.filter.outputs.source == 'true' || steps.filter.outputs.docs == 'true' || steps.filter.outputs.manual == 'true' || steps.manual-eval.outputs.manual == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: filter
with:
filters: |
source:
- '!({docs/**,*.md,**/*.md,.readthedocs.yaml})'
- 'tests/spread/**'
- 'spread.yaml'
- '.github/workflows/spread.yaml'
docs:
- 'docs/**/code/**'
- 'spread.yaml'
- '.readthedocs.yaml'
- '.github/workflows/spread.yaml'
manual:
- 'tests/spread/charms/**'
- 'tests/spread/smoketests/parallel-build/**'
- 'tests/spread/smoketests/remote-build/**'
- '.github/workflows/spread.yaml'
- id: manual-eval
env:
IS_MANUAL: "${{ contains(github.event.pull_request.labels.*.name, 'PR: Run Manual Spread') }}"
run: |
echo "manual=${IS_MANUAL}" >> "$GITHUB_OUTPUT"
Comment on lines +212 to +216
- name: Checkout charmcraft
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
Comment on lines +243 to +247
- name: Checkout charmcraft
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
Comment on lines +42 to +45
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
Comment on lines +298 to +302
- name: Checkout charmcraft
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
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