Skip to content

Change-aware GHDL/cocotb CI: run only affected cocotb tests on feature-branch pushes#1445

Closed
ruck314 wants to merge 1 commit into
pre-releasefrom
ci-test-cherry-pick-using-GHDL-cf-file
Closed

Change-aware GHDL/cocotb CI: run only affected cocotb tests on feature-branch pushes#1445
ruck314 wants to merge 1 commit into
pre-releasefrom
ci-test-cherry-pick-using-GHDL-cf-file

Conversation

@ruck314

@ruck314 ruck314 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

Make the GHDL/cocotb regression job change-aware: on ordinary feature-branch pushes it runs only the cocotb tests whose RTL dependencies actually changed, while the release path (tags, main, and PRs into main) still runs the complete suite. Previously every push re-ran the entire suite.

The dependency graph is derived from the actual build (build/*.cf + ghdl --gen-depends) at CI time — never a hand-maintained list — so it cannot drift from the RTL. Every indeterminate case fails safe toward running more tests, so selective mode can never skip a test the full suite would have run. Because cocotb cannot drive VHDL records, most tests wrap their DUT in a **/wrappers/ or **/ip_integrator/ entity that make import never compiles; those sources are imported into the resolver's library first so their toplevels resolve to real dependency sets instead of falling back to always-run. Subsystems whose core RTL is family-gated out of the generic GHDL build (pgp2b, pgp2fc, coaxpress) remain always-run by fail-safe.

CI trigger behavior

When the full suite runs vs. only the affected tests:

Trigger Type # Trigger Test Suite Run Why
1 Push to a feature branch (ref is not main and not a tag) Selective — only affected cocotb tests Fast feedback on work in progress
2 Push to main Full Integration branch
3 Tag push (refs/tags/*) Full Release path
4 Pull request targeting main Full Pre-merge gate before release
5 Pull request targeting a non-main branch (e.g. pre-release) No run The pull_request trigger is scoped to main; the branch's own push already ran the selective job

@ruck314 ruck314 force-pushed the ci-test-cherry-pick-using-GHDL-cf-file branch from b065526 to 178687e Compare July 2, 2026 15:37
@ruck314 ruck314 force-pushed the ci-test-cherry-pick-using-GHDL-cf-file branch from 18c0927 to 40058ca Compare July 2, 2026 23:15
@ruck314 ruck314 requested a review from Copilot July 2, 2026 23:24

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

Adds a dependency-based resolver to make the GHDL/cocotb regression CI change-aware: feature-branch pushes can run only the cocotb tests affected by RTL (and certain test Python) changes, while main/tags/PRs-to-main continue to run the full suite. The resolver is derived from the actual imported build graph (.cf + ghdl --gen-depends) and fails open to full runs on indeterminate cases.

Changes:

  • Introduces a dependency resolver (tests/common/dep_map.py) plus CLI entrypoint (python -m tests.common) to select affected cocotb tests or emit a FORCE_FULL sentinel.
  • Adds comprehensive unit tests for the resolver behavior and fail-open invariants (tests/common/test_dep_map.py).
  • Updates CI workflow to choose between full vs selective execution and to install an LLVM-backend GHDL for dependency resolution.

Reviewed changes

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

File Description
tests/common/dep_map.py Implements discovery, dependency extraction, wrapper attribution, and changed-file → affected-test selection logic.
tests/common/__main__.py CLI wrapper around the resolver used by CI to emit targets or FORCE_FULL.
tests/common/test_dep_map.py Unit tests covering resolver correctness, fail-open rules, and wrapper/ip_integrator handling.
.github/workflows/surf_ci.yml Adds PR trigger + selective/full mode selection, installs LLVM GHDL for --gen-depends, and runs selected tests on feature-branch pushes.

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

Comment thread tests/common/dep_map.py
Comment thread .github/workflows/surf_ci.yml Outdated
Comment thread .github/workflows/surf_ci.yml Outdated
Comment thread .github/workflows/surf_ci.yml Outdated

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/common/dep_map.py Outdated

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 4 out of 4 changed files in this pull request and generated 5 comments.

Comment thread .github/workflows/surf_ci.yml Outdated
Comment thread .github/workflows/surf_ci.yml Outdated
Comment thread tests/common/dep_map.py Outdated
Comment thread tests/common/dep_map.py Outdated
Comment thread tests/common/dep_map.py Outdated

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/common/dep_map.py Outdated

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 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread tests/common/__main__.py Outdated
Comment thread tests/common/dep_map.py Outdated
Comment thread tests/common/dep_map.py Outdated

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 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/surf_ci.yml
Comment thread tests/common/dep_map.py

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 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/surf_ci.yml Outdated
Comment thread tests/common/__main__.py

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/common/dep_map.py Outdated

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 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread tests/common/dep_map.py Outdated
Comment thread tests/common/dep_map.py

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 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread tests/common/__main__.py
Comment thread .github/workflows/surf_ci.yml Outdated
Comment thread .github/workflows/surf_ci.yml Outdated

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 4 out of 4 changed files in this pull request and generated no new comments.

Run only the cocotb tests whose RTL dependencies actually changed on
feature-branch pushes, while tags, main, and PRs into main still run the
complete suite. The dependency graph is derived from the actual build
(build/*.cf + `ghdl --gen-depends`) at CI time, so it cannot drift from the
RTL, and every indeterminate case fails safe toward running more tests.

- tests/common/dep_map.py (importable core) + `python -m tests.common` CLI:
  map each cocotb test (by its toplevel) to its transitive RTL sources via
  build/*.cf and `ghdl --gen-depends`, diff against the merge-base with
  origin/main, and print the affected pytest targets (or a FORCE_FULL
  sentinel). Any indeterminate case falls back to always-run or a full run.
- Wrapper / IP-integrator resolution: most cocotb tests wrap their DUT in a
  **/wrappers/ or **/ip_integrator/ entity (cocotb cannot drive VHDL
  records), and `make import` never compiles those sources -- so their
  toplevels are absent from the surf library and `ghdl --gen-depends` cannot
  resolve them. Import those sources into the resolver's library first (with
  absolute paths, so the .cf entries stay REPO_ROOT-resolvable) so each such
  test resolves to its real transitive dependency set instead of falling
  back to always-run. Subsystems whose core RTL is family-gated out of the
  generic GHDL build (pgp2b, pgp2fc, coaxpress) remain always-run by
  fail-safe.
- Changed-wrapper attribution: a changed **/wrappers/ file selects exactly
  the test(s) whose toplevel instantiates it (or FORCE_FULL if
  unattributable) and never fans out as another test's production dependency.
- Shared base-package changes (e.g. StdRtlPkg, AxiLitePkg, AxiStreamPkg, or
  any high-fan-out hub) force a full run, detected by a data-driven fan-out
  threshold over the built dependency map.
- Strict-subset guarantee: a runtime guard intersects the selection with the
  discovered test universe before emitting it, and a randomized property test
  asserts the selected set is always a subset of the full suite.
- .github/workflows/surf_ci.yml: trigger on push and pull_request into main
  (preserving concurrency cancel-in-progress); selective on feature-branch
  pushes, full on tag/main/PR->main; fail open to the full suite on resolver
  error. The regression job installs GHDL's official LLVM build via
  ghdl/setup-ghdl (v6.0.0) for --gen-depends only, and runs the cocotb
  simulations on the apt mcode ghdl. The lint/syntax job is unchanged.
- tests/common/test_dep_map.py: unit and property tests for the parser, the
  wrapper index, wrapper/ip_integrator source discovery and import, selection
  routing, base-package force-full, and the strict-subset invariant.
@ruck314 ruck314 force-pushed the ci-test-cherry-pick-using-GHDL-cf-file branch from 94373fe to 70559db Compare July 3, 2026 03:06
@ruck314 ruck314 closed this Jul 3, 2026
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