fix(setup-python-runner): honour use-lxd input to skip LXD installation - #166
Conversation
The setup-python-runner composite action never declared a use-lxd input, so its Setup LXD step only checked runner.os == 'Linux' and always installed LXD on Linux runners regardless of the caller's intent. test-python.yaml also declared a use-lxd workflow input but never passed it through to the setup-python-runner action calls. Add the use-lxd input to setup-python-runner, gate the Setup LXD step on it, and wire it through from test-python.yaml's three call sites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Default use-lxd to true in both setup-python-runner and test-python.yaml to preserve existing behavior for callers that don't set the input explicitly. Add self-tests to verify the use-lxd input is actually honored: - self-test-setup.yaml: a new 'no-lxd' job calls the action with use-lxd: false and asserts /snap/bin/lxc is absent. - self-test-qa.yaml: a new test-python-no-lxd caller job passes use-lxd: false through the reusable test-python.yaml workflow, and a verify-lxd-setup job inspects the run's job/step API to confirm the 'Setup LXD' step never succeeds for that caller while it does succeed for test-python-custom (use-lxd: true). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the setup-python-runner composite action and related workflows so the use-lxd input actually controls whether LXD is installed on Linux runners, and adds regression coverage to prevent reintroducing the issue.
Changes:
- Add
use-lxdinput tosetup-python-runnerand gate the “Setup LXD” step on it. - Wire
use-lxdthrough.github/workflows/test-python.yamland default it totrueto preserve current behavior. - Add self-test/regression workflows validating both the disabled path and step-level outcomes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| setup-python-runner/action.yaml | Introduces use-lxd input and conditions the LXD setup step on it. |
| .github/workflows/test-python.yaml | Defaults use-lxd to true and passes it through to the setup action across jobs. |
| .github/workflows/self-test-setup.yaml | Adds a self-test job validating use-lxd: false avoids installing LXD. |
| .github/workflows/self-test-qa.yaml | Adds a regression run plus verification logic to confirm the “Setup LXD” step outcome differs when toggling use-lxd. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pin actions/checkout to a hash, disable credential persistence, and add an explicit job-level permissions block to satisfy zizmor's unpinned-uses, excessive-permissions, and artipacked audits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
test-python.yaml pins setup-python-runner to @main, so the test-python-no-lxd/verify-lxd-setup jobs added in the previous commit could never pass within this PR (main lacks the use-lxd input until merge). The no-lxd job in self-test-setup.yaml already exercises the fix directly against the local action. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review feedback: comparing inputs.use-lxd to the string 'true' is fragile if the value isn't normalized. Use fromJSON() to coerce the composite action's string input into a real boolean before evaluating the condition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
setup-python-runner/action.yaml:29
use-lxdis declared as a boolean input, but the step condition parses it withfromJSON(...). If the action runtime provides typed boolean inputs,fromJSONcan fail due to a type mismatch; if it provides strings,fromJSONis unnecessary complexity. Prefer a condition that works for both boolean and string representations without JSON parsing.
- name: Setup LXD
if: ${{ runner.os == 'Linux' && fromJSON(inputs.use-lxd) }}
uses: canonical/setup-lxd@v1
.github/workflows/self-test-setup.yaml:122
- This self-test assumes
/snap/bin/lxcis absent on the runner whenuse-lxd: false. If the runner image ever ships with LXD/LXC preinstalled, the test will fail even though the action correctly skipped installation. Capture the pre-state and only fail when the action introduces/snap/bin/lxcon a previously-clean runner.
- uses: ./setup-python-runner
with:
use-lxd: false
- name: Check lxd is not installed
run: |
if [ -e /snap/bin/lxc ]; then
echo "::error::/snap/bin/lxc should not exist when use-lxd is false"
exit 1
fi
|
Focal LXD 6 failure is external, handled with: canonical/setup-lxd#41 |
use-lxd: falsehad no effect:setup-python-runnernever declared ause-lxdinput (its "Setup LXD" step only checkedrunner.os == 'Linux'), andtest-python.yamlnever passed itsuse-lxdinput through to the action.Adds the input to the action, gates the LXD setup step on it, wires it through from
test-python.yaml, and defaults it totrueeverywhere to preserve current behaviour. Adds regression self-tests.