Skip to content

Commit

Permalink
chore: use pnpm to manage dependencies (closes #12635) (#13190)
Browse files Browse the repository at this point in the history
* chore: use pnpm to manage dependencies

* Fix CI errors

* Don't report Docker image size for external PRs

* Fix pnpm-lock.yaml formatting

* Fix module versions

* Ignore pnpm-lock.yaml

* Upgrade Cypress action for pnpm support

* Set up node and pnpm before Cypress

* Fix typescript issues

* Include patches directory in Dockerfile

* Fix Jest tests in CI

* Update lockfile

* Update lockfile

* Clean up Dockerfile

* Update pnpm-lock.yaml to reflect current package.json files

* remove yarn-error.log from .gitignore

* formatting

* update data exploration readme

* type jest.config.ts

* fix @react-hook issues for jest

* fix react-syntax-highlighter issues for jest

* fix jest issues from query-selector-shadow-dom

* fix transform ignore patterns and undo previous fixes

* add missing storybook peer dependencies

* fix nullish coalescing operator for storybook

* reorder storybook plugins

* update editor-update-tsd warning to new npm script

* use legacy ssl for chromatic / node 18 compatibility

* use pnpm for visual regression testing workflow

* use node 16 for chromatic

* add @babel/plugin-proposal-nullish-coalescing-operator as direct dependency

* try fix for plugin-server

* cleanup

* fix comment and warning

* update more comments

* update playwright dockerfile

* update plugin source types

* conditional image size reporting

* revert react-native instructions

* less restrictive pnpm verions

* use ref component name in line with style guide

Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
  • Loading branch information
thmsobrmlr and jacobwgillespie authored Dec 12, 2022
1 parent 88c412a commit 4a30e78
Show file tree
Hide file tree
Showing 57 changed files with 28,806 additions and 30,832 deletions.
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
!babel.config.js
!posthog.json
!package.json
!yarn.lock
!pnpm-lock.yaml
!webpack.config.js
!postcss.config.js
!playwright.config.ts
Expand All @@ -24,10 +24,10 @@
!ee
!.devcontainer
!plugin-server/package.json
!plugin-server/yarn.lock
!plugin-server/pnpm-lock.yaml
!plugin-server/tsconfig.json
!plugin-server/tsconfig.eslint.json
!plugin-server/src
!plugin-server/.eslintrc.js
!plugin-server/.prettierrc
!share/GeoLite2-City.mmdb
!share/GeoLite2-City.mmdb
30 changes: 13 additions & 17 deletions .github/workflows/ci-e2e-vrt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,31 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm

- uses: actions/cache@v3
id: node-modules-cache
with:
path: |
node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules
- name: Install package.json dependencies with Yarn
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Install package.json dependencies with pnpm
run: pnpm install --frozen-lockfile

- name: Build Storybook
run: yarn build-storybook --quiet
run: pnpm build-storybook --quiet

- name: Install Playwright Browsers
run: npx playwright install --with-deps
run: pnpm dlx playwright install --with-deps

- name: Serve Storybook and run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port 6006 --silent" \
"npx wait-on tcp:6006 && npx playwright test"
pnpm dlx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"pnpm dlx http-server storybook-static --port 6006 --silent" \
"pnpm dlx wait-on tcp:6006 && pnpm dlx playwright test"
- name: Upload Playwright report
uses: actions/upload-artifact@v3
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

- name: Stop/Start stack with Docker Compose
run: |
docker compose -f docker-compose.dev.yml down
Expand Down Expand Up @@ -288,7 +299,7 @@ jobs:
$DOCKER_RUN ./bin/docker-server &> /tmp/logs/server.txt &
- name: Cypress run
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v4
with:
config-file: cypress.e2e.config.ts
config: retries=2
Expand Down
72 changes: 33 additions & 39 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,28 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm

- uses: actions/cache@v3
id: node-modules-cache
with:
path: |
node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules
- name: Install package.json dependencies with Yarn
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Install package.json dependencies with pnpm
run: pnpm install --frozen-lockfile

- name: Check formatting with prettier
run: yarn prettier:check
run: pnpm prettier:check

- name: Lint with ESLint
run: yarn eslint
run: pnpm eslint

- name: Generate logic types and run typescript with strict
run: yarn typegen:write && yarn typescript:check
run: pnpm typegen:write && pnpm typescript:check

jest-setup:
# Split the tests into multiple chunks
Expand All @@ -56,21 +52,22 @@ jobs:
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: node-modules-cache
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x
- name: Set up Node 16
uses: actions/setup-node@v3
with:
path: |
node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
- run: yarn install --frozen-lockfile
node-version: 16
cache: pnpm
- run: pnpm install --frozen-lockfile
- id: set-test-chunks
name: Set Chunks
# Looks at the output of 'yarn test --listTests --json'
# Take the 3rd line of the output (the first two are yarn non-sense)
# Looks at the output of 'pnpm test -- --listTests --json'
# Take the 5th line of the output (the first two are pnpm non-sense)
# Split the test into 3 parts. To increase the number split change the denominator in `length / 3`
run: echo "test-chunks=$(yarn test --listTests --json | sed -n 3p | jq -cM '[_nwise(length / 3 | ceil)]')" >> $GITHUB_OUTPUT
run: echo "test-chunks=$(pnpm test -- --listTests --json | sed -n 5p | jq -cM '[_nwise(length / 3 | ceil)]')" >> $GITHUB_OUTPUT
- id: set-test-chunk-ids
name: Set Chunk IDs
run: echo "test-chunk-ids=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
Expand All @@ -90,27 +87,24 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm

- uses: actions/cache@v3
id: node-modules-cache
with:
path: |
node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install package.json dependencies with Yarn
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Install package.json dependencies with pnpm
run: pnpm install --frozen-lockfile

- name: Test with Jest
# set maxWorkers or Jest only uses 1 CPU in GitHub Actions
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs yarn test --maxWorkers=2
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs pnpm test -- --maxWorkers=2
env:
NODE_OPTIONS: --max-old-space-size=6144
CHUNKS: ${{ needs.jest-setup.outputs['test-chunks'] }}
73 changes: 32 additions & 41 deletions .github/workflows/ci-plugin-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,25 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

- name: Install package.json dependencies with Yarn
run: yarn
- name: Install package.json dependencies with pnpm
run: pnpm install --frozen-lockfile

- name: Check formatting with prettier
run: yarn prettier:check
run: pnpm prettier:check

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

tests:
name: Tests (${{matrix.shard}})
Expand Down Expand Up @@ -109,28 +115,20 @@ jobs:
python -m pip install -r requirements-dev.txt
python -m pip install -r requirements.txt
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
cache-dependency-path: plugin-server/pnpm-lock.yaml

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
plugin-server/node_modules
key: plugin-server-yarn-${{ runner.os }}-${{ hashFiles('plugin-server/yarn.lock') }}
restore-keys: |
plugin-server-yarn-${{ runner.os }}
- name: Install package.json dependencies with Yarn
if: steps.yarn-cache.cache-hit != 'true'
run: cd plugin-server && yarn
- name: Install package.json dependencies with pnpm
run: cd plugin-server && pnpm i

- name: Wait for Clickhouse & Kafka
run: bin/check_kafka_clickhouse_up
Expand All @@ -140,14 +138,15 @@ jobs:
TEST: 'true'
SECRET_KEY: 'abcdef' # unsafe - for testing only
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
run: cd plugin-server && yarn setup:test
run: cd plugin-server && pnpm setup:test

- name: Test with Jest
env:
# Below DB name has `test_` prepended, as that's how Django (ran above) creates the test DB
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/test_posthog'
REDIS_URL: 'redis://localhost'
run: cd plugin-server && yarn test --runInBand --forceExit tests/ --shard=${{matrix.shard}}
NODE_OPTIONS: '--max_old_space_size=4096'
run: cd plugin-server && pnpm test -- --runInBand --forceExit tests/ --shard=${{matrix.shard}}

functional-tests:
name: Functional tests
Expand Down Expand Up @@ -191,31 +190,23 @@ jobs:
python -m pip install -r requirements-dev.txt
python -m pip install -r requirements.txt
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
cache-dependency-path: plugin-server/pnpm-lock.yaml

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
plugin-server/node_modules
key: plugin-server-yarn-${{ runner.os }}-${{ hashFiles('plugin-server/yarn.lock') }}
restore-keys: |
plugin-server-yarn-${{ runner.os }}
- name: Install package.json dependencies with Yarn
if: steps.yarn-cache.cache-hit != 'true'
- name: Install package.json dependencies with pnpm
run: |
cd plugin-server
yarn install --frozen-lockfile
yarn build
pnpm install --frozen-lockfile
pnpm build
- name: Wait for Clickhouse & Kafka
run: bin/check_kafka_clickhouse_up
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/storybook-chromatic-baselines-to-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ jobs:
with:
fetch-depth: 0 # 👈 Required to retrieve git history (https://www.chromatic.com/docs/github-actions)

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

# there's no need to run chromatic on every commit,
# so we only run it if the frontend has changed
- uses: dorny/paths-filter@v2
Expand All @@ -26,7 +37,7 @@ jobs:
- name: Install dependencies and chromatic
if: steps.changes.outputs.frontend == 'true'
run: yarn add --dev chromatic
run: pnpm add --save-dev chromatic

- name: Publish to Chromatic and auto accept changes to add baseline to master
# chromatic can't detect accepted baseline because we do squash merges
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/storybook-chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ jobs:
with:
fetch-depth: 0 # 👈 Required to retrieve git history (https://www.chromatic.com/docs/github-actions)

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x.x

- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm

# there's no need to run chromatic on every commit,
# so we only run it if the frontend has changed
- uses: dorny/paths-filter@v2
Expand All @@ -23,7 +34,7 @@ jobs:
- name: Install dependencies and chromatic
if: steps.changes.outputs.frontend == 'true'
run: yarn add --dev chromatic
run: pnpm i -D chromatic

- name: Publish to Chromatic
if: steps.changes.outputs.frontend == 'true'
Expand Down
Loading

0 comments on commit 4a30e78

Please sign in to comment.