Skip to content

NickAkhmetov/HMP-233 Switch to PNPM #3291

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 8 additions & 7 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: "recursive"

- uses: pnpm/action-setup@v2
with:
version: 8.8.0
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: context/package-lock.json

- run: npm --version
cache: "pnpm"
cache-dependency-path: context/pnpm-lock.yaml
- run: pnpm --version

- name: Install node dependencies
run: npm ci --prefix context
run: pnpm i --frozen-lockfile --dir context

- name: Run test script
run: etc/test/test-node.sh
1 change: 1 addition & 0 deletions .vscode/default.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"editor.defaultFormatter": "ms-python.autopep8"
},
"python.formatting.provider": "autopep8",
"npm.packageManager": "pnpm",
"optional": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
Expand Down
10 changes: 5 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}
},
{
"label": "npm install",
"label": "Install JS Dependencies",
"type": "npm",
"script": "install",
"group": {
Expand All @@ -66,7 +66,7 @@
"dependsOn": [
"Init submodules",
"pip install",
"npm install"
"Install JS Dependencies"
],
"dependsOrder": "parallel"
},
Expand Down Expand Up @@ -108,7 +108,7 @@
"dependsOrder": "sequence"
},
{
"label": "npm run lint",
"label": "Lint JS",
"type": "npm",
"script": "lint",
"problemMatcher": [
Expand Down Expand Up @@ -150,7 +150,7 @@
{
"label": "React Dev Server (+ lint)",
"dependsOn": [
"npm run lint",
"Lint JS",
"React Dev Server"
],
"dependsOrder": "sequence"
Expand Down Expand Up @@ -244,7 +244,7 @@
"options": {
"cwd": "${workspaceFolder}/context"
},
"command": "npx --yes kill-port 5000 5001 6006"
"command": "pnpm dlx --silent kill-port 5000 5001 6006"
}
]
}
1 change: 1 addition & 0 deletions CHANGELOG-HMP-233.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Migrate to `pnpm` package manager.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ All designs are in [Figma](https://www.figma.com/files/team/834568130405102661/H
- `` pyenv install `cat .python-version` ``
- `` pyenv virtualenv `cat .python-version` portal ``
- `pyenv activate portal`
- `nodejs/npm`: Suggest [installing nvm](https://github.com/nvm-sh/nvm#installing-and-updating) and then using it to install the appropriate node version: `nvm install`.
- `nodejs`: Suggest [installing nvm](https://github.com/nvm-sh/nvm#installing-and-updating) and then using it to install the appropriate node version: `nvm install`.
- `` nvm install `cat .nvmrc` ``
- `` nvm use `cat .nvmrc` ``
- `pnpm`: Suggest [install pnpm via npm](https://pnpm.io/installation#using-npm) after installing the proper `nodejs` version.

Optional:

Expand Down Expand Up @@ -200,8 +201,8 @@ Load tests [are available](end-to-end/artillery/), but they are not run as part

### Running tests locally without docker

- **Jest**: `cd context; npm run test`
- **Cypress**: With the application running, `cd end-to-end; npm run cypress:open`
- **Jest**: `cd context; pnpm run test`
- **Cypress**: With the application running, `cd end-to-end; pnpm run cypress:open`
- If using WSL2, see the WSL2-specific steps in the [end to end readme](./end-to-end/README.md).
- Note that the cypress tests (particularly for the publication page) are expected to be run with the `test` environment enabled in app.conf
- **Pytest**: `cd context; pytest app --ignore app/api/vitessce_conf_builder`
Expand All @@ -215,15 +216,15 @@ You can also lint and auto-correct from the command-line:

```
cd context
npm run lint
npm run lint:fix
pnpm run lint
pnpm run lint:fix
EXCLUDE=node_modules,ingest-validation-tools,etc/dev/organ-utils
autopep8 --in-place --aggressive -r . --exclude $EXCLUDE
```

### Storybook

To start storybook locally you can either run `etc/dev/dev-start.sh`, or just `npm run storybook`,
To start storybook locally you can either run `etc/dev/dev-start.sh`, or just `pnpm run storybook`,
and after it has started, visit [localhost:6006](http://localhost:6006).

## Build, tag, and deploy
Expand All @@ -234,7 +235,7 @@ The build, tag, deploy, and QA procedures are [detailed here](https://hms-dbmi.a

<details><summary>Webpack</summary>

To view visualizations of the production webpack bundle run `npm run build:analyze`.
To view visualizations of the production webpack bundle run `pnpm run build:analyze`.
The script will generate two files, report.html and stats.html, inside the public directory each showing a different visual representation of the bundle.

</details>
Expand Down
9 changes: 6 additions & 3 deletions context/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ ARG PYTHON_MINOR_V

FROM node:${NODE_V}-alpine as builder

# Run corepack to get `pnpm`
RUN corepack enable

WORKDIR /work
RUN apk add --no-cache git

# COPY only what is needed so layers can be cached.
COPY package.json .
COPY package-lock.json .
COPY pnpm-lock.yaml .
COPY .npmrc .

RUN npm ci
RUN pnpm ci

COPY tsconfig.json tsconfig.json
COPY .swcrc .swcrc
Expand All @@ -21,7 +24,7 @@ COPY ingest-validation-tools ingest-validation-tools
# portal-visualization is python-only, and not needed for the npm build.

ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN npm run build
RUN pnpm run build

FROM tiangolo/uwsgi-nginx-flask:python${PYTHON_MINOR_V}

Expand Down
Loading