Skip to content

Commit

Permalink
chore: switch to pnpm (#3187)
Browse files Browse the repository at this point in the history
### Pros

- Much faster installation (On CI, ~2m30s => ~1m or ~30s if cached)
- Less disk space usage
- No custom installation logic (AKA the repo makes much more sense)
- No patch-package needed (pnpm has that support built-in)
- `pnpm install` works as expected no matter where you are in the repo

### Cons

- New tool that isn't included with node
- Custom packaging logic to handle bundled deps (See below)

### What's the hack

See [./tools/bump-pack/src/bundle-link.ts](https://github.com/winglang/wing/blob/mark/pnpm-testing/tools/bump-pack/src/bundle-link.ts)
In short: We need to add symlinks for all the transitive dependencies of bundled dependencies. This ensures the final package has all the deps it needs to run because pnpm is intentionally not friendly to bundled deps.

---

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Monada Contribution License](https://docs.winglang.io/terms-and-policies/contribution-license.html)*.
  • Loading branch information
MarkMcCulloh authored Jul 3, 2023
1 parent b90336f commit 433654e
Show file tree
Hide file tree
Showing 286 changed files with 30,575 additions and 166,684 deletions.
6 changes: 4 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "Wing Development",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"postCreateCommand": "npm install -g [email protected]",
"updateContentCommand": "npm install",
"updateContentCommand": "pnpm install",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "18.16.0"
Expand All @@ -11,6 +10,9 @@
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers-contrib/features/pnpm:2": {
"version": "8.6.5"
}
},
"hostRequirements": {
"cpus": 4,
Expand Down
78 changes: 41 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ concurrency:
env:
RUST_VERSION: "1.67.1"
NODE_VERSION: "18.16.0"
NPM_VERSION: "8.19.3"
PNPM_VERSION: "8.6.3"

jobs:
build:
Expand All @@ -42,14 +42,17 @@ jobs:
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ env.NODE_VERSION }}

- name: Setup NPM
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -63,21 +66,21 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Install Dependencies
uses: bahmutov/npm-install@v1
run: pnpm install --frozen-lockfile

- name: Changelog Generation
id: changelog
env:
GENERATE_VERSION: ${{ github.event_name != 'push' || github.repository != 'winglang/wing' }}
run: npm run changelog
run: pnpm changelog

- name: Build
run: npm run build:ci
run: pnpm build:ci
env:
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}

- name: Package
run: npm run package:ci
run: pnpm package:ci

- name: Upload Wing CLI
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -181,14 +184,17 @@ jobs:
with:
fetch-depth: 1

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ env.NODE_VERSION }}

- name: Setup NPM
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -202,10 +208,10 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Install Dependencies
uses: bahmutov/npm-install@v1
run: pnpm install --frozen-lockfile

- name: Test
run: npm run test:ci
run: pnpm test:ci

- name: Create git patch
id: diff
Expand Down Expand Up @@ -244,26 +250,23 @@ jobs:
- name: Download Build Artifacts
uses: actions/download-artifact@v2

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ env.NODE_VERSION }}

- name: Setup NPM
run: npm install -g npm@${{ env.NPM_VERSION }}

- name: Install Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: |
tools/hangar
examples/tests/valid
examples/tests/invalid
install-command: npm ci
run: pnpm install --ignore-scripts --frozen-lockfile --filter hangar --filter examples-valid --filter examples-invalid

- name: Run E2E Benchmarks
working-directory: tools/hangar
run: npm run bench
run: pnpm bench

- name: Upload Report JSON
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -313,25 +316,25 @@ jobs:
with:
path: target

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: ${{ matrix.node }}

- name: Install Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: |
tools/hangar
examples/tests/valid
examples/tests/invalid
install-command: npm ci
run: pnpm install --ignore-scripts --frozen-lockfile --filter hangar --filter examples-valid --filter examples-invalid

- name: Run E2E Tests
working-directory: tools/hangar
run: |
npm run test:generate
npm run test -- --shard=${{ matrix.shard }} --update=${{ matrix.runner == 'ubuntu' && matrix.node == '18' }}
pnpm test:generate
pnpm run test --shard=${{ matrix.shard }} --update=${{ matrix.runner == 'ubuntu' && matrix.node == '18' }}
- name: Create mutation if needed
# we only care about the diff in our standard dev env
Expand Down Expand Up @@ -405,6 +408,7 @@ jobs:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: "https://marketplace.visualstudio.com"
extensionFile: "vscode-wing/vscode-wing.vsix"
dependencies: false

- name: Login to NPM registry
run: npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_PUBLISH_TOKEN }}
Expand All @@ -427,15 +431,15 @@ jobs:
working-directory: wingcompiler
run: npm publish *.tgz --access public

- name: Check published Wing Console Design System version
id: wingconsoledesignsystem-version
run: echo "version=$(npm view @wingconsole/design-system version)" >> $GITHUB_OUTPUT

- name: Publish Wing Console Design System
if: ${{ steps.wingconsoledesignsystem-version.outputs.version != needs.build.outputs.version }}
working-directory: wingconsoledesignsystem
run: npm publish *.tgz --access public

- name: Check published Wing Console Design System version
id: wingconsoledesignsystem-version
run: echo "version=$(npm view @wingconsole/design-system version)" >> $GITHUB_OUTPUT

- name: Check published Wing Console UI version
id: wingconsoleui-version
run: echo "version=$(npm view @wingconsole/ui version)" >> $GITHUB_OUTPUT
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.DS_Store
node_modules/
.pnpm-store/
.env
*.tfstate
*.tfstate.*
.history
*.vsix

# WASI SDK (insalled by "npm install")
# WASI SDK (insalled by "pnpm install")
.cargo/wasi-sdk-*/

# Generated wing output
Expand Down
4 changes: 0 additions & 4 deletions .npmrc

This file was deleted.

10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
"version": "0.2.0",
"configurations": [
{
"command": "npx nx wing -- compile -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- compile -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing compile tf-aws",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- compile -t tf-azure ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- compile -t tf-azure ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing compile tf-azure",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- compile -t sim ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- compile -t sim ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing compile sim",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- test ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- test ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing test sim",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npx nx wing -- test -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"command": "pnpm nx wing -- test -t tf-aws ..${pathSeparator}..${pathSeparator}${relativeFile}",
"name": "wing test tf-aws",
"request": "launch",
"type": "node-terminal"
Expand Down
2 changes: 1 addition & 1 deletion apps/jsii-docgen/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions apps/jsii-docgen/.npmrc

This file was deleted.

20 changes: 15 additions & 5 deletions apps/jsii-docgen/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apps/jsii-docgen/.projen/files.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 433654e

Please sign in to comment.