Skip to content
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

🪚 Use pnpm instead of yarn #150

Merged
merged 6 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
26 changes: 16 additions & 10 deletions .github/workflows/reusable-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,27 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache: "pnpm"

# Install the dependencies without running the post-install scripts
- name: Install Dependencies
run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts
# Fetch the dependencies without running the post-install scripts
- name: Fetch Dependencies
run: pnpm fetch --frozen-lockfile --prefer-offline --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Run the post-install scripts
- name: Build Dependencies
run: yarn install --frozen-lockfile --offline
# Install the dependencies and run the post-install scripts
- name: Install Dependencies
run: pnpm install --frozen-lockfile --offline

# Cache build artifacts from turbo
#
Expand All @@ -64,7 +70,7 @@ jobs:
${{ runner.os }}-hardhat-

- name: Build
run: yarn build
run: pnpm build
env:
NODE_ENV: production

Expand All @@ -82,8 +88,8 @@ jobs:
- name: Publish packages / create version bump PRs
uses: changesets/action@v1
with:
version: yarn changeset version
publish: yarn changeset publish
version: pnpm changeset version
publish: pnpm changeset publish
title: "🚀 Version packages"

env:
Expand Down
26 changes: 16 additions & 10 deletions .github/workflows/reusable-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,27 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache: "pnpm"

# Install the dependencies without running the post-install scripts
- name: Install Dependencies
run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts
# Fetch the dependencies without running the post-install scripts
- name: Fetch Dependencies
run: pnpm fetch --frozen-lockfile --prefer-offline --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Run the post-install scripts
- name: Build Dependencies
run: yarn install --frozen-lockfile --offline
# Install the dependencies and run the post-install scripts
- name: Install Dependencies
run: pnpm install --frozen-lockfile --offline

# Cache build artifacts from turbo
#
Expand All @@ -64,13 +70,13 @@ jobs:
${{ runner.os }}-hardhat-

- name: Lint
run: yarn lint
run: pnpm lint

- name: Build
run: yarn build
run: pnpm build

- name: Test
run: yarn test
run: pnpm test
# Since we're running the E2E tests in docker, we'll need to reinstall
# the node modules. This is a temporary solution to bridge us between
# non-containerized and containerized development
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Logs
logs
*.log
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
pnpm-error.log*

# Dependency directories
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
pnpm lint-staged
18 changes: 18 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

# pnpm does not by default execute pre & post scripts
#
# since we kinda want to keep them, we need to enable this option
# see https://pnpm.io/cli/run#differences-with-npm-run for more info
enable-pre-post-scripts=true

# pnpm will by default use the workspace protocol when installing
# local dependencies
#
# in order not to modify the publishing step just yet, we'll disable this behavior
#
# TODO reenable this behavior and use solutions provided in the linked PRs
# in this github issue for changesets https://github.com/changesets/changesets/issues/432
#
# see more here https://pnpm.io/npmrc#save-workspace-protocol
save-workspace-protocol=false
prefer-workspace-packages=true
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
yarn.lock
*.log
.eslintignore
.prettierignore
.netrc
*ignore
pnpm-*.yaml
48 changes: 18 additions & 30 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ The code is arranged into:
# or nvm install if nvm use fails
nvm use

yarn
pnpm install

# Build the entire project
yarn build
pnpm build

# Lints the entire project
yarn lint
pnpm lint

# Tests the entire project
yarn test
pnpm test

# Runs the project in development mode
yarn dev
pnpm dev
```

This project is built using `turborepo`. The above commands are just aliases to `turbo` CLI and as such support all the `turbo` options:

```bash
# To start the development mode for create-lz-oapp and its dependencies
yarn dev --filter=create-lz-oapp...
pnpm dev --filter=create-lz-oapp...
```

### Running tests
Expand All @@ -56,7 +56,7 @@ The tests are by default executed in a containerized environment that sets up tw
You can run the whole test suite within this environment by running:

```bash
yarn test
pnpm test
```

#### Refining tested packages
Expand All @@ -65,21 +65,21 @@ To only run a specific test suite, you can define `DOCKER_COMPOSE_RUN_TESTS_TURB

```bash
# To only run tests for @layerzerolabs/ua-devtools-evm-hardhat-test package
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test yarn test
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test pnpm test
```

#### Rebuilding containers

`docker compose` will by default reuse images for containers it has already built. If by any chance you are seeing code changes not being reflected in your test runs, you can force docker to rebuild the images by defining `DOCKER_COMPOSE_RUN_TESTS_ARGS` environment variable. This variable will be passed to the underlying `docker compose run` command and can contain any arguments that this command understands, for example:

```bash
DOCKER_COMPOSE_RUN_TESTS_ARGS=--build yarn test
DOCKER_COMPOSE_RUN_TESTS_ARGS=--build pnpm test
```

You also combine the environment variables:

```bash
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test DOCKER_COMPOSE_RUN_TESTS_ARGS=--build yarn test
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test DOCKER_COMPOSE_RUN_TESTS_ARGS=--build pnpm test
```

#### Container logs
Expand All @@ -97,7 +97,7 @@ This allows you to monitor logs coming from e.g. the `hardhat` nodes
It is possible to expose the test networks defined in `docker-compose.yaml` on your host machine. To do this, you can run:

```bash
yarn start
pnpm start
```

Once the networks are running, you can go to the `ua-devtools-evm-hardhat-test` package:
Expand All @@ -109,25 +109,25 @@ cd packages/ua-devtools-hardhat-test
Setup the default `EndpointV2` and `DefaultOApp`:

```bash
npx hardhat lz:test:oapp:deploy
pnpm hardhat lz:test:oapp:deploy
```

And execute `hardhat` tasks as usual:

```bash
npx hardhat lz:oapp:getDefaultConfig
pnpm hardhat lz:oapp:getDefaultConfig
```

If you are developing tasks, it's useful to build the code when it changes. To do this, run the following from the project root:

```bash
yarn dev
pnpm dev
```

To stop the network containers, just run:

```bash
yarn stop
pnpm stop
```

**Don't forget that the state of the local networks disappears after they are stopped and any deployment files created in one session will be invalid in the next one.**
Expand All @@ -144,21 +144,9 @@ export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
```

#### Problems with package updating

To update external `@layerzerolabs` packages, you can use the builtin `yarn` utility:

```bash
yarn upgrade-interactive --scope @layerzerolabs --latest
```

However, this utility has an issue with packages that are listed both at the workspace root and in the individual packages, e.g. `@layerzerolabs/prettier-config-next` - it errors out saying that a workspace package could not be found.

To work around this (since this version of yarn is outdated and a fix for this problem will not be provided), you can remove the entries from the root `package.json` before running the command, then add them back (just don't forget to update their versions).

#### Problems using the `dev` script

`turbo` might complain about concurrency issues when running `yarn dev`:
`turbo` might complain about concurrency issues when running `pnpm dev`:

```diff
- error preparing engine: Invalid persistent task configuration:
Expand All @@ -168,7 +156,7 @@ To work around this (since this version of yarn is outdated and a fix for this p
If you see this error, just follow turbo's lead and use:

```bash
yarn dev --concurrency 19
pnpm dev --concurrency 19
```

#### Problems with snapshots
Expand All @@ -183,5 +171,5 @@ For some packages the snapshot output depends on environment variables and other
If you encounter errors when running these tests, just set the environment variable before running the test:

```bash
CI=1 yarn test
CI=1 pnpm test
```
Loading
Loading