Skip to content

feat: track ModuleVersion and ConfigVersion in maester-config.json#1760

Open
SamErde wants to merge 9 commits into
mainfrom
feat/TrackMaesterConfigVersion
Open

feat: track ModuleVersion and ConfigVersion in maester-config.json#1760
SamErde wants to merge 9 commits into
mainfrom
feat/TrackMaesterConfigVersion

Conversation

@SamErde
Copy link
Copy Markdown
Contributor

@SamErde SamErde commented May 9, 2026

Summary

  • Adds ModuleVersion and ConfigVersion fields at the top of tests/maester-config.json so consumers can answer "which Maester release shipped this file?" and "did the file's content actually change between two releases, and when?"
  • ModuleVersion is stamped from the new module version at publish time. ConfigVersion is a CalVer string YYYY.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.
  • New helper build/Update-MaesterConfigVersion.ps1 does both fields in one call. It auto-computes ConfigVersion from git log when no value is passed, so each workflow stamp step is a single line.
  • Four publish workflows (publish-module, -preview, -manualversionupdate, publish-tests) get fetch-depth: 0, the new stamp step, and a small step reorder so the version is computed before Copy-MaesterTestsToPSModule.ps1 runs (both source and copy locations end up with identical fields from one edit).
  • Loader Get-MtMaesterConfig logs both fields via Write-Verbose. The HTML report's ConfigPage shows them alongside the existing ConfigSource chip. 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: 0 is now required (the CalVer cannot be computed under shallow clone).

Test plan

  • Invoke-Pester against MaesterConfig.Tests.ps1 and Get-MtMaesterConfig.Tests.ps1 — 13 / 13 pass locally
  • Auto-compute path validated end-to-end on the real file (then git restore'd): produces ConfigVersion=2026.04.28.1 against current history (46 commits, last commit 2026-04-28, single commit that day)
  • JSON validity confirmed before and after stamping
  • First preview publish after merge will exercise the new step in publish-module-preview.yaml
  • First stable release after merge will exercise publish-tests.yaml

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>
Copilot AI review requested due to automatic review settings May 9, 2026 16:18
@SamErde SamErde requested a review from a team as a code owner May 9, 2026 16:18
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 9, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ModuleVersion and ConfigVersion to tests/maester-config.json, with CI stamping during publish.
  • Add build/Update-MaesterConfigVersion.ps1 to compute/stamp versions (including CalVer-from-git for ConfigVersion).
  • Surface the new fields in Get-MtMaesterConfig verbose output, the report ConfigPage, 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.

Comment thread build/Update-MaesterConfigVersion.ps1 Outdated
Comment thread .github/workflows/publish-tests.yaml Outdated
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 9, 2026

Deploying maester with  Cloudflare Pages  Cloudflare Pages

Latest commit: 607f169
Status: ✅  Deploy successful!
Preview URL: https://4638e0ba.maester.pages.dev
Branch Preview URL: https://feat-trackmaesterconfigversi.maester.pages.dev

View logs

- 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread build/Update-MaesterConfigVersion.ps1 Outdated
Comment thread build/Update-MaesterConfigVersion.ps1 Outdated
- 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>
@SamErde SamErde requested a review from Copilot May 9, 2026 17:18
@SamErde SamErde self-assigned this May 9, 2026
@SamErde SamErde added maester-test Related to a Maester test awaiting-feedback labels May 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread tests/maester-config.json
Comment thread powershell/tests/functions/MaesterConfig.Tests.ps1
Comment thread build/Update-MaesterConfigVersion.ps1 Outdated
- 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread tests/maester-config.json
Comment thread .github/workflows/publish-tests.yaml Outdated
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@SamErde SamErde requested review from DevClate and merill May 9, 2026 17:43
Comment thread build/Update-MaesterConfigVersion.ps1 Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread build/Update-MaesterConfigVersion.ps1 Outdated
Comment thread build/Update-MaesterConfigVersion.ps1 Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-feedback maester-test Related to a Maester test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants