Skip to content

Commit 20c52be

Browse files
authored
Migrate workspace from npm to pnpm (#2385)
1 parent 6c7d483 commit 20c52be

File tree

18 files changed

+27842
-47614
lines changed

18 files changed

+27842
-47614
lines changed

.github/actions/create-test/action.yml

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
name: Create a new survey
1516

1617
inputs:
1718
platform-repository:
18-
description: "ground-platform repository under test"
19+
description: 'ground-platform repository under test'
1920
default: google/ground-platform
2021

2122
upload-artifacts:
22-
description: "Whether to upload the final emulator data artifacts"
23-
default: "false"
23+
description: 'Whether to upload the final emulator data artifacts'
24+
default: 'false'
2425

2526
runs:
26-
using: "composite"
27+
using: 'composite'
2728
steps:
2829
- name: Checkout code
2930
uses: actions/checkout@v4
@@ -38,56 +39,18 @@ runs:
3839
restore-keys: |
3940
${{ runner.os }}-firebase-emulators-
4041
41-
- name: Set up Node.js
42-
uses: actions/setup-node@v2
43-
with:
44-
node-version: "20"
45-
46-
- name: Load cached Node modules
47-
id: cache-npm
48-
uses: actions/cache@v3
49-
env:
50-
cache-name: cache-node-modules
51-
with:
52-
# npm cache files are stored in `~/.npm` on Linux/macOS
53-
path: ~/.npm
54-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
55-
restore-keys: |
56-
${{ runner.os }}-build-${{ env.cache-name }}-
57-
${{ runner.os }}-build-
58-
${{ runner.os }}-
59-
60-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
61-
name: List the state of Node modules
62-
continue-on-error: true
63-
shell: bash
64-
run: npm list
65-
66-
- name: Install Chrome
67-
uses: browser-actions/setup-chrome@v1
68-
id: setup-chrome
42+
- name: Set up environment
43+
uses: ./.github/actions/setup
6944
with:
70-
chrome-version: 125
71-
72-
- name: Save CHROME_PATH
73-
shell: bash
74-
run: echo "CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
75-
76-
- name: Install nx-linux-x64-gnu
77-
shell: bash
78-
run: npm install @nx/nx-linux-x64-gnu
79-
80-
- name: Install dependencies
81-
shell: bash
82-
run: npm install
45+
install-chrome: 'true'
8346

8447
- name: Build project and local deps
8548
shell: bash
86-
run: npx nx build
49+
run: pnpm exec nx build
8750

8851
- name: Run 'Create survey' test
8952
shell: bash
90-
run: npm run test:e2e:create
53+
run: pnpm run test:e2e:create
9154

9255
- name: Move Firebase emulator data (avoids .gitignore)
9356
shell: bash
@@ -98,7 +61,7 @@ runs:
9861
uses: actions/upload-artifact@v4
9962
with:
10063
name: data-create
101-
path: "**/test"
64+
path: '**/test'
10265
retention-days: 7
10366
overwrite: true
10467
if-no-files-found: error

.github/actions/setup/action.yml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,54 @@
1-
name: "Set up environment"
2-
description: "Sets up Node.js and installs dependencies"
1+
name: Set up environment
2+
description: Sets up Node.js, pnpm, Nx cache, and installs dependencies
33

44
inputs:
55
cache-key-suffix:
6-
description: "Suffix for the Nx cache key (e.g. job name)"
6+
description: Suffix for the Nx cache key (e.g. job name)
77
required: false
8-
default: "default"
8+
default: default
9+
install-chrome:
10+
description: 'Whether to install Google Chrome'
11+
required: false
12+
default: 'false'
913

1014
runs:
11-
using: "composite"
15+
using: composite
1216
steps:
13-
- name: Cache Nx
17+
- name: Restore Nx cache
1418
uses: actions/cache@v4
1519
with:
1620
path: .nx/cache
1721
key: nx-${{ runner.os }}-${{ inputs.cache-key-suffix }}-${{ github.sha }}
1822
restore-keys: |
1923
nx-${{ runner.os }}-${{ inputs.cache-key-suffix }}-
2024
25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: 9
29+
2130
- name: Set up Node.js
2231
uses: actions/setup-node@v6
2332
with:
24-
node-version: "20"
25-
cache: "npm"
33+
node-version: '20'
34+
cache: pnpm
35+
36+
- name: Install dependencies
37+
shell: bash
38+
run: pnpm install --frozen-lockfile
39+
env:
40+
NX_REJECT_UNKNOWN_LOCAL_CACHE: '0'
41+
42+
- name: Install Chrome
43+
if: ${{ inputs.install-chrome == 'true' }}
44+
uses: browser-actions/setup-chrome@v1
45+
id: setup-chrome
46+
with:
47+
chrome-version: stable
2648

27-
- name: Install deps
28-
run: npm ci
49+
- name: Configure Chrome Environment
50+
if: ${{ inputs.install-chrome == 'true' }}
2951
shell: bash
52+
run: |
53+
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
54+
echo "CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV

.github/actions/verify-test/action.yml

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
name: Verify survey submissions
1516

1617
inputs:
1718
platform-repository:
18-
description: "ground-platform repository under test"
19+
description: 'ground-platform repository under test'
1920
default: google/ground-platform
2021

2122
use-repo-data:
22-
description: "Whether to use the local repository emulator data or not"
23-
default: "true"
23+
description: 'Whether to use the local repository emulator data or not'
24+
default: 'true'
2425

2526
runs:
26-
using: "composite"
27+
using: 'composite'
2728
steps:
2829
- name: Checkout code
2930
uses: actions/checkout@v4
@@ -38,49 +39,14 @@ runs:
3839
restore-keys: |
3940
${{ runner.os }}-firebase-emulators-
4041
41-
- name: Set up Node.js
42-
uses: actions/setup-node@v2
43-
with:
44-
node-version: "20"
45-
46-
- name: Load cached Node modules
47-
id: cache-npm
48-
uses: actions/cache@v3
49-
env:
50-
cache-name: cache-node-modules
51-
with:
52-
# npm cache files are stored in `~/.npm` on Linux/macOS
53-
path: ~/.npm
54-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
55-
restore-keys: |
56-
${{ runner.os }}-build-${{ env.cache-name }}-
57-
${{ runner.os }}-build-
58-
${{ runner.os }}-
59-
60-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
61-
name: List the state of Node modules
62-
continue-on-error: true
63-
shell: bash
64-
run: npm list
65-
66-
- name: Install Chrome
67-
uses: browser-actions/setup-chrome@v1
68-
id: setup-chrome
42+
- name: Set up environment
43+
uses: ./.github/actions/setup
6944
with:
70-
chrome-version: 125
71-
72-
- name: Save CHROME_PATH
73-
shell: bash
74-
run: |
75-
echo "CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
76-
77-
- name: Install nx-linux-x64-gnu
78-
shell: bash
79-
run: npm install @nx/nx-linux-x64-gnu
45+
install-chrome: 'true'
8046

8147
- name: Build project and local deps
8248
shell: bash
83-
run: npx nx build
49+
run: pnpm exec nx build
8450

8551
- name: Copy Firebase emulator data
8652
uses: actions/download-artifact@v4
@@ -96,4 +62,4 @@ runs:
9662

9763
- name: Run 'Verify survey' test
9864
shell: bash
99-
run: npm run test:e2e:verify
65+
run: pnpm run test:e2e:verify

.github/workflows/check.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ jobs:
6868
cache-key-suffix: functions
6969

7070
- name: Build
71-
run: npx nx build functions
71+
run: pnpm exec nx build functions
7272

7373
- name: Test
74-
run: npx nx test functions
74+
run: pnpm exec nx test functions
7575

7676
- name: Lint
77-
run: npx nx lint functions
77+
run: pnpm exec nx lint functions
7878

7979
lib:
8080
needs: changes
@@ -91,13 +91,13 @@ jobs:
9191
cache-key-suffix: lib
9292

9393
- name: Build
94-
run: npx nx build lib
94+
run: pnpm exec nx build lib
9595

9696
- name: Test
97-
run: npx nx test lib
97+
run: pnpm exec nx test lib
9898

9999
- name: Lint
100-
run: npx nx lint lib
100+
run: pnpm exec nx lint lib
101101

102102
proto:
103103
needs: changes
@@ -114,10 +114,10 @@ jobs:
114114
cache-key-suffix: proto
115115

116116
- name: Build
117-
run: npx nx build proto
117+
run: pnpm exec nx build proto
118118

119119
- name: Lint
120-
run: npx nx lint proto
120+
run: pnpm exec nx lint proto
121121

122122
web:
123123
needs: changes
@@ -133,14 +133,26 @@ jobs:
133133
with:
134134
cache-key-suffix: web
135135

136+
- name: Install Chrome
137+
uses: browser-actions/setup-chrome@v1
138+
id: setup-chrome
139+
with:
140+
chrome-version: stable
141+
142+
- name: Configure Chrome Environment
143+
shell: bash
144+
run: |
145+
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
146+
echo "CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
147+
136148
- name: Build
137-
run: npx nx build web
149+
run: pnpm exec nx build web
138150

139151
- name: Test
140-
run: npx nx test web
152+
run: pnpm exec nx test web
141153

142154
- name: Lint
143-
run: npx nx lint web
155+
run: pnpm exec nx lint web
144156

145157
- name: Update test coverage report
146158
uses: codecov/codecov-action@v5

.github/workflows/deploy-to-staging.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,11 @@ jobs:
2525
- name: Check out repository
2626
uses: actions/checkout@v6
2727

28-
- name: Setup Node.js
29-
uses: actions/setup-node@v6
30-
with:
31-
node-version: "20"
32-
33-
- name: Install deps
34-
run: npm install
28+
- name: Set up environment
29+
uses: ./.github/actions/setup
3530

36-
- name: Build
37-
run: npx nx build --configuration=staging
31+
- name: Build project and local deps
32+
run: pnpm exec nx build --configuration=staging
3833

3934
- name: Deploy to Firebase
4035
uses: FirebaseExtended/action-hosting-deploy@v0

0 commit comments

Comments
 (0)