feat: track ModuleVersion and ConfigVersion in maester-config.json#1760
feat: track ModuleVersion and ConfigVersion in maester-config.json#1760SamErde wants to merge 9 commits into
Conversation
Adds two top-level fields to tests/maester-config.json so consumers can identify which Maester release shipped a given config and when the file's content last changed: - ModuleVersion: stamped from the new module version at publish time - ConfigVersion: CalVer YYYY.MM.DD.N derived from git history of the config file (last commit date plus same-day commit count) A new helper script build/Update-MaesterConfigVersion.ps1 performs surgical regex replacement on the JSON to preserve formatting, and auto-computes ConfigVersion from `git log` when not passed explicitly. The four publish workflows (publish-module, -preview, -manualversionupdate, publish-tests) get fetch-depth: 0, a single-line stamp step, and reordered steps so the version is computed before the test-folder copy. Surfacing: Get-MtMaesterConfig logs both fields via Write-Verbose; the HTML report's ConfigPage displays them alongside the existing ConfigSource chip. Pester tests assert both fields are present in the source file and survive load. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
There was a problem hiding this comment.
Pull request overview
This PR adds version metadata to the default maester-config.json so downstream consumers can identify which Maester release shipped the config and whether the config content has changed between releases. It introduces a build-time stamping script and updates publish workflows, tests, and the HTML report UI to surface these fields.
Changes:
- Add
ModuleVersionandConfigVersiontotests/maester-config.json, with CI stamping during publish. - Add
build/Update-MaesterConfigVersion.ps1to compute/stamp versions (including CalVer-from-git forConfigVersion). - Surface the new fields in
Get-MtMaesterConfigverbose output, the reportConfigPage, and Pester tests; update publish workflows to use full git history.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/maester-config.json | Adds top-level ModuleVersion/ConfigVersion fields to the default config. |
| report/src/pages/ConfigPage.tsx | Displays module/config version metadata alongside config source in the UI. |
| powershell/tests/functions/MaesterConfig.Tests.ps1 | Adds assertions for presence/format of the new JSON fields. |
| powershell/tests/functions/Get-MtMaesterConfig.Tests.ps1 | Verifies version fields survive config loading. |
| powershell/internal/Get-MtMaesterConfig.ps1 | Logs loaded version fields via Write-Verbose. |
| build/Update-MaesterConfigVersion.ps1 | New helper to stamp/compute ModuleVersion and ConfigVersion without reformatting JSON. |
| .github/workflows/publish-tests.yaml | Uses full checkout history and stamps version fields before publishing tests repo. |
| .github/workflows/publish-module.yaml | Uses full checkout history; stamps version fields before copying tests into module. |
| .github/workflows/publish-module-preview.yaml | Uses full checkout history; stamps version fields before copying tests into module. |
| .github/workflows/publish-module-manualversionupdate.yaml | Uses full checkout history; stamps version fields before copying tests into module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying maester with
|
| Latest commit: |
607f169
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4638e0ba.maester.pages.dev |
| Branch Preview URL: | https://feat-trackmaesterconfigversi.maester.pages.dev |
- Update-MaesterConfigVersion.ps1: remove the absent-field insertion paths. The anchor for inserting ConfigVersion depended on ModuleVersion having a trailing comma, which fails if ModuleVersion is the last property. Replaced with a clear error that asks the caller to add missing fields manually — schema changes are now explicit in source control rather than handled by fragile defensive code. - publish-tests.yaml: on workflow_dispatch, github.event.release.tag_name is empty and would have stamped ModuleVersion as "". Added a Resolve latest release tag step that prefers the event tag (release trigger) and falls back to the latest published release via gh release view (workflow_dispatch). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Auto-compute path resolution: resolve to a repo-relative path via `git rev-parse --show-toplevel` and run `git -C <root> log -- <relpath>`, so the script works regardless of CWD or whether ConfigPath was passed as relative or absolute. Previously a non-repo-root CWD or absolute path could leave git unable to find the file's history. - Top-level regex: switch ModuleVersion/ConfigVersion regexes to multiline mode with a leading-whitespace capture group. The match now requires the field to start a line (i.e. be a top-level key), not appear anywhere in the JSON. Indent is preserved via the capture-group backreference. Error messages updated to describe the actual contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Update-MaesterConfigVersion.ps1: tighten the top-level regex from `^[ \t]*` (any leading whitespace) to `^ ` (exactly 2 spaces). The config file uses 2-space indent for top-level keys and 4+ for nested ones, so this rules out accidentally matching a nested object that happens to share a property name. Error messages updated to describe the indent contract. - MaesterConfig.Tests.ps1: add a parity assertion that the source tests/maester-config.json `ModuleVersion` equals powershell/Maester.psd1 `ModuleVersion`. The published artifact gets the real version stamped by CI, but maintainers should keep the source values in sync so a clone shows a sensible number; this test guards against drift. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Use $env:GITHUB_REPOSITORY instead of inline ${{ github.repository }} for
the --repo argument in publish-tests.yaml. Belt-and-suspenders defensive
practice flagged by Copilot review; reading the value from the env var
avoids any chance of pwsh parser interpretation of the owner/repo token
and is the more conventional GHA pattern anyway.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
ModuleVersionandConfigVersionfields at the top oftests/maester-config.jsonso consumers can answer "which Maester release shipped this file?" and "did the file's content actually change between two releases, and when?"ModuleVersionis stamped from the new module version at publish time.ConfigVersionis a CalVer stringYYYY.MM.DD.N— the date of the last commit to the config file, dot-suffixed by the count of commits to the file on that date. Same-day disambiguator covers multiple preview publishes per day.build/Update-MaesterConfigVersion.ps1does both fields in one call. It auto-computesConfigVersionfromgit logwhen no value is passed, so each workflow stamp step is a single line.publish-module,-preview,-manualversionupdate,publish-tests) getfetch-depth: 0, the new stamp step, and a small step reorder so the version is computed beforeCopy-MaesterTestsToPSModule.ps1runs (both source and copy locations end up with identical fields from one edit).Get-MtMaesterConfiglogs both fields viaWrite-Verbose. The HTML report'sConfigPageshows them alongside the existingConfigSourcechip. New Pester assertions cover both fields in the source file and on the loaded object.Why two fields?
Module version alone tells you "which release this is" but not "did the config actually change." A pure counter answers the second question but is hard to read. CalVer with a same-day disambiguator gets both: human-readable, monotonic, and rises only when the file genuinely changes.
Trade-offs are documented in the plan; the main one is that
fetch-depth: 0is now required (the CalVer cannot be computed under shallow clone).Test plan
Invoke-PesteragainstMaesterConfig.Tests.ps1andGet-MtMaesterConfig.Tests.ps1— 13 / 13 pass locallygit restore'd): producesConfigVersion=2026.04.28.1against current history (46 commits, last commit 2026-04-28, single commit that day)publish-module-preview.yamlpublish-tests.yaml