fix: make daily AIC guardrail exceedance test reliable in CI#38707
Closed
Copilot wants to merge 1 commit into
Closed
fix: make daily AIC guardrail exceedance test reliable in CI#38707Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
… pattern Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
fix: make daily AIC guardrail exceedance test reliable with vi.doMock pattern
fix: make daily AIC guardrail exceedance test reliable in CI
Jun 11, 2026
Copilot created this pull request from a session on behalf of
pelikhan
June 11, 2026 19:08
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a CI flake in the daily AI Credits (AIC) guardrail exceedance test by ensuring Vitest’s module mocking is applied before the source module is loaded, avoiding cases where Node’s ESM cache can bypass the mock for @actions/artifact in GitHub Actions.
Changes:
- Updates the exceedance test to register
vi.doMock("@actions/artifact")before re-importing the source module. - Adds
vi.resetModules()+ a fresh dynamicimport()ofcheck_daily_aic_workflow_guardrail.cjs, and runs assertions against the re-importedmain().
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/check_daily_aic_workflow_guardrail.test.cjs | Reorders mocking + module loading to make the @actions/artifact mock reliably apply in CI. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
main() marks the step failed when the daily AI Credits guardrail is exceededtest was flaky in CI because it calledvi.doMock("@actions/artifact")after the source module was already loaded inbeforeEach. In GitHub Actions,@actions/artifactis ESM-only and Node's native ESM cache can serve the real module, bypassing Vitest's mock registry — causing the reallistArtifacts()to fail silently and leavedaily_effective_workflow_exceededat"false".Changes
check_daily_aic_workflow_guardrail.test.cjs— restructure the guardrail exceedance test to use the canonical Vitestvi.doMockpattern: register the mock first, thenvi.resetModules()+ re-import the source, then calllocalExports.main().This guarantees
import("@actions/artifact")insidegetArtifactClient()consults Vitest's mock registry before Node's native ESM cache.