Skip to content

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

Merged
merged 1 commit into from
May 30, 2025

Conversation

joshblack
Copy link
Member

@joshblack joshblack commented May 30, 2025

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

  • Add migration status workflow that runs daily
  • Add script for getting vitest migration status

Changed

Removed

Copy link

changeset-bot bot commented May 30, 2025

⚠️ No Changeset found

Latest commit: 5608739

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@joshblack
Copy link
Member Author

Example step summary output:

Vitest Migration

Status

Status by file count

Status by file count

Status by file size

Status by file size

Migrated (39)

Filepath Size (kB)
packages/react/src/DataTable/__tests__/DataTable.test.tsx 29.13kB
packages/react/src/TextInputWithTokens/TextInputWithTokens.test.tsx 17.95kB
packages/react/src/DataTable/__tests__/Pagination.test.tsx 16.07kB
packages/react/src/Banner/Banner.test.tsx 9.41kB
packages/react/src/Stack/__tests__/Stack.test.tsx 9.39kB
packages/react/src/DataTable/__tests__/Table.test.tsx 8.84kB
packages/react/src/UnderlineNav/UnderlineNav.test.tsx 8.52kB
packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx 6.93kB
packages/react/src/Select/Select.test.tsx 6.39kB
packages/react/src/ToggleSwitch/ToggleSwitch.test.tsx 5.92kB
packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsx 4.8kB
packages/react/src/Textarea/Textarea.test.tsx 4.73kB
packages/react/src/CheckboxGroup/CheckboxGroup.test.tsx 4.51kB
packages/react/src/RadioGroup/RadioGroup.test.tsx 4.2kB
packages/react/src/Blankslate/Blankslate.test.tsx 4.15kB
packages/react/src/Radio/Radio.test.tsx 3.96kB
packages/react/src/ProgressBar/ProgressBar.test.tsx 3.47kB
packages/react/src/TabNav/__tests__/TabNav.test.tsx 3.46kB
packages/react/src/ScrollableRegion/ScrollableRegion.test.tsx 2.65kB
packages/react/src/DataTable/__tests__/sorting.test.ts 2.43kB
packages/react/src/DataTable/__tests__/ErrorDialog.test.tsx 2.18kB
packages/react/src/Stack/__tests__/StackItem.test.tsx 2.07kB
packages/react/src/ActionBar/ActionBar.test.tsx 2.06kB
packages/react/src/StateLabel/__tests__/StateLabel.test.tsx 2.05kB
packages/react/src/Tooltip/Tooltip.test.tsx 1.91kB
packages/react/src/SubNav/SubNav.test.tsx 1.85kB
packages/react/src/Timeline/__tests__/Timeline.test.tsx 1.82kB
packages/react/src/Spinner/Spinner.test.tsx 1.77kB
packages/postcss-preset-primer/src/__tests__/preset.test.ts 1.59kB
packages/react/src/RelativeTime/RelativeTime.test.tsx 1.52kB
packages/react/src/CircleBadge/CircleBadge.test.tsx 1.47kB
packages/react/src/FeatureFlags/__tests__/FeatureFlags.test.tsx 1.02kB
packages/react/src/CircleOcticon/CircleOcticon.test.tsx 0.96kB
packages/react/src/ButtonGroup/ButtonGroup.test.tsx 0.72kB
packages/react/src/Truncate/Truncate.test.tsx 0.72kB
packages/react/src/BranchName/__tests__/BranchName.test.tsx 0.55kB
packages/react/src/Breadcrumbs/__tests__/Breadcrumbs.test.tsx 0.51kB
packages/react/src/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx 0.49kB
packages/react/src/Skeleton/__tests__/SkeletonBox.test.tsx 0.35kB

Not Migrated (90)

Filepath Size (kB)
packages/react/src/TreeView/TreeView.test.tsx 52.18kB
packages/react/src/SelectPanel/SelectPanel.test.tsx 37.53kB
packages/react/src/ActionMenu/ActionMenu.test.tsx 30.79kB
packages/react/src/Autocomplete/Autocomplete.test.tsx 20.26kB
packages/react/src/__tests__/ThemeProvider.test.tsx 17.85kB
packages/react/src/ActionList/Item.test.tsx 17.3kB
packages/react/src/NavList/NavList.test.tsx 17.19kB
packages/react/src/__tests__/exports.test.ts 15.04kB
packages/react/src/FormControl/__tests__/FormControl.test.tsx 14.54kB
packages/react/src/Overlay/Overlay.test.tsx 13.91kB
packages/react/src/SegmentedControl/SegmentedControl.test.tsx 13.48kB
packages/react/src/Button/__tests__/Button.test.tsx 11.49kB
packages/react/src/TextInput/TextInput.test.tsx 10.5kB
packages/react/src/LabelGroup/LabelGroup.test.tsx 9.49kB
packages/react/src/Dialog/Dialog.test.tsx 8.87kB
packages/react/src/experimental/SelectPanel2/SelectPanel.test.tsx 8.54kB
packages/react/src/__tests__/Pagination/PaginationModel.test.tsx 8.48kB
packages/react/src/__tests__/CheckboxOrRadioGroup.test.tsx 7.15kB
packages/react/src/__tests__/hooks/useMnemonics.test.tsx 7.14kB
packages/react/src/PageLayout/PageLayout.test.tsx 7.01kB
packages/react/src/experimental/UnderlinePanels/UnderlinePanels.test.tsx 7.01kB
packages/react/src/ActionList/Group.test.tsx 6.82kB
packages/react/src/ActionList/ActionList.test.tsx 6.46kB
packages/react/src/ConfirmationDialog/ConfirmationDialog.test.tsx 6.1kB
packages/react/src/DialogV1/Dialog.test.tsx 5.71kB
packages/react/src/Details/__tests__/Details.test.tsx 5.06kB
packages/react/src/Checkbox/Checkbox.test.tsx 4.74kB
packages/react/src/Heading/__tests__/Heading.test.tsx 4.63kB
packages/react/src/PageHeader/PageHeader.test.tsx 4.57kB
packages/react/src/Token/__tests__/Token.test.tsx 4.5kB
packages/react/src/__tests__/deprecated/ActionMenu.test.tsx 4.06kB
packages/react/src/__tests__/storybook.test.tsx 3.86kB
packages/react/src/KeybindingHint/KeybindingHint.test.tsx 3.81kB
packages/react/src/Portal/Portal.test.tsx 3.7kB
packages/react/src/hooks/__tests__/useSlots.test.tsx 3.47kB
packages/react/src/__tests__/hooks/useMenuInitialFocus.test.tsx 3.34kB
packages/react/src/live-region/__tests__/AriaStatus.test.tsx 3.21kB
packages/react/src/AvatarStack/AvatarStack.test.tsx 3.21kB
packages/react/src/hooks/__tests__/useMedia.test.tsx 2.98kB
packages/react/src/__tests__/hooks/useOpenAndCloseFocus.test.tsx 2.97kB
packages/react/src/ActionList/Description.test.tsx 2.87kB
packages/react/src/internal/utils/__tests__/toggleStyledComponent.test.tsx 2.74kB
packages/react/src/live-region/__tests__/Announce.test.tsx 2.56kB
packages/react/src/Text/Text.test.tsx 2.54kB
packages/react/src/__tests__/hooks/useResponsiveValue.test.tsx 2.54kB
packages/react/src/ActionList/Heading.test.tsx 2.52kB
packages/react/src/hooks/__tests__/useControllableState.test.tsx 2.45kB
packages/react/src/InlineMessage/InlineMessage.test.tsx 2.43kB
packages/react/src/live-region/__tests__/AriaAlert.test.tsx 2.28kB
packages/react/src/PointerBox/PointerBox.test.tsx 2.16kB
packages/react/src/CounterLabel/CounterLabel.test.tsx 2.12kB
packages/react/src/deprecated/utils/createSlots.test.tsx 2.09kB
packages/react/src/Header/Header.test.tsx 2.09kB
packages/react/src/hooks/__tests__/useSyncedState.test.tsx 2.05kB
packages/react/src/__tests__/hooks/useOnOutsideClick.test.tsx 2.02kB
packages/react/src/Hidden/Hidden.test.tsx 1.96kB
packages/react/src/Avatar/Avatar.test.tsx 1.91kB
packages/react/src/FormControl/__tests__/useFormControlForwardedProps.test.tsx 1.85kB
packages/react/src/Popover/Popover.test.tsx 1.82kB
packages/react/src/SplitPageLayout/SplitPageLayout.test.tsx 1.77kB
packages/react/src/Link/__tests__/Link.test.tsx 1.77kB
packages/react/src/deprecated/UnderlineNav/UnderlineNav.test.tsx 1.76kB
packages/react/src/__tests__/SideNav.test.tsx 1.74kB
packages/react/src/internal/utils/__tests__/hasInteractiveNodes.test.ts 1.7kB
packages/react/src/Box/Box.test.tsx 1.55kB
packages/react/src/__tests__/BaseStyles.test.tsx 1.49kB
packages/react/src/internal/utils/__tests__/toggleSxComponent.test.tsx 1.46kB
packages/react/src/Flash/__tests__/Flash.test.tsx 1.45kB
packages/react/src/__tests__/hooks/useProvidedStateOrCreate.test.tsx 1.32kB
packages/react/src/Label/Label.test.tsx 1.29kB
packages/react/src/__tests__/Pagination/Pagination.test.tsx 1.27kB
packages/react/src/__tests__/useSafeTimeout.test.tsx 1.25kB
packages/react/src/__tests__/deprecated/ActionList.test.tsx 1.23kB
packages/react/src/__tests__/theme.test.ts 1.15kB
packages/react/src/__tests__/Caret.test.tsx 1.14kB
packages/react/src/__tests__/filterObject.test.ts 1.07kB
packages/react/src/__tests__/hooks/useAnchoredPosition.test.tsx 1.02kB
packages/react/src/internal/utils/__tests__/getResponsiveAttributes.test.ts 0.95kB
packages/react/src/utils/__tests__/warning.test.ts 0.85kB
packages/react/src/__tests__/deprecated/FilteredSearch.test.tsx 0.68kB
packages/react/src/__tests__/SubNavLink.test.tsx 0.68kB
packages/react/src/experimental/SelectPanel2/__tests__/SelectPanelLoading.test.tsx 0.68kB
packages/react/src/Octicon/Octicon.test.tsx 0.61kB
packages/react/src/deprecated/UnderlineNav/UnderlineNavLink.test.tsx 0.57kB
packages/react/src/__tests__/hooks/useOnEscapePress.test.tsx 0.53kB
packages/react/src/Pagehead/Pagehead.test.tsx 0.52kB
packages/react/src/utils/__tests__/invariant.test.ts 0.45kB
packages/react/src/FormControl/__tests__/FormControl.Validation.test.tsx 0.44kB
packages/react/src/__tests__/themeGet.test.ts 0.42kB
packages/react/src/experimental/Skeleton/__tests__/SkeletonText.test.tsx 0.31kB

@joshblack joshblack added the skip changeset This change does not need a changelog label May 30, 2025
@joshblack joshblack marked this pull request as ready for review May 30, 2025 17:49
@Copilot Copilot AI review requested due to automatic review settings May 30, 2025 17:49
@joshblack joshblack requested a review from a team as a code owner May 30, 2025 17:49
@joshblack joshblack requested a review from jonrohan May 30, 2025 17:49
Copy link
Contributor

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 94.53 KB (0%)
packages/react/dist/browser.umd.js 94.63 KB (0%)

Copy link
Contributor

@Copilot 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

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, '..')
Copy link
Preview

Copilot AI May 30, 2025

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.

Suggested change
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.

Comment on lines +35 to +40
return contents.match(/from 'vitest'/)
})

const notMigrated = matches.filter(({filepath}) => {
const contents = fs.readFileSync(filepath, 'utf8')
return !contents.match(/from 'vitest'/)
Copy link
Preview

Copilot AI May 30, 2025

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['\"]/.

Suggested change
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.

Comment on lines +24 to +39
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')
Copy link
Preview

Copilot AI May 30, 2025

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.

Suggested change
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.

Comment on lines +11 to +13
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
Copy link
Preview

Copilot AI May 30, 2025

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.

Suggested change
- 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.

@joshblack joshblack enabled auto-merge May 30, 2025 17:53
@joshblack joshblack added this pull request to the merge queue May 30, 2025
Merged via the queue into main with commit 5a84cd3 May 30, 2025
41 of 43 checks passed
@joshblack joshblack deleted the chore/add-vitest-migration-status branch May 30, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset This change does not need a changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants