Skip to content

Commit

Permalink
chore(pnpm): migrate project to use pnpm (#2524)
Browse files Browse the repository at this point in the history
Fixes #2519
  • Loading branch information
wesbillman authored Aug 28, 2024
1 parent 7cd61b6 commit bf5adf5
Show file tree
Hide file tree
Showing 18 changed files with 13,765 additions and 25,118 deletions.
16 changes: 9 additions & 7 deletions .github/actions/build-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ runs:
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-maven-
- name: Restore NPM Cache
id: cache-npm
uses: actions/cache/restore@v4
- name: Restore pnpm Cache
id: cache-pnpm
uses: actions/cache@v4
with:
path: .hermit/node/cache/_cacache
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
path: |
~/.pnpm-store
node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-npm-
${{ runner.os }}-pnpm-
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ jobs:
uses: cashapp/activate-hermit@v1
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Console NPM Install
run: just npm-install
- name: Console pnpm install
run: just pnpm-install
- name: Console Lint
working-directory: frontend
run: npm run lint
run: just lint-frontend
- name: Console Build
run: just build-frontend
- name: Console Test
Expand All @@ -150,12 +149,12 @@ jobs:
uses: cashapp/activate-hermit@v1
- name: Build Cache
uses: ./.github/actions/build-cache
- name: VSCode Extension NPM Install
run: just npm-install
- name: VSCode Extension Lint
- name: VSCode extension pnpm install
run: just pnpm-install
- name: VSCode extension lint
working-directory: extensions/vscode
run: npm run lint
- name: VSCode Extension NPM Build
run: pnpm run lint
- name: VSCode extension pnpm build
run: just build-extension
build-all:
name: Rebuild All
Expand Down Expand Up @@ -210,8 +209,8 @@ jobs:
uses: cashapp/activate-hermit@v1
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Console NPM Install
run: just npm-install
- name: Console pnpm install
run: just pnpm-install
- name: Console e2e
run: just e2e-frontend
integration-shard:
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/writecache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
run: just build-all
- name: Download Go Dependencies
run: go mod download -x
- name: Download NPM Dependencies
run: find . -name package-lock.json -execdir npm ci \;
- name: Download pnpm dependencies
run: pnpm install
- id: find-go-build-cache
shell: bash
run: echo "cache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
Expand All @@ -41,9 +41,11 @@ jobs:
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: Save NPM Modules Cache
id: cache-npm
- name: Save pnpm Modules Cache
id: cache-pnpm
uses: actions/cache/save@v4
with:
path: .hermit/node/cache/_cacache
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
path: |
~/.pnpm-store
node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
32 changes: 16 additions & 16 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ errtrace:
# Clean the build directory
clean:
rm -rf build
rm -rf frontend/node_modules
rm -rf node_modules
find . -name '*.zip' -exec rm {} \;
mvn -f jvm-runtime/ftl-runtime clean

Expand Down Expand Up @@ -82,12 +82,12 @@ build-zips: build-kt-runtime
@for dir in {{ZIP_DIRS}}; do (cd $dir && mk ../$(basename ${dir}).zip : . -- "rm -f $(basename ${dir}.zip) && zip -q --symlinks -r ../$(basename ${dir}).zip ."); done

# Rebuild frontend
build-frontend: npm-install
@mk {{FRONTEND_OUT}} : frontend/src -- "cd frontend && npm run build"
build-frontend: pnpm-install
@mk {{FRONTEND_OUT}} : frontend/src -- "cd frontend && pnpm run build"

# Rebuild VSCode extension
build-extension: npm-install
@mk {{EXTENSION_OUT}} : extensions/vscode/src extensions/vscode/package.json -- "cd extensions/vscode && rm -f ftl-*.vsix && npm run compile"
build-extension: pnpm-install
@mk {{EXTENSION_OUT}} : extensions/vscode/src extensions/vscode/package.json -- "cd extensions/vscode && rm -f ftl-*.vsix && pnpm run compile"

# Install development version of VSCode extension
install-extension: build-extension
Expand All @@ -107,19 +107,18 @@ build-kt-runtime:
@mkdir -p build/template/ftl && touch build/template/ftl/temp.txt
@cd build/template && zip -q --symlinks -r ../../{{RUNNER_TEMPLATE_ZIP}} .

# Install Node dependencies
# npm install fails intermittently due to network issues, so we retry a few times.
npm-install:
@mk frontend/node_modules : frontend/package.json -- "cd frontend && for i in {1..3}; do npm install && break || sleep 5; done"
@mk extensions/vscode/node_modules : extensions/vscode/package.json extensions/vscode/src -- "cd extensions/vscode && for i in {1..3}; do npm install && break || sleep 5; done"
# Install Node dependencies using pnpm
# Retry a few times in case of network issues
pnpm-install:
@for i in {1..3}; do pnpm install && break || sleep 5; done

# Regenerate protos
build-protos: npm-install
build-protos: pnpm-install
@mk {{SCHEMA_OUT}} : backend/schema -- "ftl-schema > {{SCHEMA_OUT}} && buf format -w && buf lint"
@mk {{PROTOS_OUT}} : {{PROTOS_IN}} -- "cd backend/protos && buf generate"

# Unconditionally rebuild protos
build-protos-unconditionally: npm-install
build-protos-unconditionally: pnpm-install
ftl-schema > {{SCHEMA_OUT}} && buf format -w && buf lint
cd backend/protos && buf generate

Expand Down Expand Up @@ -154,14 +153,14 @@ test-scripts:
scripts/tests/test-ensure-frozen-migrations.sh

test-frontend: build-frontend
@cd frontend && npm run test
@cd frontend && pnpm run test

e2e-frontend: build-frontend
@cd frontend && npx playwright install --with-deps && npm run e2e
@cd frontend && npx playwright install --with-deps && pnpm run e2e

# Lint the frontend
lint-frontend: build-frontend
@cd frontend && npm run lint && tsc
@cd frontend && pnpm run lint && tsc

# Lint the backend
lint-backend:
Expand Down Expand Up @@ -237,6 +236,7 @@ grafana:
grafana-stop:
docker compose down grafana

# Start storybook server
storybook:
#!/bin/bash
cd frontend && npm run storybook
cd frontend && pnpm run storybook
1 change: 1 addition & 0 deletions bin/.pnpm-9.9.0.pkg
1 change: 1 addition & 0 deletions bin/pnpm
Loading

0 comments on commit bf5adf5

Please sign in to comment.