Conversation
Run `packer init` and `packer build` for one template directory and render what it produced. The build is streamed with `tee` rather than captured through `shell.run`, which only prints the output once the command has returned: an image build runs for minutes, so a silent job log is not an option. The artifacts and the errors are read from the two sections Packer closes with, so the summary names the AMIs a build created without the template needing a manifest post-processor. `-machine-readable` does expose them as structured records, unlike `packer validate`, but it replaces the readable log the same job needs.
Resolve the build directories to build and the variable files they build with, as one matrix entry each. `changed` mode walks up from each changed directory to the nearest one holding a Packer template, so editing a variable file under `<build>/vars/` still builds `<build>`. `all` mode enumerates the build directories instead, for a scheduled or manually dispatched full build. A build directory with a `vars/` subdirectory yields one target per variable file in it, which is how one directory turns into several builds. Any `*.auto.pkrvars.hcl` beside the template stays shared, since Packer loads it for every one of them.
Wire the target resolution, the build matrix, and the report together, so one caller serves a push, a schedule, and a manual dispatch: `scope` defaults to `auto`, which builds the changed directories on a `push` or a `pull_request` and everything on any other event. Each target takes its own concurrency group, so a scheduled full build and the build of a freshly merged change never overlap on the same image, and `max_parallel` keeps a full build clear of cloud quotas. The report follows the Terraform plan and apply workflows: every target collects a `headline` and a `details` section, which `github.matrix-report` publishes as one table plus a collapsed section per build.
👋 Welcome! Looks like this is your first pull request.Hey, thanks for your contribution! Please give us a bit of time to review it. 😄 Please check out our contributing guidelines. |
|
Heads-up that is not about this pull request: the repository's actionlint / check-jsonschema lint is currently broken on
jobs:
integration:
uses: tedilabs/github-actions/.github/workflows/github-actions.integration.yaml@mainwhich is itself. It no longer has Ran the missing checks locally instead, all clean: |
👋 Background
Building the images, as the counterpart to the checks in #1. One caller has to serve three events — a push that builds only what changed, a schedule that builds everything, and a manual dispatch — and one build directory has to be able to produce several images from several variable files.
🔗 Related Issues
packer.*check actions and the integration workflow)github.matrix-reportgrowsdetails,headline, andpr_numberthere, and none of the three is onmainyet. This should merge after feat: add Terraform plan and apply workflows for workspaces #5.⚙️ Description
New composite actions
packer.buildpacker initthenpacker buildfor one template directory, with a summary of what it producedpacker.build-targetspacker.buildstreams the build withteeinstead of going throughshell.run.shell.runredirects both streams to files and prints them once the command returns, which is right for a check that takes seconds and wrong for an image build that takes minutes.It reads the artifacts and the errors from the two sections Packer closes with, so a summary can name the AMIs a build created without the template carrying a
manifestpost-processor. Worth noting against the discussion on #1:packer builddoes expose these as structured records under-machine-readable, unlikepacker validate. It is still not used, for a different reason — it replaces the human-readable log that the same job needs.packer.build-targetsresolves targets in two modes.changedwalks up from each changed directory to the nearest one holding a Packer template, so editing a variable file under<build>/vars/still builds<build>.allenumerates the build directories underbuilds_dir.Variants
A build directory with a
vars/subdirectory yields one target per variable file in it:A directory without
vars/is built once with no-var-file, so nothing has to change for a build that has only one variant today.vars_dirandvars_patternmake the convention configurable, andbuilds/variantsfilter it for a manual dispatch.New reusable workflow
packer.templates.build.yamltargets,build,reportscopedefaults toauto: changed directories on apushor apull_request, everything on any other event. That is what lets a single caller cover all three events:Each target gets its own concurrency group, so a scheduled full build and the build of a freshly merged change never overlap on the same image.
max_paralleldefaults to4: images are built on real instances, so a full build should stay clear of cloud quotas rather than take whatever the runner limits allow.✅ Verification
yamllint,actionlint, andshellcheckpass.The target resolver was run standalone against a fixture tree (two build directories, one with two variable files, one directory without a template, one unrelated directory):
allchangedfrombuilds/ubuntu-2604/varsbuilds/ubuntu-2604, both variantschangedfrom unrelated directoriesbuilds+variantsfiltersallover an emptybuilds/The build action's parsing was run against real
packer buildoutput (packer 1.16.0, null builder) and two fixtures for the AMI shapes:1 artifact(s), artifact line in the summaryFailed,> [!CAUTION]callout with the error lineamazon-ebswith two regionsami-lines kept under the-->line🚨 To Reviewers
Three things worth a second opinion.
namein the matrix entry. The Terraform workflows repeat${{ matrix.project }}${{ matrix.workspace && format(' / {0}', matrix.workspace) || '' }}at each use. Here the resolver emitsnameinstead, because the build workflow needs it in four places. It is a small deviation from the existing style; say the word and I will repeat the expression instead.pushafter a merge there is no pull request context, so the report goes to the job summary unless the caller passespr_number.github.pr.head-runfrom feat: add Terraform plan and apply workflows for workspaces #5 could resolve the merged pull request the wayterraform.workspaces.applydoes, but it requires aworkflowto look a run up in, which a build workflow has no use for. Easy to add once feat: add Terraform plan and apply workflows for workspaces #5 lands if you want the comment.packer buildruns, but theamazon-ebscases could not be: they need AWS credentials. Those two rows are hand-written fixtures in the documented format, so they carry some hallucination risk until a real build confirms them.