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

chore: convert to pnpm #970

Merged
merged 13 commits into from
Jan 26, 2024
28 changes: 25 additions & 3 deletions .github/workflows/bundled-size.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2

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

- name: Get pnpm cache directory path
id: pnpm-cache-dir
run: echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: pnpm-cache
with:
build-script: "build-rollup"
compression: "none"
path: ${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-

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

# auto selects yarn because yarn.lock exists in master :/
# need to re-enable _after_ moving to pnpm
# - uses: preactjs/compressed-size-action@v2
# with:
# build-script: "build-rollup"
# compression: "none"
24 changes: 20 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,35 @@ jobs:
PUBLISHED_VERSION: ${{ needs.check-package-version.outputs.published-version }}
steps:
- name: Checkout the repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}

- uses: pnpm/action-setup@v2
with:
version: 8.x.x

- name: Set up Node 18
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: yarn --frozen-lockfile
- name: Get pnpm cache directory path
id: pnpm-cache-dir
run: echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: pnpm-cache
with:
path: |
${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install package.json dependencies with pnpm
run: pnpm install --frozen-lockfile

- name: Publish the package in the npm registry
run: npm publish --access public
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/label-version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ jobs:
)
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 8.x.x

- name: Detect version bump type
id: bump-type
run: |
Expand Down Expand Up @@ -66,8 +70,8 @@ jobs:
echo -e "$CHANGELOG_HEADING\n\n$CHANGELOG_POINTS\n\n$(cat CHANGELOG.old.md)" > CHANGELOG.md
rm CHANGELOG.old.md

- name: Update yarn.lock
run: yarn
- name: Update lockfile
run: pnpm i

- name: Commit bump
if: steps.bump-type.outputs.bump-type != 'null'
Expand Down
96 changes: 53 additions & 43 deletions .github/workflows/library-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,71 +11,81 @@ jobs:
name: Unit tests
runs-on: ubuntu-latest
steps:
# Check out the repository
- uses: actions/checkout@v3

# Install Node.js
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
node-version: 18
cache: 'yarn'

# Install your dependencies
- run: yarn install

- run: yarn test
version: 8.x.x
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- run: pnpm install
- run: pnpm test

integration:
name: Cypress
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8.x.x
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
node-version: '18'
- name: Get pnpm cache directory path
id: pnpm-cache-dir
run: echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- run: yarn install && yarn build
- name: Get cypress cache directory path
id: cypress-cache-dir
run: echo "CYPRESS_BIN_PATH=$(npx cypress cache path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: pnpm-cache
with:
path: |
${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }}
${{ steps.cypress-cache-dir.outputs.CYPRESS_BIN_PATH }}
key: ${{ runner.os }}-pnpm-cypress-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-cypress-
- name: Install package.json dependencies with pnpm
run: pnpm install --frozen-lockfile
- run: pnpm build
- name: Cypress run
uses: cypress-io/github-action@v6

functional:
name: Functional tests
runs-on: ubuntu-latest
steps:
# Check out the repository
- uses: actions/checkout@v3

# Install Node.js
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
node-version: 18
cache: 'yarn'

# Install your dependencies
- run: yarn install

- run: yarn jest functional_tests/
version: 8.x.x
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- run: pnpm install
- run: pnpm jest functional_tests/

lint:
name: Lint
runs-on: ubuntu-latest
steps:
# Check out the repository
- uses: actions/checkout@v3

# Install Node.js
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
node-version: 18
cache: 'yarn'

# Install your dependencies
- run: yarn install
version: 8.x.x
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- run: pnpm install

- run: |
yarn prettier --check
yarn lint
yarn tsc -b
pnpm prettier --check
pnpm lint
pnpm tsc -b
13 changes: 8 additions & 5 deletions .github/workflows/react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ jobs:
name: Test with React
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
node-version: 18
cache: 'yarn'
- run: yarn && yarn build && cd react && yarn test
version: 8.x.x
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- run: pnpm install && pnpm build && cd react && pnpm test
14 changes: 8 additions & 6 deletions .github/workflows/ssr-es-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ jobs:
name: Cypress
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
node-version: 18
cache: 'yarn'

version: 8.x.x
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'

- run: yarn install && yarn build
- run: pnpm install && pnpm build

- name: Run es-check to check if our bundle is ES5 compatible
run: npx [email protected] es5 dist/{array,module}.js
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/testcafe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ jobs:
name: Safari

steps:
- name: Check out posthog-js
uses: actions/checkout@v2

- name: Set up Node 18
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8.x.x
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
node-version: '18'
cache: 'pnpm'

- name: Serve static files
run: python -m http.server 8080 &

- name: Install node dependencies
run: yarn
run: pnpm install

- name: Set up posthog-js
run: yarn build-rollup
run: pnpm build-rollup

- name: Run ${{ matrix.name }} test
run: node scripts/run-testcafe-with-retries.mjs --browser "browserstack:${{ matrix.browserstack }}" --attempts 3
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This README is intended for developing the library itself.

## Testing

Unit tests: run `yarn test`.
Cypress: run `yarn start` to have a test server running and separately `yarn cypress` to launch Cypress test engine.
Unit tests: run `pnpm test`.
Cypress: run `pnpm start` to have a test server running and separately `pnpm cypress` to launch Cypress test engine.

### Running TestCafe E2E tests with BrowserStack

Expand All @@ -28,7 +28,7 @@ in your shell env variables.

After all this, you'll be able to run through the below steps:

1. Optional: rebuild array.js on changes: `nodemon -w src/ --exec bash -c "yarn build-rollup"`.
1. Optional: rebuild array.js on changes: `nodemon -w src/ --exec bash -c "pnpm build-rollup"`.
1. Export browserstack credentials: `export BROWSERSTACK_USERNAME=xxx BROWSERSTACK_ACCESS_KEY=xxx`.
1. Run tests: `npx testcafe "browserstack:ie" testcafe/e2e.spec.js`.

Expand All @@ -39,7 +39,7 @@ You can use the create react app setup in `playground/nextjs` to test posthog-js
1. Run `posthog` locally on port 8000 (`DEBUG=1 TEST=1 ./bin/start`).
2. Run `python manage.py setup_dev --no-data` on posthog repo, which sets up a demo account.
3. Copy posthog token found in `http://localhost:8000/project/settings` and then
4. `cd playground/nextjs`and run `NEXT_PUBLIC_POSTHOG_KEY='<your-local-api-key>' yarn dev`
4. `cd playground/nextjs`and run `NEXT_PUBLIC_POSTHOG_KEY='<your-local-api-key>' pnpm dev`

### Tiers of testing

Expand Down
Loading
Loading