Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,25 @@ jobs:
javascript-tests:
executor:
name: node/default
# The Node version here must be kept in sync with that in `package.json`.
tag: '22.11.0'
# The Node version here should be compatible with `package.json` engines.
# Note: cimg/node requires at least a minor version (e.g., '22.0'), not just major version
tag: '22.0'
steps:
- checkout
- node/install-packages:
# `yarn install --frozen-lockfile` is run and cache is enabled by default for this orb configuration
pkg-manager: yarn
- run:
command: yarn lint
name: Install pnpm
command: sudo corepack enable && corepack prepare [email protected] --activate
- run:
name: Install dependencies
command: pnpm install --frozen-lockfile
- run:
command: pnpm lint
name: Run linting
- run:
command: yarn markdownlint
command: pnpm markdownlint
name: Check markdown linting
- run:
command: yarn test:coverage
command: pnpm test:coverage
name: Run Jest tests
- codecov/upload

Expand All @@ -123,10 +127,6 @@ jobs:
- image: 'cimg/python:3.10-node'
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- node-deps-v1-{{ .Branch }}
- run: pip install tox
- run:
command: tox -e docs
Expand Down
4 changes: 3 additions & 1 deletion .markdownlintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
docs/index.md
node_modules
node_modules
venv
CLAUDE.md
17 changes: 17 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# pnpm configuration for Treeherder

# Equivalent to yarn's ignore-engines - don't check engine compatibility
engine-strict=false

# Save exact versions instead of ranges when adding packages
save-exact=true

# Don't run lifecycle scripts during install for security
ignore-scripts=true

# Hoist all dependencies to node_modules root for compatibility
# This makes pnpm behavior similar to npm/yarn flat node_modules
shamefully-hoist=true

# Auto-install peers to avoid peer dependency warnings
auto-install-peers=true
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Ignore generated directories.
.*/
venv/
node_modules/
pnpm-lock.yaml

# Ignore our legacy JS since it will be rewritten when converted to React.
ui/js/
Expand Down
20 changes: 0 additions & 20 deletions .yarnrc

This file was deleted.

13 changes: 1 addition & 12 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,7 @@
[
"@babel/preset-react",
{
"development": true,
"useSpread": true
}
]
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"react-hot-loader/babel",
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
"runtime": "automatic"
}
]
]
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ services:
# https://hub.docker.com/_/node
image: node:23.5.0-alpine3.20
# Installing JS dependencies at runtime so that they share the `node_modules` from the
# host, improving speed (both install and build due to the webpack cache) and ensuring
# host, improving speed (both install and build due to the rspack cache) and ensuring
# the host copy stays in sync (for people that switch back and forth between UI-only
# and full stack Treeherder development).
working_dir: /app
environment:
BACKEND: http://backend:8000
command: sh -c "yarn && yarn start --host 0.0.0.0"
command: sh -c "corepack enable && corepack prepare [email protected] --activate && pnpm install && pnpm start --host 0.0.0.0"
volumes:
- .:/app
ports:
Expand Down
14 changes: 8 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
## Frontend stage
FROM node:22.11.0 AS frontend
FROM node:22-slim AS frontend

WORKDIR /app

# Install pnpm
RUN corepack enable && corepack prepare [email protected] --activate

COPY ui/ /app/ui/
COPY package.json babel.config.json webpack.config.js yarn.lock /app/
COPY package.json rspack.config.js pnpm-lock.yaml .npmrc /app/

RUN npm install -g --force [email protected]
RUN yarn install
RUN yarn build
RUN pnpm install --frozen-lockfile
RUN pnpm build


## Backend stage
Expand Down Expand Up @@ -38,7 +40,7 @@ RUN python manage.py collectstatic --noinput
# WhiteNoise can then serve in preference to the originals. This is required
# since WhiteNoise's Django storage backend only gzips assets handled by
# collectstatic, and so does not affect files in the `.build/` directory
# since they are instead generated by webpack.
# since they are instead generated by rspack.
RUN python -m whitenoise.compress .build

RUN groupadd --gid 9500 treeherder && \
Expand Down
4 changes: 2 additions & 2 deletions docs/backend_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ docker-compose run backend bash

...which saves having to wait for docker-compose to spin up for every test run.

`yarn build` will generate a `.build` directory which will be seen within the `backend` container.
If you don't have `yarn` working on your host you can run this instead `docker-compose run frontend sh -c "yarn && yarn build"`
`pnpm build` will generate a `.build` directory which will be seen within the `backend` container.
If you don't have `pnpm` working on your host you can run this instead `docker-compose run frontend sh -c "corepack enable && pnpm install && pnpm build"`

Then run the individual tools within that shell, like so:

Expand Down
4 changes: 2 additions & 2 deletions docs/code_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Javascript in the [Installation section](installation.md#validating-javascript))

Prettier is also used to format JSON/CSS/HTML/Markdown/YAML. However these are not supported
by ESLint, so instead are validated using Prettier's CLI. To manually check their formatting
(as well as that of JS/JSX) using Prettier, run `yarn format:check`, or to apply formatting
fixes run `yarn format`.
(as well as that of JS/JSX) using Prettier, run `pnpm format:check`, or to apply formatting
fixes run `pnpm format`.

However we recommend that you instead
[add Prettier to your editor/IDE](https://prettier.io/docs/en/editors.html)
Expand Down
10 changes: 5 additions & 5 deletions docs/common_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ The docs will then be available at: <http://localhost:8000>

## Updating package.json

- Always use `yarn` to make changes, not `npm`, so that `yarn.lock` remains in sync.
- Add new packages using `yarn add <PACKAGE>` (`yarn.lock` will be automatically updated).
- After changes to `package.json` use `yarn install` to install them and automatically update `yarn.lock`.
- For more details see the [Yarn documentation].
- Always use `pnpm` to make changes, not `npm`, so that `pnpm-lock.yaml` remains in sync.
- Add new packages using `pnpm add <PACKAGE>` (`pnpm-lock.yaml` will be automatically updated).
- After changes to `package.json` use `pnpm install` to install them and automatically update `pnpm-lock.yaml`.
- For more details see the [pnpm documentation].

[yarn documentation]: https://yarnpkg.com/en/docs/usage
[pnpm documentation]: https://pnpm.io/cli/add

## Debugging Tools

Expand Down
18 changes: 9 additions & 9 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ From here on, linting checks will be executed every time you commit.

To get started:

- Install [Node.js] and [Yarn] (see [package.json] for known compatible versions, listed under `engines`).
- Run `yarn install` to install all dependencies.
- Run `yarn build` to build necessary files.
- Install [Node.js] and [pnpm] (see [package.json] for known compatible versions, listed under `engines` and `packageManager`).
- Run `pnpm install` to install all dependencies.
- Run `pnpm build` to build necessary files.

### Running the standalone development server

Expand All @@ -40,7 +40,7 @@ production site. You do not need to set up the Docker environment unless making
- Start the development server by running:

```bash
yarn start
pnpm start
```

<!-- prettier-ignore -->
Expand All @@ -54,7 +54,7 @@ production site. You do not need to set up the Docker environment unless making
To run the unminified UI with data from the staging site instead of the production site, type:

```bash
yarn start:stage
pnpm start:stage
```

## Server and Full-stack Development
Expand All @@ -81,7 +81,7 @@ export those env variables in the shell first or inline with the command below.

- Visit <http://localhost:5000> in your browser (NB: not port 8000).

Both Django's runserver and webpack-dev-server will automatically refresh every time there's a change in the code.
Both Django's runserver and rspack-dev-server will automatically refresh every time there's a change in the code.
Proceed to [Running the ingestion tasks](#running-the-ingestion-tasks) to get data.

### Using the minified UI
Expand All @@ -91,7 +91,7 @@ If you would like to use the minified production version of the UI with the deve
- Run the build task:

```bash
docker-compose run frontend sh -c "yarn && yarn build"
docker-compose run frontend sh -c "corepack enable && pnpm install && pnpm build"
```

- Start Treeherder's backend:
Expand All @@ -102,7 +102,7 @@ If you would like to use the minified production version of the UI with the deve

- Visit <http://localhost:8000> (NB: port 8000, unlike above)

Requests to port 8000 skip webpack-dev-server, causing Django's runserver to serve the
Requests to port 8000 skip rspack-dev-server, causing Django's runserver to serve the
production UI from `.build/` instead. In addition to being minified and using the
non-debug versions of React, the assets are served with the same `Content-Security-Policy`
header as production.
Expand Down Expand Up @@ -224,6 +224,6 @@ Continue to **Working with the Server** section after looking at the [Code Style
[git]: https://git-scm.com
[treeherder repo]: https://github.com/mozilla/treeherder
[node.js]: https://nodejs.org/en/download/current/
[yarn]: https://yarnpkg.com/en/docs/install
[pnpm]: https://pnpm.io/installation
[package.json]: https://github.com/mozilla/treeherder/blob/master/package.json
[settings]: https://github.com/mozilla/treeherder/blob/master/treeherder/config/settings.py#L318
18 changes: 9 additions & 9 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ does not match the style requirements.
To run ESLint by itself, you may run the lint task:

```shell
yarn lint
pnpm lint
```

Or to automatically fix issues found (where possible):

```shell
yarn lint --fix
pnpm lint --fix
```

You can also check against Prettier:

```shell
yarn format:check
pnpm format:check
```

and to have it actually fix (to the best of its ability) any format issues,
just do:

```shell
yarn format
pnpm format
```

See the [code style](code_style.md#ui) section for more details.
Expand All @@ -44,19 +44,19 @@ The tests are written with react testing library. For the integration tests Poll

Integration tests are useful when testing higher level components that would be hard to setup with fetch mock.
They use PollyJS because it helps to automatically record and replay requests/responses.
To refresh the PollyJS recordings (usually when an endpoint response changes), just delete the recordings folder and run `yarn test:integration` again like described below.
To refresh the PollyJS recordings (usually when an endpoint response changes), just delete the recordings folder and run `pnpm test:integration` again like described below.

To run the tests:

- If you haven't already done so, install local dependencies by running `yarn install` from the project root.
- For unit tests run `yarn test` to execute the tests.
- For integration tests run `yarn test:integration` to execute the tests.
- If you haven't already done so, install local dependencies by running `pnpm install` from the project root.
- For unit tests run `pnpm test` to execute the tests.
- For integration tests run `pnpm test:integration` to execute the tests.

While working on the frontend, you may wish to watch JavaScript files and re-run the unit tests
automatically when files change. To do this, you may run one of the following commands:

```shell
yarn test:watch
pnpm test:watch
```

The tests will perform an initial run and then re-execute each time a project file is changed.
Expand Down
12 changes: 12 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@ export default [
parser: babelParser,
},
files: ['**/*.js', '**/*.jsx'],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.json'],
moduleDirectory: ['node_modules', 'ui'],
},
},
},
rules: {
'class-methods-use-this': 'off',
'consistent-return': 'off',
'default-case': 'off',
'default-param-last': 'off',
'import/extensions': 'off',
'import/no-unresolved': [
'error',
{ ignore: ['^react-resizable-panels$'] },
],
'jsx-a11y/click-events-have-key-events': 'off',
'no-alert': 'off',
'no-continue': 'off',
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = {
'<rootDir>/tests/jest/file-mock.js',
'\\.(css|less|sass|scss)$': '<rootDir>/tests/jest/style-mock.js',
'^react-native$': '<rootDir>/node_modules/react-native-web',
'^react-resizable-panels$':
'<rootDir>/tests/jest/react-resizable-panels-mock.js',
},
bail: true,
collectCoverageFrom: ['ui/**/*.{mjs,jsx,js}'],
Expand Down
Loading