Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Switch to pnpm #508

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20.x'
- run: npm install
- run: npm run build
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
- run: pnpm install
- run: pnpm run build

# Go through all open PRs and run the bot over them
- run: node ./dist/run.js
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}

- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0

- name: Install and test
run: |
npm install
npm run build --if-present
npm run test --if-present
pnpm install
pnpm run build --if-present
pnpm run test --if-present

- name: Bundle
run: pnpm run bundle

- name: Build zip
run: npm run bundle
- name: Check bundle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this isn't related to the pnpm check? Seems like we just weren't doing it on deploy before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct; an oversight in my last PR to bundle instead of uploading node_modules.

run: BOT_AUTH_TOKEN=secret node dist/functions/index.js

- name: Create zip
run: zip -r ${{ env.FUNCTION_ZIP_NAME }} dist host.json package.json
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20.x'
- run: npm install
- run: npm run lint
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
- run: pnpm install
- run: pnpm run lint
- run: npx knip
test:
strategy:
Expand All @@ -29,12 +30,9 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20.x'
- run: npm install
- run: npm run build
- run: npm test
- run: npm prune --production
- run: |
export BOT_AUTH_TOKEN=secret
for i in dist/functions/*.js; do
node $i;
done
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
- run: pnpm install
- run: pnpm run build
- run: pnpm test
- run: pnpm run bundle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to bundle now when we didn't before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also an oversight in my last PR; we used to in this check test the compiled code, but that doesn't really matter, we want to verify that the bundle we're going to send to Azure even runs, just as an extra safety check.

- run: BOT_AUTH_TOKEN=secret node dist/functions/index.js
3 changes: 2 additions & 1 deletion .knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"src/commands/*.ts",
"src/functions/*.ts",
"src/scripts/*.ts",
"src/_tests/testEnvironment.js"
"src/_tests/testEnvironment.js",
"apollo.config.js"
],
"project": [
"**/*.{js,ts,tsx}"
Expand Down
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,5 @@
"**/.DS_Store": true,
"**/bin": true
},
"azureFunctions.deploySubpath": ".",
"azureFunctions.projectLanguage": "TypeScript",
"azureFunctions.projectRuntime": "~3",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "npm prune"
"debug.internalConsoleOptions": "neverOpen"
}
19 changes: 6 additions & 13 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,19 @@
"command": "host start",
"problemMatcher": "$func-watch",
"isBackground": true,
"dependsOn": "npm build"
"dependsOn": "pnpm build"
},
{
"type": "shell",
"label": "npm build",
"command": "npm run build",
"dependsOn": "npm install",
"label": "pnpm build",
"command": "pnpm run build",
"dependsOn": "pnpm install",
"problemMatcher": "$tsc"
},
{
"type": "shell",
"label": "npm install",
"command": "npm install"
},
{
"type": "shell",
"label": "npm prune",
"command": "npm prune --production",
"dependsOn": "npm build",
"problemMatcher": []
"label": "pnpm install",
"command": "pnpm install"
}
]
}
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ git clone https://github.com/DefinitelyTyped/dt-mergebot.git
cd dt-mergebot

# Deps
npm install
pnpm install

# Validate it works
npm test
pnpm test
```

# How the app works
Expand Down Expand Up @@ -60,12 +60,12 @@ Then to run locally you'll need to install the [Azure Functions cli](https://doc

```sh
# Build
npm run build
pnpm run build

# Run the CLI to see what would happen to an existing PR
npm run single-info -- [PR_NUM]
pnpm run single-info -- [PR_NUM]
# or
npm run single-info-debug -- [PR_NUM]
pnpm run single-info-debug -- [PR_NUM]
```

### If you update any queries
Expand All @@ -74,7 +74,7 @@ Run this to update the generate types:

```sh
# Code-gen the schema
npm run graphql-schema
pnpm run graphql-schema
```

### If you change project columns or labels
Expand All @@ -83,14 +83,14 @@ Run this to update the cached values:

```sh
# Regenerate src/_tests/cachedQueries.json
npm run update-test-data
pnpm run update-test-data
```

# Tests

```sh
# Run tests, TypeScript is transpiled at runtime
npm test
pnpm test
```

Most of the tests run against a fixtured PR, these are high level integration tests that store the PR info and then re-run the latter two phases of the app.
Expand All @@ -99,16 +99,16 @@ To create fixtures of a current PR:

```sh
# To create a fixture for PR 43161
npm run create-fixture -- 43161
pnpm run create-fixture -- 43161
```

Then you can work against these fixtures offline with:

```sh
# Watch mode for all tests
npm test -- --watch
pnpm test -- --watch
# Just run fixtures for one PR
npm test -- --testNamePattern 44299
pnpm test -- --testNamePattern 44299
```

Run a test with the debugger:
Expand All @@ -122,7 +122,7 @@ Then use "Attach to Process ID" to connect to that test runner
If your changes require re-creating all fixtures:

```sh
npm run update-all-fixtures
pnpm run update-all-fixtures
```

Be careful with this, because PRs may now be in a different state e.g. it's now merged and it used to be a specific
Expand Down
Loading