Skip to content

[test] do not merge: Packer and Ansible checks via shell.run - #17

Closed
posquit0 wants to merge 7 commits into
mainfrom
test/packer-ansible-checks
Closed

posquit0 wants to merge 7 commits into
mainfrom
test/packer-ansible-checks

Conversation

@posquit0

Copy link
Copy Markdown
Member

Temporary PR to run the aligned packer.fmt, packer.validate, and ansible.ansible-lint actions from #1 on a real runner: passing, failing, and empty (skipped) targets for each, asserting stdout/exitcode/skipped. Will be closed after the run. Not meant to be merged.

- Check formatting with `packer fmt -check -diff`
- Support `recursive` input to also check subdirectories (default `true`)
- Add the diff to the job summary on failure via github.step-summary
- Install required plugins with `packer init` and run `packer validate`
- Export `github_token` as `PACKER_GITHUB_API_TOKEN` to avoid anonymous
  GitHub API rate limits when downloading plugins
- Add init/validate output to the job summary on failure via github.step-summary
- Run `ansible-lint` from the project directory so `.ansible-lint` and
  `ansible.cfg` are discovered as usual
- Optionally install Galaxy collections from `requirements_file` outside
  the checkout and expose them via `ANSIBLE_COLLECTIONS_PATH`
- Rely on ansible-lint's built-in GitHub Actions annotations
- Add findings to the job summary on failure via github.step-summary
- Detect changed Packer template directories under builds/**
- Run packer fmt and packer init/validate per directory with
  continue-on-error so all checks run
- Collect per-directory outcomes via github.matrix-report and publish
  an aggregated report to the job summary and a sticky PR comment
- Add pr_comment_enabled input (default true) to toggle the PR comment
- Write default tool versions to a throwaway global mise config pointed at
  by `MISE_GLOBAL_CONFIG_FILE`, so repository pins in `mise.toml` /
  `.tool-versions` win and a self-hosted runner's config is left alone
- Export `AWS_DEFAULT_REGION` so Amazon builders validate without AWS config
- Install python via mise and `ansible-lint` via pip (version pinnable)
- Lint the Ansible project directory with the ansible.ansible-lint action
- Optionally install Galaxy collections from `requirements_file`
- Write default tool versions to a throwaway global mise config pointed at
  by `MISE_GLOBAL_CONFIG_FILE`, so repository pins in `mise.toml` /
  `.tool-versions` win and a self-hosted runner's config is left alone
…-action interface

- Run `packer fmt`, `packer init`, `packer validate`, `ansible-galaxy
  collection install`, and `ansible-lint` through `shell.run`, and expose
  `skipped`, `stdout`, `stderr`, and `exitcode` like the Terraform and
  GitHub Actions checks
- Resolve the target in a dedicated step: strip the trailing slash, skip
  with a notice when the directory holds no Packer HCL, template, or YAML
  files, and print the tool version there so it stays out of `stdout`
- Guard the failure summary steps with `always()`, since the implicit
  `success()` otherwise skips them after the check fails
- Report `skipped` and drop disabled checks in the Packer integration
  report, as the Terraform integration workflows do
@github-actions

Copy link
Copy Markdown

GitHub Actions Integration

Repository actionlint check-jsonschema (workflows) check-jsonschema (actions)
tedilabs/github-actions

✅ All 1 passed.

@posquit0

Copy link
Copy Markdown
Member Author

Verified on ubuntu-latest (run 35453505149) with the actions from #1: packer fmt passes on a formatted template, fails with exitcode=3 and the diff in stdout on an unformatted one, and skips an empty directory; packer init + packer validate pass on a null-builder template with stdout captured and skip an empty directory; ansible-lint passes on a clean playbook, fails with exitcode=2 and the findings in the captured output, and skips a directory without YAML files. Trailing slashes are honored. 11/11 assertions passed. Closing; nothing here is meant to merge.

@posquit0 posquit0 closed this Sep 19, 2026
@posquit0
posquit0 deleted the test/packer-ansible-checks branch September 19, 2026 16:00
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.

1 participant