diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 51498c5eba..10236f411a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,3 +1,7 @@ +# The maintained actionlint fork (#1501) that knows current runner labels, pinned by digest. +# This stage is a reference only; the binary is copied into the devcontainer image below. +FROM docker.io/kjanat/actionlint:1.17.0@sha256:d484cccadf56b6a356466ade9af4c8e05c5dce1badaf0a9ecd0d7639d68d9c92 AS actionlint + FROM debian:sid # Avoid interactive prompts during apt operations in CI @@ -49,3 +53,7 @@ COPY src/ /tmp/devops-cli/src/ RUN --mount=type=cache,target=/root/.cache/uv \ uv pip install --system --break-system-packages --no-deps /tmp/devops-cli && \ rm -rf /tmp/devops-cli + +# Provide the pinned actionlint binary on PATH so the bare `actionlint` command resolves. +# Placed last so a source change above rebuilds no earlier layer. +COPY --from=actionlint /usr/local/bin/actionlint /usr/local/bin/actionlint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2bdf101ad..659149021f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,8 +67,13 @@ jobs: - name: Install Trivy run: uv run devops install-tools --tool trivy --only-missing + # The pinned actionlint validates the workflows. It is the same digest-pinned image that the + # devcontainer Dockerfile copies, so the gate does not run actionlint twice (#1119). + - name: Run actionlint + uses: docker://docker.io/kjanat/actionlint:1.17.0@sha256:d484cccadf56b6a356466ade9af4c8e05c5dce1badaf0a9ecd0d7639d68d9c92 + - name: Static Analysis Quality Gate - run: uv run devops ci --check --no-cache --skip test,outdated + run: uv run devops ci --check --no-cache --skip test,outdated,actionlint # The scan skips Trivy's filesystem scan, `trivy`, which took 194 s over this tree. The audit # row of the quality gate checks the dependencies. diff --git a/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/.openspec.yaml b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/.openspec.yaml new file mode 100644 index 0000000000..c1fa2fe5d4 --- /dev/null +++ b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/.openspec.yaml @@ -0,0 +1,3 @@ +schema: spec-driven +created: 2026-10-29 +skip_specs: true diff --git a/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/design.md b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/design.md new file mode 100644 index 0000000000..de3c142801 --- /dev/null +++ b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/design.md @@ -0,0 +1,32 @@ +# Design + +## Context + +The `actionlint-py` PyPI wrapper is stalled at version 1.7.12, which rejects `ubuntu-26.04` as an unknown label, blocking the lint gate. The maintained upstream `actionlint` has reached v1.17.0. The devcontainer already provides other tools via `COPY --from` stages, and the CI workflow already uses `docker://` actions for other tools. + +## Goals / Non-Goals + +**Goals:** + +- Replace `actionlint-py` (stalled PyPI wrapper) with `kjanat/actionlint` v1.17.0 (maintained upstream binary). +- Deliver the binary as a digest-pinned Docker image so the gate never depends on a mutable PyPI release. +- Keep the `actionlint` row of `devops ci` unchanged in name and behavior. +- Pass all existing tests without lowering any threshold. + +**Non-Goals:** + +- Changing the `actionlint` linter's behavior or configuration. +- Adding new checks to the CI gate. +- Changing the devcontainer's base image. + +## Decisions + +- **Use a digest-pinned Docker image.** The devcontainer `Dockerfile` adds a `FROM docker.io/kjanat/actionlint:1.17.0@sha256:d484ccca…` stage and `COPY --from` of the binary into the final image. This pins the exact binary by content hash, so a future registry update cannot change what the gate runs. Rejected: using a tag-pinned image. A tag can be moved to a different binary; a digest cannot. +- **Invoke `actionlint` bare on `PATH`.** The devcontainer provides the binary at `/usr/local/bin/actionlint`. The gate's `CheckSpec` command changes from `["uv", "run", "actionlint"]` to `["actionlint"]`. The `shutil.which` pre-check in the subcommand gives a clear message when the binary is absent (e.g. on a host without the devcontainer). Rejected: keeping `uv run actionlint`. This would require `actionlint-py` to remain in the dependency group, which this change removes. +- **Add a `docker://` step in CI.** The `Static Analysis` job of `ci.yml` adds a `docker://docker.io/kjanat/actionlint:1.17.0@sha256:d484ccca…` step that runs the linter in CI. The gate now skips `actionlint` (it runs as a separate `uses:` step). This mirrors the existing pattern for other tools delivered via `docker://`. Rejected: running `actionlint` inside the `devops ci` gate in CI. The binary would not be on `PATH` in the CI runner. +- **Add an offline digest-parity test.** `test_actionlint_digest_pinned_in_dockerfile_and_ci` asserts that the Dockerfile `FROM` and the CI workflow `uses:` reference the same digest-pinned image. This prevents the two from drifting apart. + +## Risks / Trade-offs + +- [The Docker Hub image is removed or the digest becomes unavailable] → The digest is content-addressed; as long as Docker Hub retains the blob, the build is reproducible. The repository pins the digest in both the Dockerfile and the CI workflow, and the digest-parity test holds them together. +- [A host without the devcontainer runs `devops ci actionlint`] → The `shutil.which` pre-check exits with a clear message naming the missing binary and the install source. diff --git a/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/proposal.md b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/proposal.md new file mode 100644 index 0000000000..539ae184ce --- /dev/null +++ b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/proposal.md @@ -0,0 +1,46 @@ +# Proposal + +## Why + +Issue #1119: the `actionlint-py` PyPI wrapper is stalled at version 1.7.12, which rejects `ubuntu-26.04` as an unknown label. The maintained upstream `actionlint` has reached v1.17.0, which accepts `ubuntu-26.04`. This change replaces the stalled PyPI wrapper with the maintained upstream binary, delivered as a digest-pinned Docker image so the gate never depends on a mutable PyPI release. + +## What Changes + +- The devcontainer `Dockerfile` adds a `FROM docker.io/kjanat/actionlint:1.17.0@sha256:d484ccca…` stage and `COPY --from` of the `actionlint` binary into the final image. +- `pyproject.toml` removes `actionlint-py` from the `dev` dependency group; `uv.lock` is regenerated. +- `src/devops_cli/commands/ci.py` changes the `actionlint` row's command from `["uv", "run", "actionlint"]` to `["actionlint"]`, and adds a `shutil.which` pre-check in the subcommand that exits with a clear message when the binary is not on `PATH` (skipped during `--dry-run`). +- `.github/workflows/ci.yml` adds a `docker://docker.io/kjanat/actionlint:1.17.0@sha256:d484ccca…` step to the `Static Analysis` job, and the gate now skips `actionlint` (it runs as a separate `uses:` step). +- `tests/test_ci.py`, `tests/test_ci_dry_run.py` and `tests/test_workflow_contracts.py` are updated to match the new invocation and to assert that the Dockerfile and CI workflow reference the same digest. +- `src/devops_cli/ai/knowledge_base/devops_cli/libraries/bandit_actionlint.md` and `python_packages.md` are updated to reflect the new invocation. + +The change alters no observable behavior of `devops ci`: the `actionlint` row still runs the same linter against the same files, and the gate result is unchanged. It is a dependency and delivery-method refactor. `skip_specs: true`. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +None. The `actionlint` row of `devops ci` runs the same linter against the same files; only the binary's origin and invocation method change. + +## Impact + +- Code: `src/devops_cli/commands/ci.py` (CheckSpec command, `shutil.which` pre-check). +- Build: `.devcontainer/Dockerfile` (FROM + COPY stage). +- Config: `pyproject.toml` (remove `actionlint-py`), `uv.lock` (regenerated). +- CI: `.github/workflows/ci.yml` (docker:// step, skip list). +- Tests: `tests/test_ci.py`, `tests/test_ci_dry_run.py`, `tests/test_workflow_contracts.py`. +- Docs: `src/devops_cli/ai/knowledge_base/devops_cli/libraries/bandit_actionlint.md`, `python_packages.md`. + +## Feasibility + +- `docker.io/kjanat/actionlint:1.17.0` exists on Docker Hub and its manifest is digest-addressable at `sha256:d484cccadf56b6a356466ade9af4c8e05c5dce1badaf0a9ecd0d7639d68d9c92`. The binary lives at `/usr/local/bin/actionlint` inside the image (confirmed via `docker inspect`). +- `actionlint` v1.17.0 accepts `ubuntu-26.04` as a valid label (upstream release notes), unblocking the lint gate. +- `COPY --from=image` is excluded from the COPY-coverage invariant in `tests/test_architectural_invariants.py:962-1000`, so the new COPY stage does not trip the ratchet. + +## Existing Tool Considered + +- `kjanat/actionlint` v1.17.0 is the upstream, actively maintained actionlint binary. Rather than continuing to depend on the stalled `actionlint-py` PyPI wrapper (last release 1.7.12), this change uses the upstream binary directly via a digest-pinned Docker image, which is the canonical distribution channel for the actionlint project. +- The change deletes the `actionlint-py==1.7.12.25` entry from `pyproject.toml` and the corresponding lock entry from `uv.lock`. diff --git a/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/tasks.md b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/tasks.md new file mode 100644 index 0000000000..6cd9b39ae4 --- /dev/null +++ b/openspec/changes/archive/2026-10-29-1119-actionlint-docker-image/tasks.md @@ -0,0 +1,23 @@ +# Tasks + +## 1. Update tests for the new invocation + +- [x] 1.1 Update `tests/test_ci.py`, `tests/test_ci_dry_run.py` and `tests/test_workflow_contracts.py` to match the new `["actionlint"]` invocation, add `shutil.which` mocks, add `test_ci_actionlint_not_on_path`, add the allowlist entry for the `docker://` step, add the `covered_rows` fix, add the digest-parity test, and verify they pass (`uv run pytest tests/test_ci.py tests/test_ci_dry_run.py tests/test_workflow_contracts.py`) + +## 2. Implementation of the digest-pinned delivery + +- [x] 2.1 Add the `FROM docker.io/kjanat/actionlint:1.17.0@sha256:d484ccca…` stage and `COPY --from` to `.devcontainer/Dockerfile`, remove `actionlint-py` from `pyproject.toml`, regenerate `uv.lock`, change the `CheckSpec` command to `["actionlint"]` and add the `shutil.which` pre-check in `src/devops_cli/commands/ci.py` (`uv run pytest tests/test_ci.py tests/test_ci_dry_run.py tests/test_workflow_contracts.py tests/test_architectural_invariants.py`) +- [x] 2.2 Add the `docker://` actionlint step to the `Static Analysis` job of `.github/workflows/ci.yml` and update the `--skip` list (`uv run pytest tests/test_ci.py tests/test_ci_dry_run.py tests/test_workflow_contracts.py`) + +## 3. Documentation + +- [x] 3.1 Update `src/devops_cli/ai/knowledge_base/devops_cli/libraries/bandit_actionlint.md` and `python_packages.md` to reflect the new invocation (`uv run devops docs check`) + +## 4. Full gate and OpenSpec archive + +- [x] 4.1 Verify all tests and static checks pass (`uv run devops ci --check --no-cache --skip test,outdated,actionlint`) +- [x] 4.2 Archive OpenSpec change (`uv run devops openspec archive 1119-actionlint-docker-image`) + +## Workflow follow-up + +- Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD). diff --git a/pyproject.toml b/pyproject.toml index fa6c40fc83..baee71412e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,7 +95,6 @@ dev = [ "pytest-randomly==5.0.0", "pytest-timeout==2.4.0", "bandit==1.9.4", - "actionlint-py==1.7.12.25", "zizmor==1.30.1", "pre-commit==4.6.2", "hypothesis==6.168.3", diff --git a/src/devops_cli/ai/knowledge_base/devops_cli/libraries/bandit_actionlint.md b/src/devops_cli/ai/knowledge_base/devops_cli/libraries/bandit_actionlint.md index 12dc5ae288..6a23432e85 100644 --- a/src/devops_cli/ai/knowledge_base/devops_cli/libraries/bandit_actionlint.md +++ b/src/devops_cli/ai/knowledge_base/devops_cli/libraries/bandit_actionlint.md @@ -19,7 +19,7 @@ tags: | :--- | :--- | | **Official Documentation** | [bandit.readthedocs.io](https://bandit.readthedocs.io/) • [github.com/rhysd/actionlint](https://github.com/rhysd/actionlint) | | **Public Git Repository** | [github.com/PyCQA/bandit](https://github.com/PyCQA/bandit) • [github.com/rhysd/actionlint](https://github.com/rhysd/actionlint) | -| **Official PyPI Packages** | `bandit==1.9.4`, `actionlint-py==1.7.12.25` | +| **Pinned Packages** | `bandit==1.9.4` (PyPI) • `actionlint 1.17.0` (docker.io/kjanat/actionlint, digest-pinned) | | **DevOps CLI Integration** | [`src/devops_cli/commands/ci.py`](../../../../../../src/devops_cli/commands/ci.py) • [`src/devops_cli/security/`](../../../../../../src/devops_cli/security/) | --- @@ -62,7 +62,7 @@ uv run bandit -r src --ini .bandit --severity-level low uv run bandit -r tests --ini .bandit --severity-level medium # Execute Actionlint against all GitHub Actions workflow definitions -uv run actionlint +actionlint ``` --- diff --git a/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md b/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md index 9a0183d11a..4bef43cec1 100644 --- a/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md +++ b/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md @@ -266,7 +266,7 @@ The development environment leverages modern Python engineering tools managed vi | **`pytest-randomly`** | `5.0.0` | Shuffles test order and reseeds `random` for each test; blocked in `addopts` (`-p no:randomly`) and enabled only by `devops ci test --repeat`. | `uv run devops ci test --repeat 3 ` | | **`pytest-timeout`** | `2.4.0` | Fails a test that hangs at the per-test bound in `[tool.pytest.ini_options]` (`timeout`, `timeout_method = "signal"`), so a stuck test fails in its own process and the run carries on. | `@pytest.mark.timeout()` for a test that needs longer | | **`bandit`** | `1.9.4` | AST-based Python security analyzer detecting insecure patterns (CWE checks). | `uv run devops ci security` (`bandit -r src` at low, `bandit -r tests` at medium, with `--ini .bandit`) | -| **`actionlint-py`** | `1.7.12.25` | GitHub Actions workflow syntax and expression validation engine. | `uv run actionlint` | + | **`pre-commit`** | `4.6.2` | Multi-hook manager orchestrating git commit quality gates. | `uv run pre-commit run --all-files` | | **`hatchling`** | `>=1.32.4` | Build backend complying with PEP 517 / PEP 621 for wheel generation. | `uv build` | diff --git a/src/devops_cli/commands/ci.py b/src/devops_cli/commands/ci.py index abeec82c00..0f48345d3b 100644 --- a/src/devops_cli/commands/ci.py +++ b/src/devops_cli/commands/ci.py @@ -8,6 +8,7 @@ import os import re import shlex +import shutil import signal import subprocess import sys @@ -769,7 +770,7 @@ def get_check_specs() -> list[CheckSpec]: CheckSpec( name="actionlint", display_title=MESSAGES.ci.actionlint, - cmd=["uv", "run", "actionlint"], + cmd=["actionlint"], span_name="ci.step.actionlint", metric_step="actionlint", ), @@ -2011,6 +2012,13 @@ def actionlint( set_dry_run(True) if not _verify_python_314_environment(): raise typer.Exit(1) + if not dry_run and shutil.which("actionlint") is None: + print_error( + "actionlint is not on PATH. The devcontainer image provides it. " + "For other hosts, install it from https://github.com/kjanat/actionlint " + "or the actionlint install page." + ) + raise typer.Exit(1) spec = get_check_spec("actionlint") if not _run(spec.cmd): raise typer.Exit(1) diff --git a/tests/test_ci.py b/tests/test_ci.py index 47911e5a55..114acbd7e6 100644 --- a/tests/test_ci.py +++ b/tests/test_ci.py @@ -344,12 +344,25 @@ def mock_run(cmd, *args, **kwargs): return subprocess.CompletedProcess(args=cmd, returncode=0, stdout="", stderr="") monkeypatch.setattr("subprocess.run", mock_run) + monkeypatch.setattr( + shutil, + "which", + lambda name: "/usr/local/bin/actionlint" if name == "actionlint" else None, + ) result = runner.invoke(app, ["actionlint"]) assert result.exit_code == 0 assert any("actionlint" in c for c in called) +def test_ci_actionlint_not_on_path(monkeypatch) -> None: + monkeypatch.setattr(shutil, "which", lambda name: None) + result = runner.invoke(app, ["actionlint"]) + assert result.exit_code == 1 + assert "actionlint" in result.output + assert "devcontainer" in result.output + + def test_ci_lint_command(monkeypatch) -> None: called = [] @@ -2361,6 +2374,11 @@ def mock_run(cmd: list[str], *a: Any, **kw: Any) -> subprocess.CompletedProcess[ monkeypatch.setattr(subprocess, "run", mock_run) monkeypatch.setattr(ci_module, "run_subprocess", mock_run) + monkeypatch.setattr( + shutil, + "which", + lambda name: "/usr/local/bin/actionlint" if name == "actionlint" else None, + ) spec = get_check_spec(expected_row) args = [subcmd] @@ -2641,6 +2659,10 @@ def _validate_ci_workflow_parity(workflow_data: dict[str, Any]) -> None: "static", "Install Trivy", ): "Installs the pinned Trivy that the Security Scan step runs, with the lock's installer", + ( + "static", + "Run actionlint", + ): "Runs the pinned actionlint via the docker image, so the gate skips it (#1119)", ( "test", "Install promtool", @@ -2684,6 +2706,13 @@ def _validate_ci_workflow_parity(workflow_data: dict[str, Any]) -> None: ) covered_rows.update(rows) + # The docker:// actionlint step covers the actionlint row without a `run` command (#1119). + for job_info in jobs.values(): + for step in job_info.get("steps", []): + uses = step.get("uses", "") if isinstance(step, dict) else "" + if "kjanat/actionlint" in uses: + covered_rows.add("actionlint") + missing = all_spec_names - covered_rows assert not missing, ( f"CI workflow does not cover all check table rows. Missing: {sorted(missing)}" diff --git a/tests/test_ci_dry_run.py b/tests/test_ci_dry_run.py index 8738e04b13..e1e4a82b4e 100644 --- a/tests/test_ci_dry_run.py +++ b/tests/test_ci_dry_run.py @@ -100,7 +100,12 @@ def test_ci_all_checks_dry_run(recorder: list[list[str]]) -> None: in res.stdout, ) == (True, True, True) for spec in specs: - target_name = spec.cmd[2] if len(spec.cmd) > 2 and spec.cmd[0] == "uv" else spec.cmd[1] + if len(spec.cmd) > 2 and spec.cmd[0] == "uv": + target_name = spec.cmd[2] + elif len(spec.cmd) > 1: + target_name = spec.cmd[1] + else: + target_name = spec.cmd[0] assert target_name in res.stdout # No pass badges or summary table under dry run assert ("✓ pass" in res.stdout, "CI Summary" in res.stdout) == (False, False) diff --git a/tests/test_workflow_contracts.py b/tests/test_workflow_contracts.py index 5db977881a..8131d54821 100644 --- a/tests/test_workflow_contracts.py +++ b/tests/test_workflow_contracts.py @@ -640,12 +640,14 @@ def _uses(node: Any) -> Iterator[str]: def test_every_remote_action_is_pinned_to_a_commit_sha() -> None: """A tag or branch can be moved to other code; a 40-character commit SHA cannot. Local - `./` actions are this repository's own.""" + `./` actions are this repository's own. `docker://` images are pinned by digest (#1119).""" unpinned = [ f"{path}: {ref}" for path in _automation_files() for ref in _uses(_load_workflow(path)) - if not ref.startswith("./") and not re.fullmatch(r"[^@\s]+@[0-9a-f]{40}", ref) + if not ref.startswith("./") + and not re.fullmatch(r"[^@\s]+@[0-9a-f]{40}", ref) + and not (ref.startswith("docker://") and re.search(r"@sha256:[0-9a-f]{64}", ref)) ] assert unpinned == [] @@ -1253,3 +1255,27 @@ def test_a_pull_request_that_changes_an_image_pin_resolves_each_pinned_image() - }, ], ) + + +def test_actionlint_digest_pinned_in_dockerfile_and_ci() -> None: + """The Dockerfile FROM and the ci.yml uses: reference the same digest-pinned image (#1119).""" + dockerfile = Path(".devcontainer/Dockerfile").read_text(encoding="utf-8") + ci_yaml = Path(".github/workflows/ci.yml").read_text(encoding="utf-8") + + dockerfile_match = re.search( + r"FROM\s+(docker\.io/kjanat/actionlint:1\.17\.0@sha256:[0-9a-f]{64})\s+AS\s+actionlint", + dockerfile, + ) + assert dockerfile_match, "Dockerfile FROM actionlint digest-pinned image not found" + + ci_yaml_match = re.search( + r"uses:\s+(docker://docker\.io/kjanat/actionlint:1\.17\.0@sha256:[0-9a-f]{64})", + ci_yaml, + ) + assert ci_yaml_match, "ci.yml uses: actionlint digest-pinned image not found" + + dockerfile_ref = dockerfile_match.group(1) + ci_yaml_ref = ci_yaml_match.group(1).removeprefix("docker://") + assert dockerfile_ref == ci_yaml_ref, ( + f"Dockerfile and ci.yml actionlint digests differ: {dockerfile_ref} != {ci_yaml_ref}" + ) diff --git a/uv.lock b/uv.lock index 163dbdc26d..e4aa8f0049 100644 --- a/uv.lock +++ b/uv.lock @@ -10,12 +10,6 @@ resolution-markers = [ "python_full_version < '3.15' and sys_platform != 'emscripten' and sys_platform != 'win32'", ] -[[package]] -name = "actionlint-py" -version = "1.7.12.25" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/33/75/36ee89db39bb3620d1e46fe1f6ec77d6000d30ff45345699e51b4c850e83/actionlint_py-1.7.12.25.tar.gz", hash = "sha256:83f83be4cd317c79b15cbb7022787513a6994f00bfb2dd8da02fa4e62b4f640d", size = 12438, upload-time = "2026-09-22T16:24:42.477Z" } - [[package]] name = "aiofile" version = "3.12.3" @@ -842,7 +836,6 @@ dependencies = [ [package.dev-dependencies] dev = [ - { name = "actionlint-py" }, { name = "ast-grep-cli" }, { name = "bandit" }, { name = "deptry" }, @@ -941,7 +934,6 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ - { name = "actionlint-py", specifier = "==1.7.12.25" }, { name = "ast-grep-cli", specifier = "==0.51.0" }, { name = "bandit", specifier = "==1.9.4" }, { name = "deptry", specifier = "==0.25.1" },