Skip to content

fix(scripts): standardize timestamp in Test-CopyrightHeaders.ps1 to use Get-StandardTimestamp#1278

Merged
WilliamBerryiii merged 5 commits intomainfrom
fix/995-standardize-timestamp-copyright-headers
Apr 2, 2026
Merged

fix(scripts): standardize timestamp in Test-CopyrightHeaders.ps1 to use Get-StandardTimestamp#1278
WilliamBerryiii merged 5 commits intomainfrom
fix/995-standardize-timestamp-copyright-headers

Conversation

@chaosdinosaur
Copy link
Copy Markdown
Collaborator

Pull Request

Description

Replaced Get-Date -Format "o" (local-offset timestamp) in Test-CopyrightHeaders.ps1 with Get-StandardTimestamp from CIHelpers.psm1. The script already imports CIHelpers.psm1 at line 77, so no additional import was needed. This produces genuine UTC timestamps ending in Z instead of local-offset timestamps.

Added a Pester test that verifies the result JSON contains a UTC ISO 8601 timestamp ending in Z.

Related Issue(s)

Fixes #995

Type of Change

Select all that apply:

Code & Documentation:

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Infrastructure & Configuration:

  • GitHub Actions workflow
  • Linting configuration (markdown, PowerShell, etc.)
  • Security configuration
  • DevContainer configuration
  • Dependency update

AI Artifacts:

  • Reviewed contribution with prompt-builder agent and addressed all feedback
  • Copilot instructions (.github/instructions/*.instructions.md)
  • Copilot prompt (.github/prompts/*.prompt.md)
  • Copilot agent (.github/agents/*.agent.md)
  • Copilot skill (.github/skills/*/SKILL.md)

Other:

  • Script/automation (.ps1, .sh, .py)
  • Other (please describe):

Testing

  • Verified Get-Date -Format "o" replaced with Get-StandardTimestamp at line 242.
  • Added Pester test verifying the timestamp field matches ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.*Z$.
  • npm run lint:ps passed.
  • npm run test:ps passed (45 tests for this file).

Checklist

Required Checks

  • Documentation is updated (if applicable) (N/A — no docs change needed)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

Required Automated Checks

The following validation commands must pass before merging:

  • Markdown linting: npm run lint:md
  • Spell checking: npm run spell-check
  • Frontmatter validation: npm run lint:frontmatter
  • Skill structure validation: npm run validate:skills
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps
  • Plugin freshness: npm run plugin:generate

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues (N/A — no dependency changes)
  • Security-related scripts follow the principle of least privilege (N/A — no privilege changes)

Additional Notes

This is part of the timestamp standardization series (issues #994-#1002). The prerequisite Get-StandardTimestamp function was merged in #993. CIHelpers.psm1 was already imported by this script, so the change is a direct expression swap with no import changes required.

…se Get-StandardTimestamp

Replace Get-Date -Format "o" with Get-StandardTimestamp from CIHelpers.psm1
for consistent UTC ISO 8601 timestamps. Add Pester test for timestamp format.

Fixes #995
@chaosdinosaur chaosdinosaur requested a review from a team as a code owner April 2, 2026 15:48
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.71%. Comparing base (11a483f) to head (68b3c23).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1278      +/-   ##
==========================================
- Coverage   87.72%   87.71%   -0.02%     
==========================================
  Files          61       61              
  Lines        9320     9320              
==========================================
- Hits         8176     8175       -1     
- Misses       1144     1145       +1     
Flag Coverage Δ
pester 85.31% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
scripts/linting/Test-CopyrightHeaders.ps1 90.09% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@katriendg katriendg left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Automated Review

Overview

The production change is correct and minimal — a clean, single-expression swap from Get-Date -Format "o" to Get-StandardTimestamp, with no unintended side effects. The PR aligns directly with issue #995, the description is complete, and the template is filled in properly.

Two minor issues were found in the new Pester test; the production script itself has no concerns.


Issue Alignment ✅

Issue #995 asks to replace Get-Date -Format "o" with Get-StandardTimestamp in Test-CopyrightHeaders.ps1 and update the corresponding Pester tests. The PR does exactly this — one production line changed, one test added. No scope creep; no missing requirements.


PR Template Compliance ✅

All required sections are filled in. The checked boxes (Bug fix, Script/automation) match the actual changes. Testing and checklist sections are complete.


Coding Standards

scripts/tests/linting/Test-CopyrightHeaders.Tests.ps1 — 2 findings (inline comments attached)

  1. Test name (line 601) — does not follow the given_context_when_action_then_expected or descriptive snake_case convention required by pester-testing.instructions.md. The current name describes the implementation mechanism rather than the observable behaviour.

  2. .ToString('o') call (line 603) — semantically misleading when applied to a JSON-deserialized string. The assertion should cast explicitly to [string] and match directly, avoiding reliance on implicit PowerShell version-specific DateTime coercion in ConvertFrom-Json.


Code Quality ✅

No bugs, logic errors, security concerns, or performance issues. The production change is a straightforward, safe substitution.


Action Items

  1. Rename the test to describe the observable outcome rather than the implementation detail (e.g., 'Timestamp field contains a UTC ISO 8601 value ending in Z').
  2. Replace $results.timestamp.ToString('o') with [string]$results.timestamp to make the assertion version-independent and unambiguous.

Generated by PR Review for issue #1278

- rename test to behavior-focused sentence matching codebase convention
- replace ConvertFrom-Json assertion with raw JSON match to avoid PS7 DateTime coercion
- follow established pattern from Test-ActionVersionConsistency.Tests.ps1

🔧 - Generated by Copilot
@WilliamBerryiii WilliamBerryiii merged commit 84ddd5d into main Apr 2, 2026
40 checks passed
@github-actions github-actions bot mentioned this pull request Apr 2, 2026
chaosdinosaur added a commit that referenced this pull request Apr 3, 2026
Use raw JSON string matching instead of ConvertFrom-Json with property
access, avoiding PowerShell 7 DateTime coercion that makes direct regex
matching unreliable. Pattern follows the established approach from
Test-CopyrightHeaders.Tests.ps1 (#1278).
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.

Standardize timestamp in Test-CopyrightHeaders.ps1 to use Get-StandardTimestamp

4 participants