You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-208Lines changed: 1 addition & 208 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,214 +93,7 @@ More information about Storybook can be found inside the **Overview** page once
93
93
94
94
### Testing
95
95
96
-
We have several types of tests:
97
-
98
-
* Unit tests: these live in the `tests/unit-tests/` directory
99
-
* View tests: these live in `src/view/variant-analysis/__tests__/`
100
-
* VSCode integration tests:
101
-
*`test/vscode-tests/activated-extension` tests: These are intended to cover functionality that require the full extension to be activated but don't require the CLI. This suite is not run against multiple versions of the CLI in CI.
102
-
*`test/vscode-tests/no-workspace` tests: These are intended to cover functionality around not having a workspace. The extension is not activated in these tests.
103
-
*`test/vscode-tests/minimal-workspace` tests: These are intended to cover functionality that need a workspace but don't require the full extension to be activated.
104
-
* CLI integration tests: these live in `test/vscode-tests/cli-integration`
105
-
* These tests are intended to cover functionality that is related to the integration between the CodeQL CLI and the extension. These tests are run against each supported versions of the CLI in CI.
106
-
107
-
The CLI integration tests require an instance of the CodeQL CLI to run so they will require some extra setup steps. When adding new tests to our test suite, please be mindful of whether they need to be in the cli-integration folder. If the tests don't depend on the CLI, they are better suited to being a VSCode integration test.
108
-
109
-
Any test data you're using (sample projects, config files, etc.) must go in a `test/vscode-tests/*/data` directory. When you run the tests, the test runner will copy the data directory to `out/vscode-tests/*/data`.
110
-
111
-
#### Running the tests
112
-
113
-
Pre-requisites:
114
-
1. Run `npm run build`.
115
-
2. You will need to have `npm run watch` running in the background.
116
-
117
-
##### 1. From the terminal
118
-
119
-
Then, from the `extensions/ql-vscode` directory, use the appropriate command to run the tests:
120
-
121
-
* Unit tests: `npm run test:unit`
122
-
* View Tests: `npm test:view`
123
-
* VSCode integration tests: `npm run test:vscode-integration`
124
-
125
-
###### CLI integration tests
126
-
127
-
The CLI integration tests require the CodeQL standard libraries in order to run so you will need to clone a local copy of the `github/codeql` repository.
128
-
129
-
1. Set the `TEST_CODEQL_PATH` environment variable: running from a terminal, you _must_ set the `TEST_CODEQL_PATH` variable to point to a checkout of the `github/codeql` repository. The appropriate CLI version will be downloaded as part of the test.
130
-
131
-
2. Run your test command:
132
-
133
-
```shell
134
-
cd extensions/ql-vscode && npm run test:cli-integration
135
-
```
136
-
137
-
##### 2. From VSCode
138
-
139
-
Alternatively, you can run the tests inside of VSCode. There are several VSCode launch configurations defined that run the unit and integration tests.
140
-
141
-
You will need to run tests using a task from inside of VS Code, under the "Run and Debug" view:
142
-
143
-
* Unit tests: run the _Launch Unit Tests - React_ task
144
-
* View Tests: run the _Launch Unit Tests_ task
145
-
* VSCode integration tests: run the _Launch Unit Tests - No Workspace_ and _Launch Unit Tests - Minimal Workspace_ tasks
146
-
147
-
###### CLI integration tests
148
-
149
-
The CLI integration tests require the CodeQL standard libraries in order to run so you will need to clone a local copy of the `github/codeql` repository.
150
-
151
-
1. Set the `TEST_CODEQL_PATH` environment variable: running from a terminal, you _must_ set the `TEST_CODEQL_PATH` variable to point to a checkout of the `github/codeql` repository. The appropriate CLI version will be downloaded as part of the test.
152
-
153
-
2. Set the codeql path in VSCode's launch configuration: open `launch.json` and under the _Launch Integration Tests - With CLI_ section, uncomment the `"${workspaceRoot}/../codeql"` line. If you've cloned the `github/codeql` repo to a different path, replace the value with the correct path.
154
-
155
-
3. Run the VSCode task from the "Run and Debug" view called _Launch Integration Tests - With CLI_.
156
-
157
-
#### Running a single test
158
-
159
-
##### 1. From the terminal
160
-
161
-
The easiest way to run a single test is to change the `it` of the test to `it.only` and then run the test command with some additional options
162
-
to only run tests for this specific file. For example, to run the test `test/vscode-tests/cli-integration/run-queries.test.ts`:
163
-
164
-
```shell
165
-
npm run test:cli-integration -- --runTestsByPath test/vscode-tests/cli-integration/run-queries.test.ts
166
-
```
167
-
168
-
You can also use the `--testNamePattern` option to run a specific test within a file. For example, to run the test `test/vscode-tests/cli-integration/run-queries.test.ts`:
169
-
170
-
```shell
171
-
npm run test:cli-integration -- --runTestsByPath test/vscode-tests/cli-integration/run-queries.test.ts --testNamePattern "should create a QueryEvaluationInfo"
172
-
```
173
-
174
-
##### 2. From VSCode
175
-
176
-
Alternatively, you can run a single test inside VSCode. To do so, install the [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) extension. Then,
177
-
you will have quicklinks to run a single test from within test files. To run a single unit or integration test, click the "Run" button. Debugging a single test is currently only supported
178
-
for unit tests by default. To debug integration tests, open the `.vscode/settings.json` file and uncomment the `jestrunner.debugOptions` lines. This will allow you to debug integration tests.
179
-
Please make sure to revert this change before committing; with this setting enabled, it is not possible to debug unit tests.
180
-
181
-
Without the Jest Runner extension, you can also use the "Launch Selected Unit Test (vscode-codeql)" launch configuration to run a single unit test.
182
-
183
-
#### Using a mock GitHub API server
184
-
185
-
Multi-Repo Variant Analyses (MRVA) rely on the GitHub API. In order to make development and testing easy, we have functionality that allows us to intercept requests to the GitHub API and provide mock responses.
186
-
187
-
##### Using a pre-recorded test scenario
188
-
189
-
To run a mock MRVA scenario, follow these steps:
190
-
1. Enable the mock GitHub API server by adding the following in your VS Code user settings (which can be found by running the `Preferences: Open User Settings (JSON)` VS Code command):
191
-
```json
192
-
"codeQL.mockGitHubApiServer": {
193
-
"enabled": true
194
-
}
195
-
```
196
-
197
-
1. Run the `CodeQL: Mock GitHub API Server: Load Scenario` command from the command pallet, and choose one of the scenarios to load.
198
-
1. Execute a normal MRVA. At this point you should see the scenario being played out, rather than an actual MRVA running.
199
-
1. Once you're done, you can stop using the mock scenario with `CodeQL: Mock GitHub API Server: Unload Scenario`
200
-
201
-
If you want to replay the same scenario you should unload and reload it so requests are replayed from the start.
202
-
203
-
##### Recording a new test scenario
204
-
To record a new mock MRVA scenario, follow these steps:
205
-
206
-
1. Enable the mock GitHub API server by adding the following in your VS Code user settings (which can be found by running the `Preferences: Open User Settings (JSON)` VS Code command):
207
-
```json
208
-
"codeQL.mockGitHubApiServer": {
209
-
"enabled": true
210
-
}
211
-
```
212
-
213
-
1. Run the `CodeQL: Mock GitHub API Server: Start Scenario Recording` VS Code command from the command pallet.
214
-
1. Execute a normal MRVA.
215
-
1. Once what you wanted to record is done (e.g. the MRVA has finished), then run the `CodeQL: Mock GitHub API Server: Save Scenario` command from the command pallet.
216
-
1. The scenario should then be available for replaying.
217
-
218
-
If you want to cancel recording, run the `CodeQL: Mock GitHub API Server: Cancel Scenario Recording` command.
219
-
220
-
Once the scenario has been recorded, it's often useful to remove some of the requests to speed up the replay, particularly ones that fetch the variant analysis status. Once some of the request files have manually been removed, the [fix-scenario-file-numbering script](./extensions/ql-vscode/scripts/fix-scenario-file-numbering.ts) can be used to update the number of the files. See the script file for details on how to use.
221
-
222
-
#### Scenario data location
223
-
224
-
Pre-recorded scenarios are stored in `./src/mocks/scenarios`. However, it's possible to configure the location, by setting the `codeQL.mockGitHubApiServer.scenariosPath` configuration property in the VS Code user settings.
225
-
226
-
## Releasing (write access required)
227
-
228
-
1. Go through [our test plan](/extensions/ql-vscode/docs/test-plan.md) to ensure that the extension is working as expected.
229
-
1. Double-check the `CHANGELOG.md` contains all desired change comments and has the version to be released with date at the top.
230
-
* Go through all recent PRs and make sure they are properly accounted for.
231
-
* Make sure all changelog entries have links back to their PR(s) if appropriate.
232
-
* For picking the new version number, we default to increasing the patch version number, but make our own judgement about whether a change is big enough to warrant a minor version bump. Common reasons for a minor bump could include:
233
-
* Making substantial new features available to all users. This can include lifting a feature flag.
234
-
* Breakage in compatibility with recent versions of the CLI.
235
-
* Minimum required version of VS Code is increased.
236
-
* New telemetry events are added.
237
-
* Deprecation or removal of commands.
238
-
* Accumulation of many changes, none of which are individually big enough to warrant a minor bump, but which together are. This does not include changes which are purely internal to the extension, such as refactoring, or which are only available behind a feature flag.
239
-
1. Double-check that the node version we're using matches the one used for VS Code. If it doesn't, you will then need to update the node version in the following files:
240
-
*`.nvmrc` - this will enable `nvm` to automatically switch to the correct node version when you're in the project folder
241
-
*`.github/workflows/main.yml` - all the "node-version: <version>" settings
242
-
*`.github/workflows/release.yml` - the "node-version: <version>" setting
243
-
1. Double-check that the extension `package.json` and `package-lock.json` have the version you intend to release. If you are doing a patch release (as opposed to minor or major version) this should already be correct.
244
-
1. Create a PR for this release:
245
-
* This PR will contain any missing bits from steps 1 and 2. Most of the time, this will just be updating `CHANGELOG.md` with today's date.
246
-
* Create a new branch for the release named after the new version. For example: `v1.3.6`
247
-
* Create a new commit with a message the same as the branch name.
248
-
* Create a PR for this branch.
249
-
* Wait for the PR to be merged into `main`
250
-
1. Switch to `main` and add a new tag on the `main` branch with your new version (named after the release), e.g.
251
-
```bash
252
-
git checkout main
253
-
git tag v1.3.6
254
-
```
255
-
256
-
If you've accidentally created a badly named tag, you can delete it via
257
-
```bash
258
-
git tag -d badly-named-tag
259
-
```
260
-
1. Push the new tag up:
261
-
262
-
a. If you're using a fork of the repo:
263
-
264
-
```bash
265
-
git push upstream refs/tags/v1.3.6
266
-
```
267
-
268
-
b. If you're working straight in this repo:
269
-
270
-
```bash
271
-
git push origin refs/tags/v1.3.6
272
-
```
273
-
274
-
This will trigger [a release build](https://github.com/github/vscode-codeql/releases) on Actions.
275
-
276
-
* **IMPORTANT** Make sure you are on the `main` branch and your local checkout is fully updated when you add the tag.
277
-
* If you accidentally add the tag to the wrong ref, you can just force push it to the right one later.
278
-
1. Monitor the status of the release build in the `Release` workflow in the Actions tab.
279
-
* DO NOT approve the "publish" stages of the workflow yet.
280
-
1. Download the VSIX from the draft GitHub release at the top of [the releases page](https://github.com/github/vscode-codeql/releases) that is created when the release build finishes.
281
-
1. Unzip the `.vsix` and inspect its `package.json` to make sure the version is what you expect,
282
-
or look at the source if there's any doubt the right code is being shipped.
283
-
1. Install the `.vsix` file into your vscode IDE and ensure the extension can load properly. Run a single command (like run query, or add database).
284
-
1. Go to the actions tab of the vscode-codeql repository and selectthe [Release workflow](https://github.com/github/vscode-codeql/actions?query=workflow%3ARelease).
285
-
- If there is an authentication failure when publishing, be sure to check that the authentication keys haven't expired. See below.
286
-
1. Approve the deployments of the correct Release workflow. This will automatically publish to Open VSX and VS Code Marketplace.
287
-
1. Go to the draft GitHub release in [the releases tab of the repository](https://github.com/github/vscode-codeql/releases), click 'Edit', add some summary description, and publish it.
288
-
1. Confirm the new release is marked as the latest release at <https://github.com/github/vscode-codeql/releases>.
289
-
1. If documentation changes need to be published, notify documentation team that release has been made.
290
-
1. Review and merge the version bump PR that is automatically created by Actions.
291
-
292
-
## Secrets and authentication for publishing
293
-
294
-
Repository administrators, will need to manage the authentication keys for publishing to the VS Code marketplace and Open VSX. Each requires an authentication token. The VS Code marketplace token expires yearly.
295
-
296
-
To regenerate the Open VSX token:
297
-
298
-
1. Log in to the [user settings page on Open VSX](https://open-vsx.org/user-settings/namespaces).
299
-
1. Make sure you are a member of the GitHub namespace.
300
-
1. Go to the [Access Tokens](https://open-vsx.org/user-settings/tokens) page and generate a new token.
301
-
1. Update the secret in the `publish-open-vsx` environment in the project settings.
302
-
303
-
To regenerate the VSCode Marketplace token, please see our internal documentation. Note that Azure DevOps PATs expire every 90 days and must be regenerated.
96
+
Information about testing can be found [here](./docs/testing.md).
1. Go through [our test plan](./test-plan.md) to ensure that the extension is working as expected.
4
+
1. Double-check the `CHANGELOG.md` contains all desired change comments and has the version to be released with date at the top.
5
+
* Go through all recent PRs and make sure they are properly accounted for.
6
+
* Make sure all changelog entries have links back to their PR(s) if appropriate.
7
+
* For picking the new version number, we default to increasing the patch version number, but make our own judgement about whether a change is big enough to warrant a minor version bump. Common reasons for a minor bump could include:
8
+
* Making substantial new features available to all users. This can include lifting a feature flag.
9
+
* Breakage in compatibility with recent versions of the CLI.
10
+
* Minimum required version of VS Code is increased.
11
+
* New telemetry events are added.
12
+
* Deprecation or removal of commands.
13
+
* Accumulation of many changes, none of which are individually big enough to warrant a minor bump, but which together are. This does not include changes which are purely internal to the extension, such as refactoring, or which are only available behind a feature flag.
14
+
1. Double-check that the node version we're using matches the one used for VS Code. If it doesn't, you will then need to update the node version in the following files:
15
+
*`.nvmrc` - this will enable `nvm` to automatically switch to the correct node version when you're in the project folder
16
+
*`.github/workflows/main.yml` - all the "node-version: <version>" settings
17
+
*`.github/workflows/release.yml` - the "node-version: <version>" setting
18
+
1. Double-check that the extension `package.json` and `package-lock.json` have the version you intend to release. If you are doing a patch release (as opposed to minor or major version) this should already be correct.
19
+
1. Create a PR for this release:
20
+
* This PR will contain any missing bits from steps 1 and 2. Most of the time, this will just be updating `CHANGELOG.md` with today's date.
21
+
* Create a new branch for the release named after the new version. For example: `v1.3.6`
22
+
* Create a new commit with a message the same as the branch name.
23
+
* Create a PR for this branch.
24
+
* Wait for the PR to be merged into `main`
25
+
1. Switch to `main` and add a new tag on the `main` branch with your new version (named after the release), e.g.
26
+
```bash
27
+
git checkout main
28
+
git tag v1.3.6
29
+
```
30
+
31
+
If you've accidentally created a badly named tag, you can delete it via
32
+
```bash
33
+
git tag -d badly-named-tag
34
+
```
35
+
1. Push the new tag up:
36
+
37
+
a. If you're using a fork of the repo:
38
+
39
+
```bash
40
+
git push upstream refs/tags/v1.3.6
41
+
```
42
+
43
+
b. If you're working straight in this repo:
44
+
45
+
```bash
46
+
git push origin refs/tags/v1.3.6
47
+
```
48
+
49
+
This will trigger [a release build](https://github.com/github/vscode-codeql/releases) on Actions.
50
+
51
+
* **IMPORTANT** Make sure you are on the `main` branch and your local checkout is fully updated when you add the tag.
52
+
* If you accidentally add the tag to the wrong ref, you can just force push it to the right one later.
53
+
1. Monitor the status of the release build in the `Release` workflow in the Actions tab.
54
+
* DO NOT approve the "publish" stages of the workflow yet.
55
+
1. Download the VSIX from the draft GitHub release at the top of [the releases page](https://github.com/github/vscode-codeql/releases) that is created when the release build finishes.
56
+
1. Unzip the `.vsix` and inspect its `package.json` to make sure the version is what you expect,
57
+
or look at the source if there's any doubt the right code is being shipped.
58
+
1. Install the `.vsix` file into your vscode IDE and ensure the extension can load properly. Run a single command (like run query, or add database).
59
+
1. Go to the actions tab of the vscode-codeql repository and selectthe [Release workflow](https://github.com/github/vscode-codeql/actions?query=workflow%3ARelease).
60
+
- If there is an authentication failure when publishing, be sure to check that the authentication keys haven't expired. See below.
61
+
1. Approve the deployments of the correct Release workflow. This will automatically publish to Open VSX and VS Code Marketplace.
62
+
1. Go to the draft GitHub release in [the releases tab of the repository](https://github.com/github/vscode-codeql/releases), click 'Edit', add some summary description, and publish it.
63
+
1. Confirm the new release is marked as the latest release at <https://github.com/github/vscode-codeql/releases>.
64
+
1. If documentation changes need to be published, notify documentation team that release has been made.
65
+
1. Review and merge the version bump PR that is automatically created by Actions.
66
+
67
+
## Secrets and authentication for publishing
68
+
69
+
Repository administrators, will need to manage the authentication keys for publishing to the VS Code marketplace and Open VSX. Each requires an authentication token. The VS Code marketplace token expires yearly.
70
+
71
+
To regenerate the Open VSX token:
72
+
73
+
1. Log in to the [user settings page on Open VSX](https://open-vsx.org/user-settings/namespaces).
74
+
1. Make sure you are a member of the GitHub namespace.
75
+
1. Go to the [Access Tokens](https://open-vsx.org/user-settings/tokens) page and generate a new token.
76
+
1. Update the secret in the `publish-open-vsx` environment in the project settings.
77
+
78
+
To regenerate the VSCode Marketplace token, please see our internal documentation. Note that Azure DevOps PATs expire every 90 days and must be regenerated.
0 commit comments