Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions vinca/generate_gha.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ def build_unix_pipeline(
"name": pretty_stage_name,
"runs-on": runs_on,
"strategy": {"fail-fast": False},
"needs": prev_batch_keys,
# actionlint rejects an empty needs list, so first-stage jobs omit it
**({"needs": prev_batch_keys} if prev_batch_keys else {}),
"steps": steps,
}

Expand Down Expand Up @@ -410,7 +411,8 @@ def build_win_pipeline(
"name": pretty_stage_name,
"runs-on": vm_imagename,
"strategy": {"fail-fast": False},
"needs": prev_batch_keys,
# actionlint rejects an empty needs list, so first-stage jobs omit it
**({"needs": prev_batch_keys} if prev_batch_keys else {}),
"env": {
"CONDA_BLD_PATH": "C:\\\\bld\\\\",
"VINCA_CUSTOM_CMAKE_BUILD_DIR": "C:\\\\x\\\\",
Expand Down
18 changes: 18 additions & 0 deletions vinca/test_generate_gha.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,21 @@ def test_win_pipeline_requires_the_repository_build_script(tmp_path, monkeypatch
build_win_pipeline(
[[["ros2-rclcpp"]]], "buildbranch_win", outfile=tmp_path / "win.yml"
)


def test_only_later_stages_declare_needs(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
(tmp_path / ".scripts").mkdir()
(tmp_path / ".scripts" / "build_win.bat").write_text("echo build\n")
stages = [[["ros2-a"], ["ros2-b"]], [["ros2-c"]]]
yaml = pytest.importorskip("yaml")

build_unix_pipeline(stages, "branch", outfile=tmp_path / "linux.yml")
build_win_pipeline(stages, "branch", outfile=tmp_path / "win.yml")

for outfile in ("linux.yml", "win.yml"):
jobs = yaml.safe_load((tmp_path / outfile).read_text())["jobs"]
# actionlint rejects `needs: []`
assert "needs" not in jobs["stage_0_job_0"]
assert "needs" not in jobs["stage_0_job_1"]
assert jobs["stage_1_job_2"]["needs"] == ["stage_0_job_0", "stage_0_job_1"]
Loading