Skip to content

Commit

Permalink
[feature/numeric-dx-refactor] Merge branch 'main' into feature/numeri…
Browse files Browse the repository at this point in the history
…c-dx-refactor
  • Loading branch information
SonicScrewdriver committed Feb 24, 2025
2 parents a0c897d + e53c2ac commit c573b1f
Show file tree
Hide file tree
Showing 310 changed files with 26,317 additions and 19,832 deletions.
19 changes: 19 additions & 0 deletions .changeset/empty-lemons-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"perseus-build-settings": minor
"@khanacademy/perseus-dev-ui": minor
"@khanacademy/kas": minor
"@khanacademy/keypad-context": minor
"@khanacademy/kmath": minor
"@khanacademy/math-input": minor
"@khanacademy/perseus": minor
"@khanacademy/perseus-core": minor
"@khanacademy/perseus-editor": minor
"@khanacademy/perseus-linter": minor
"@khanacademy/perseus-score": minor
"@khanacademy/pure-markdown": minor
"@khanacademy/simple-markdown": minor
---

Tooling:

- Switching to `pnpm`.
14 changes: 14 additions & 0 deletions .changeset/famous-badgers-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@khanacademy/kas": patch
"@khanacademy/kmath": patch
"@khanacademy/math-input": patch
"@khanacademy/perseus": patch
"@khanacademy/perseus-core": patch
"@khanacademy/perseus-editor": patch
"@khanacademy/perseus-linter": patch
"@khanacademy/perseus-score": patch
"@khanacademy/pure-markdown": patch
"@khanacademy/simple-markdown": patch
---

Minor change to how each package embeds it's package version in itself (slightly larger bundle size)
6 changes: 6 additions & 0 deletions .changeset/green-beers-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": patch
"@khanacademy/perseus-core": patch
---

Internal: test that Interactive Graph widgets can render with answerless data
5 changes: 5 additions & 0 deletions .changeset/light-deers-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus-linter": minor
---

Add linter rule to catch images added to content without a URL
5 changes: 0 additions & 5 deletions .changeset/shiny-elephants-allow.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/silent-crabs-fix.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/silly-pianos-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": patch
"@khanacademy/perseus-core": patch
---

Add tests for answerless Dropdown support
5 changes: 5 additions & 0 deletions .changeset/tricky-shoes-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus-editor": minor
---

Export the ContentPreview component from perseus-editor
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"forwardPorts": [6006],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "yarn install"
"postCreateCommand": "pnpm install"

// Configure tool-specific properties.
// "customizations": {},
Expand Down
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ module.exports = {
react: {
version: "detect",
},
"jsx-a11y": {
// Map perseus components to their corresponding DOM elements. This
// helps eslint-plugin-jsx-a11y understand what the underlying
// elements are. For more details, see
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y?tab=readme-ov-file#component-mapping
components: {
NumericInput: "input",
ScrolllessNumberTextField: "input",
BlurInput: "input",
TextInput: "input",
NumberInput: "input",
},
},
},
env: {
"cypress/globals": true,
Expand Down
13 changes: 9 additions & 4 deletions .github/actions/shared-node-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ inputs:
runs:
using: "composite"
steps:
- name: Set up node
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: yarn
cache: pnpm

- name: yarn install
- name: pnpm install
shell: sh
run: yarn install
run: pnpm install ---frozen-lockfile
6 changes: 3 additions & 3 deletions .github/workflows/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ jobs:
## Reviewing notes:
There should only be changes to the `yarn.lock` file in
There should only be changes to the `pnpm-lock.yaml` file in
this PR. Check that there is only 1 `caniuse-lite` package
reference in the `yarn.lock` file (the intent of this
reference in the `pnpm-lock.yaml` file (the intent of this
update is to ensure that `caniuse-lite` is on the latest
version and that there aren't multiple, conflicting
versions that different tools might see).
If everything looks fine, please approve this PR and then
land it (either with the Big Green Merge Button ™️ or by
land it (either with the Big Green Merge Button™️ or by
using `git land <this pr #>` in a terminal).
54 changes: 40 additions & 14 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ jobs:
with:
fetch-depth: 0

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Force Node version
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
# Note that we don't specify 'cache: pnpm' here because we
# don't install node_modules in this workflow/job!

- name: Get changed files
uses: Khan/actions@get-changed-files-v2
Expand All @@ -60,7 +66,7 @@ jobs:
ssh-private-key: ${{ secrets.KHAN_ACTIONS_BOT_SSH_PRIVATE_KEY }}

- name: Verify changeset entries
uses: Khan/[email protected]
uses: Khan/actions@check-for-changeset-v1
with:
changed_files: ${{ steps.match.outputs.filtered }}

Expand All @@ -86,55 +92,55 @@ jobs:

- name: Check formatting
run: |
yarn -s prettier --check .
pnpm prettier --check .
- id: js-files
name: Find .js(x)/.ts(x) changed files
uses: Khan/actions@filter-files-v1
with:
changed-files: ${{ steps.changed.outputs.files }}
extensions: ".js,.jsx,.ts,.tsx"
files: "yarn.lock"
files: "pnpm-lock.yaml"

- id: eslint-reset
uses: Khan/actions@filter-files-v1
name: Files that would trigger a full eslint run
with:
changed-files: ${{ steps.changed.outputs.files }}
files: ".eslintrc.js,package.json,yarn.lock,.eslintignore"
files: ".eslintrc.js,package.json,pnpm-lock.yaml,.eslintignore"

# Linting / type checking
- name: Eslint
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.eslint-reset.outputs.filtered }}
full: yarn lint packages
full: pnpm lint packages
limited-trigger: ${{ steps.js-files.outputs.filtered }}
limited: yarn lint {}
limited: pnpm lint {}

- name: Typecheck
if: (success() || failure()) && steps.js-files.outputs.filtered != '[]'
run: yarn typecheck
run: pnpm typecheck

- name: Build types
if: (success() || failure()) && steps.js-files.outputs.filtered != '[]'
run: yarn build:types
run: pnpm build:types

# Run tests for our target matrix
- id: jest-reset
uses: Khan/actions@filter-files-v1
name: Files that would trigger a full jest run
with:
changed-files: ${{ steps.changed.outputs.files }}
files: "jest.config.js,package.json,yarn.lock,test.config.js,test.transform.js"
files: "jest.config.js,package.json,pnpm-lock.yaml,test.config.js,test.transform.js"

- name: Jest
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.jest-reset.outputs.filtered }}
full: yarn jest
full: pnpm jest
limited-trigger: ${{ steps.js-files.outputs.filtered }}
limited: yarn jest --passWithNoTests --findRelatedTests {}
limited: pnpm jest --passWithNoTests --findRelatedTests {}

# We use STOPSHIP internally to mark code that's not safe to go live yet.
# We use an if block because we want to return the exact inverse of what
Expand All @@ -153,13 +159,32 @@ jobs:
- name: Checking out latest commit
uses: actions/checkout@v4

# MUST be before we install node_modules as that depends on finding
# Cypress binaries in this cache!
- uses: actions/cache@v4
with:
path: ~/.cache/Cypress
# Generate a new cache whenever the lock file changes
key: ${{ runner.os }}-cypress-${{ hashFiles('**/pnpm-lock.yaml') }}
# If source files changed, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-cypress-
- name: Install & cache node_modules
uses: ./.github/actions/shared-node-cache
with:
node-version: ${{ matrix.node-version }}

# We _should_ have a valid Cypress binary in place at this point,
# but we _could_ have had a cache miss on `~/.cache/Cypress` but a
# cache hit on `node_modules` leaving us in a state where the
# Cypress binary isn't available. This step ensures that the
# Cypress binary is in place
- name: Install Cypress
run: pnpm exec cypress install

- name: Run tests
run: yarn cypress:ci
run: pnpm cypress:ci

- name: Upload Screenshots
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -219,6 +244,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: "0"

- name: Ensure main branch is available
run: |
REF=$(git rev-parse HEAD)
Expand Down Expand Up @@ -301,7 +327,7 @@ jobs:
Example:
```sh
yarn add @khanacademy/perseus@${{
pnpm add @khanacademy/perseus@${{
steps.publish-snapshot.outputs.npm_snapshot_tag }}
```
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Build Storybook
# Generate a static version of storybook inside "storybook-static/"
run: yarn build-storybook
run: pnpm build-storybook

- name: Deploy to GitHub pages
uses: JamesIves/[email protected]
Expand All @@ -62,7 +62,7 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
publish: yarn publish:ci
publish: pnpm publish:ci
env:
# We use a Personal Access Token here rather than the GITHUB_TOKEN
# so that it will trigger our other actions. The token has to be on
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
.nvmrc
.prettierignore
LICENSE
yarn.lock
pnpm-lock.yaml
pnpm-workspace.yaml

coverage/
docs/
Expand Down
9 changes: 7 additions & 2 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import viteConfig from "../dev/vite.config";
import viteConfig from "../vite.config";
import {mergeConfig} from "vite";

import type {StorybookConfig} from "@storybook/react-vite";
Expand Down Expand Up @@ -59,6 +59,11 @@ const config: StorybookConfig = {
viteFinal: async (config, {configType}) => {
return mergeConfig(config, {
...viteConfig,
define: {
// This is used to determine if we are running in a
// Dev/Storybook environment.
"process.env.STORYBOOK": "true",
},
build: {
// Vite 5 has a bug with how it builds `url(data: )` urls when
// it inlines SVGs. Given this is mostly used for static
Expand All @@ -72,7 +77,7 @@ const config: StorybookConfig = {
},
// Fix from: https://github.com/storybookjs/storybook/issues/25256#issuecomment-1866441206
assetsInclude: ["/sb-preview/runtime.js"],
plugins: [...viteConfig.plugins, lessWrapper],
plugins: [...(viteConfig.plugins ?? []), lessWrapper],
});
},
staticDirs: ["../static"],
Expand Down
8 changes: 5 additions & 3 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as React from "react";
import {color} from "@khanacademy/wonder-blocks-tokens";
import {RenderStateRoot} from "@khanacademy/wonder-blocks-core";
import {Dependencies} from "@khanacademy/perseus";

import {DependenciesContext} from "../packages/perseus/src/dependencies";
import {
setDependencies,
DependenciesContext,
} from "../packages/perseus/src/dependencies";
import {
storybookTestDependencies,
storybookDependenciesV2,
Expand All @@ -14,7 +16,7 @@ import type {Preview} from "@storybook/react";
// IMPORTANT: This code runs ONCE per story file, not per story within that file.
// If you want code to run once per story, see `StorybookWrapper`.

Dependencies.setDependencies(storybookTestDependencies);
setDependencies(storybookTestDependencies);

const preview: Preview = {
// These decorators apply to all stories, both inside and outside the
Expand Down
Loading

0 comments on commit c573b1f

Please sign in to comment.