-
Notifications
You must be signed in to change notification settings - Fork 616
chore: add migration status workflow and job for vitest #6148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds an automated status report for migrating tests from Jest to Vitest by introducing a new script and a scheduled GitHub Actions workflow.
- Introduces
script/vitest-migration-status.mts
to scan test files, calculate migration progress by size and count, and output a markdown report. - Adds
.github/workflows/migration-status.yml
to run the migration script daily (and on demand) and post its summary.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
script/vitest-migration-status.mts | New script to calculate and report Vitest migration status |
.github/workflows/migration-status.yml | New scheduled workflow to run the migration script and publish results |
import fs from 'node:fs' | ||
import glob from 'fast-glob' | ||
|
||
const directory = path.resolve(import.meta.dirname, '..') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import.meta.dirname is not a standard ESM property and may be undefined; consider using path.dirname(new URL(import.meta.url).pathname) to reliably derive the script directory.
const directory = path.resolve(import.meta.dirname, '..') | |
const directory = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..') |
Copilot uses AI. Check for mistakes.
return contents.match(/from 'vitest'/) | ||
}) | ||
|
||
const notMigrated = matches.filter(({filepath}) => { | ||
const contents = fs.readFileSync(filepath, 'utf8') | ||
return !contents.match(/from 'vitest'/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex only matches single-quoted imports; tests importing with double quotes (e.g. from "vitest") will be misclassified. Use a pattern like /from\s+['\"]vitest['\"]/
.
return contents.match(/from 'vitest'/) | |
}) | |
const notMigrated = matches.filter(({filepath}) => { | |
const contents = fs.readFileSync(filepath, 'utf8') | |
return !contents.match(/from 'vitest'/) | |
return contents.match(/from\s+['\"]vitest['\"]/) | |
}) | |
const notMigrated = matches.filter(({filepath}) => { | |
const contents = fs.readFileSync(filepath, 'utf8') | |
return !contents.match(/from\s+['\"]vitest['\"]/) |
Copilot uses AI. Check for mistakes.
return { | ||
filepath, | ||
size: stats.size, | ||
} | ||
}) | ||
.sort((a, b) => { | ||
return b.size - a.size | ||
}) | ||
|
||
const migrated = matches.filter(({filepath}) => { | ||
const contents = fs.readFileSync(filepath, 'utf8') | ||
return contents.match(/from 'vitest'/) | ||
}) | ||
|
||
const notMigrated = matches.filter(({filepath}) => { | ||
const contents = fs.readFileSync(filepath, 'utf8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each file is read twice when classifying migrated vs. not migrated. You could read and cache the file contents once when building matches
to avoid redundant I/O.
return { | |
filepath, | |
size: stats.size, | |
} | |
}) | |
.sort((a, b) => { | |
return b.size - a.size | |
}) | |
const migrated = matches.filter(({filepath}) => { | |
const contents = fs.readFileSync(filepath, 'utf8') | |
return contents.match(/from 'vitest'/) | |
}) | |
const notMigrated = matches.filter(({filepath}) => { | |
const contents = fs.readFileSync(filepath, 'utf8') | |
const contents = fs.readFileSync(filepath, 'utf8') | |
return { | |
filepath, | |
size: stats.size, | |
contents, | |
} | |
}) | |
.sort((a, b) => { | |
return b.size - a.size | |
}) | |
const migrated = matches.filter(({contents}) => { | |
return contents.match(/from 'vitest'/) | |
}) | |
const notMigrated = matches.filter(({contents}) => { |
Copilot uses AI. Check for mistakes.
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinning to a specific commit SHA prevents automatic updates; consider using a semantic version tag (e.g., actions/checkout@v3
) to receive non-breaking improvements.
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Set up Node.js | |
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 |
Copilot uses AI. Check for mistakes.
Inspired by what we did for docs migration tracking, adds a workflow and script to report on our migration status for Vitest. Example output is in a comment below.
Changelog
New
Changed
Removed