feat: add Packer composite actions and integration workflow - #1
Conversation
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
1074083 to
093e32b
Compare
2538562 to
1e50317
Compare
GitHub Actions Integration
✅ All 1 passed. |
1e50317 to
87091b8
Compare
87091b8 to
1b26eea
Compare
1b26eea to
1c0468d
Compare
|
Rebased onto
Runner verification: #17 (closed) ran all three actions from this branch against passing, failing, and empty fixtures, run https://github.com/tedilabs/github-actions/actions/runs/35453505149. 11/11 assertions passed, including |
1c0468d to
425a22c
Compare
|
Rebased onto
Runner verification: #28 (closed) ran all three against failing fixtures, run https://github.com/tedilabs/github-actions/actions/runs/35524387836:
|
- 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
- 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
…rface - Run `packer fmt`, `packer init`, and `packer validate` 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 or template 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
- Add `annotations_enabled` (default `true`) on the pattern of the Terraform and GitHub Actions checks - `packer.fmt` reads file and hunk line from the captured diff; `packer.validate` pairs each `Error:` line with its `on <file> line <n>` line; both print repository-relative paths already
425a22c to
e0c800d
Compare
|
Split the Ansible half out into #30 ( |
…on-less diagnostics - Add `syntax_only` (default `false`), which passes `-syntax-only` and skips `packer init`, since a syntax-only check resolves no plugins and `packer init` would otherwise fail on a runner that cannot reach the plugin registry - Annotate a diagnostic that names no file, such as `Unset variable`, without a location instead of dropping it: the summary was only ever emitted once an `on <file> line <n>` line followed it - Correct the comment on the annotation step. `packer validate` does take `-machine-readable`, but it is the legacy stream format, which packs every diagnostic into one `ui,error` record as the same text with `\n` escaped and commas replaced by `%!(PACKER_COMMA)`, and carries no file or line field
|
Good catch on It is the legacy Packer 1.x stream format ( While testing I found a real gap: a diagnostic that names no file, such as On the other flags — Not wired into Verified: annotator re-run against real |
Without `install_args`, `mise install` resolves every tool in the calling repository's mise config. `packer-templates` pins `terraform` alongside `packer` in `.tool-versions`, so each leg of the matrix was installing Terraform it never runs, as the Terraform integration workflows already avoid by naming the tools they need.
|
Right — The cost was real: One difference from the Terraform integration workflows I left alone: they also pass |
…se config Drop the `packer_version` input and the throwaway global mise config it was written to, matching the Terraform integration workflows since #18: the tools and their versions come from the calling repository's own `mise.toml` or `.tool-versions`, with no workflow-side default. Pass the build directory as `working_directory` as well, so a `mise.toml` placed there overrides the repository-wide one.
|
Agreed on both counts — 97c91d3.
Companion change on the consumer side: tedilabs/packer-templates#17 folds |
CI building blocks for the
packer-templatesrepository, restructured to follow the same convention as theterraform.*actions and integration workflows: the logic lives in composite actions and the workflows only wire them together.Note
The Ansible half of this pull request (
ansible.ansible-lintandansible.integration.yaml) has been split out into #30 so it can be reviewed and adopted on its own. Nothing was shared between the two halves, so the Packer files here are unchanged by the split.New composite actions
packer.fmtpacker fmt -check -diff, with an optionalrecursive(defaulttrue)packer.validatepacker initfollowed bypacker validateEach takes
target_dirand, on failure, appends its output to the job summary throughgithub.step-summary, so a failed check is readable without opening the raw log.packer.validateexports itsgithub_tokeninput asPACKER_GITHUB_API_TOKEN, which the plugin installer uses to avoid the anonymous GitHub API rate limit.New reusable workflow
packer.templates.integration.yamlchanged,lint,reportbuilds/**, then fan outfmtandvalidateper directorypacker.templates.integration.yamlmirrorsterraform.modules.integration.yaml: checks run withcontinue-on-errorso one failure does not hide the others,github.matrix-reportcollects each directory's outcome, and thereportjob publishes a single table to the job summary and a sticky pull request comment.pr_comment_enabled(defaulttrue) turns the comment off.Changes from the first revision of this PR
The original revision added reusable workflows that each carried their own inline logic. The current one differs in these ways.
packer-templatesand any later caller share the same implementation.hashicorp/setup-packer. Default versions go into a throwaway config underRUNNER_TEMPthatMISE_GLOBAL_CONFIG_FILEpoints at, so a repository's ownmise.tomlor.tool-versionsstill wins and a self-hosted runner's real global config is never overwritten. This matters here:packer-templatespinspacker 1.15.4in.tool-versions, and the previous approach would have silently overridden it.packer_target_diris nowtarget_dir, matching every other<tool>.<action>in this repository.Validation
yamllint(repo config),actionlint, andshellcheckpass.Beyond the linters, every action's script was executed directly against a checkout of
tedilabs/packer-templates:packer fmton a formatted directorypacker fmton a deliberately unformatted copypacker initandpacker validateonbuilds/ubuntu-2604-dockerpacker validateon a directory holding no templateNotes
aws_regiondefaults tous-east-1and is exported asAWS_DEFAULT_REGIONso an Amazon builder that does not setregionexplicitly still validates on a runner with no AWS configuration. No credentials are involved. Worth flagging that the currentpacker-templatesbuilds validated cleanly without it, so this is defensive rather than something reproduced as necessary. It can be dropped if you would rather not carry the input.Consumed by
tedilabs/packer-templates, which calls this workflow from its own integration workflow, alongside the Ansible workflow in #30.