Skip to content

Commit ead1fb4

Browse files
committed
Merge branch 'main' into asgerf/navigate-alerts
2 parents 0acf9f7 + 4e5abee commit ead1fb4

File tree

105 files changed

+6087
-1301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+6087
-1301
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
- uses: actions/setup-node@v1
2424
with:
25-
node-version: '16.14.0'
25+
node-version: '16.14.2'
2626

2727
- name: Install dependencies
2828
working-directory: extensions/ql-vscode
@@ -139,7 +139,7 @@ jobs:
139139
strategy:
140140
matrix:
141141
os: [ubuntu-latest, windows-latest]
142-
version: ['v2.6.3', 'v2.7.6', 'v2.8.5', 'v2.9.4', 'v2.10.5', 'v2.11.0', 'nightly']
142+
version: ['v2.7.6', 'v2.8.5', 'v2.9.4', 'v2.10.5', 'v2.11.1', 'nightly']
143143
env:
144144
CLI_VERSION: ${{ matrix.version }}
145145
NIGHTLY_URL: ${{ needs.find-nightly.outputs.url }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
- uses: actions/setup-node@v1
2424
with:
25-
node-version: '16.14.0'
25+
node-version: '16.14.2'
2626

2727
- name: Install dependencies
2828
run: |

CODEOWNERS

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
**/* @github/codeql-vscode-reviewers
2-
/extensions/ql-vscode/src/remote-queries/ @github/code-scanning-secexp-reviewers
3-
/extensions/ql-vscode/src/view/remote-queries/ @github/code-scanning-secexp-reviewers
4-
/extensions/ql-vscode/src/view/variant-analysis/ @github/code-scanning-secexp-reviewers
2+
**/remote-queries/ @github/code-scanning-secexp-reviewers
3+
**/variant-analysis/ @github/code-scanning-secexp-reviewers

CONTRIBUTING.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,58 @@ Alternatively, you can start Storybook inside of VSCode. There is a VSCode launc
9191

9292
More information about Storybook can be found inside the **Overview** page once you have launched Storybook.
9393

94-
### Running the unit tests and integration tests that do not require a CLI instance
94+
### Testing
9595

96-
Unit tests and many integration tests do not require a copy of the CodeQL CLI.
96+
We have several types of tests:
9797

98-
Outside of vscode, in the `extensions/ql-vscode` directory, run:
98+
* Unit tests: these live in the `tests/pure-tests/` directory
99+
* View tests: these live in `src/view/variant-analysis/__tests__/`
100+
* VSCode integration tests: these live in `src/vscode-tests/no-workspace` and `src/vscode-tests/minimal-workspace`
101+
* CLI integration tests: these live in `src/vscode-tests/cli-integration`
102+
103+
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.
104+
105+
#### Running the tests
106+
107+
##### 1. From the terminal
108+
109+
First move into the `extensions/ql-vscode` directory. Then, depending on which tests you want to run, use the appropriate command to run the tests:
110+
111+
* Unit tests: `npm run test:unit`
112+
* View Tests: `npm test:view`
113+
* VSCode integration tests: `npm run integration`
114+
115+
###### CLI integration tests
116+
117+
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.
118+
119+
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.
120+
121+
2. Run your test command:
99122

100123
```shell
101-
npm run test && npm run integration
124+
cd extensions/ql-vscode && npm run cli-integration
102125
```
103126

104-
Alternatively, you can run the tests inside of vscode. There are several vscode launch configurations defined that run the unit and integration tests. They can all be found in the debug view.
127+
##### 2. From VSCode
105128

106-
Only the _With CLI_ tests require a CLI instance to run. See below on how to do that.
129+
Alternatively, you can run the tests inside of VSCode. There are several VSCode launch configurations defined that run the unit and integration tests.
107130

108-
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.
131+
You will need to run tests using a task from inside of VS Code, under the "Run and Debug" view:
109132

110-
### Running the integration tests
133+
* Unit tests: run the _Launch Unit Tests - React_ task
134+
* View Tests: run the _Launch Unit Tests_ task
135+
* VSCode integration tests: run the _Launch Unit Tests - No Workspace_ and _Launch Unit Tests - Minimal Workspace_ tasks
111136

112-
You will need to run CLI tests using a task from inside of VS Code called _Launch Integration Tests - With CLI_.
137+
###### CLI integration tests
113138

114139
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.
115140

116-
From inside of VSCode, open the `launch.json` file and in the _Launch Integration Tests - With CLI_ task, uncomment the `"${workspaceRoot}/../codeql"` line. If necessary, replace value with a path to your checkout, and then run the task.
141+
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.
142+
143+
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.
144+
145+
3. Run the VSCode task from the "Run and Debug" view called _Launch Integration Tests - With CLI_.
117146

118147
## Releasing (write access required)
119148

@@ -137,7 +166,7 @@ From inside of VSCode, open the `launch.json` file and in the _Launch Integratio
137166
git tag v1.3.6
138167
```
139168

140-
If you've accidentally created a badly named tag, you can delete it via
169+
If you've accidentally created a badly named tag, you can delete it via
141170
```bash
142171
git tag -d badly-named-tag
143172
```
@@ -148,13 +177,13 @@ From inside of VSCode, open the `launch.json` file and in the _Launch Integratio
148177
```bash
149178
git push upstream refs/tags/v1.3.6
150179
```
151-
180+
152181
b. If you're working straight in this repo:
153182
154183
```bash
155184
git push origin refs/tags/v1.3.6
156-
```
157-
185+
```
186+
158187
This will trigger [a release build](https://github.com/github/vscode-codeql/releases) on Actions.
159188
160189
* **IMPORTANT** Make sure you are on the `main` branch and your local checkout is fully updated when you add the tag.

extensions/ql-vscode/.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.14.0
1+
v16.14.2

extensions/ql-vscode/.storybook/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const config: StorybookConfig = {
88
addons: [
99
'@storybook/addon-links',
1010
'@storybook/addon-essentials',
11-
'@storybook/addon-interactions'
11+
'@storybook/addon-interactions',
12+
'./vscode-theme-addon/preset.ts',
1213
],
1314
framework: '@storybook/react',
1415
core: {

extensions/ql-vscode/.storybook/preview.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { action } from '@storybook/addon-actions';
44
// Allow all stories/components to use Codicons
55
import '@vscode/codicons/dist/codicon.css';
66

7-
import '../src/stories/vscode-theme.css';
8-
97
// https://storybook.js.org/docs/react/configure/overview#configure-story-rendering
108
export const parameters = {
119
// All props starting with `on` will automatically receive an action as a prop
@@ -22,16 +20,12 @@ export const parameters = {
2220
theme: themes.dark,
2321
},
2422
backgrounds: {
25-
default: 'dark',
26-
values: [
27-
{
28-
name: 'dark',
29-
value: '#1e1e1e',
30-
},
31-
],
23+
// The background is injected by our theme CSS files
24+
disable: true,
3225
}
3326
};
3427

3528
(window as any).acquireVsCodeApi = () => ({
36-
postMessage: action('post-vscode-message')
29+
postMessage: action('post-vscode-message'),
30+
setState: action('set-vscode-state'),
3731
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"moduleResolution": "node",
5+
"target": "es6",
6+
"outDir": "out",
7+
"lib": ["ES2021", "dom"],
8+
"jsx": "react",
9+
"sourceMap": true,
10+
"rootDir": "..",
11+
"strict": true,
12+
"noUnusedLocals": true,
13+
"noImplicitReturns": true,
14+
"noFallthroughCasesInSwitch": true,
15+
"experimentalDecorators": true,
16+
"skipLibCheck": true
17+
},
18+
"exclude": ["node_modules"]
19+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import * as React from 'react';
2+
import { FunctionComponent, useCallback } from 'react';
3+
4+
import { useGlobals } from '@storybook/api';
5+
import { IconButton, Icons, WithTooltip, TooltipLinkList, Link, WithHideFn } from '@storybook/components';
6+
7+
import { themeNames, VSCodeTheme } from './theme';
8+
9+
export const ThemeSelector: FunctionComponent = () => {
10+
const [{ vscodeTheme }, updateGlobals] = useGlobals();
11+
12+
const changeTheme = useCallback((theme: VSCodeTheme) => {
13+
updateGlobals({
14+
vscodeTheme: theme,
15+
});
16+
}, [updateGlobals]);
17+
18+
const createLinks = useCallback((onHide: () => void): Link[] => Object.values(VSCodeTheme).map((theme) => ({
19+
id: theme,
20+
onClick() {
21+
changeTheme(theme);
22+
onHide();
23+
},
24+
title: themeNames[theme],
25+
value: theme,
26+
active: vscodeTheme === theme,
27+
})), [vscodeTheme, changeTheme]);
28+
29+
return (
30+
<WithTooltip
31+
placement="top"
32+
trigger="click"
33+
closeOnClick
34+
tooltip={({ onHide }: WithHideFn) => (
35+
<TooltipLinkList
36+
links={createLinks(onHide)}
37+
/>
38+
)}
39+
>
40+
<IconButton
41+
key="theme"
42+
title="Change the theme of the preview"
43+
active={vscodeTheme !== VSCodeTheme.Dark}
44+
>
45+
<Icons icon="dashboard" />
46+
</IconButton>
47+
</WithTooltip>
48+
);
49+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as React from 'react';
2+
import { addons, types } from '@storybook/addons';
3+
import { ThemeSelector } from './ThemeSelector';
4+
5+
const ADDON_ID = 'vscode-theme-addon';
6+
7+
addons.register(ADDON_ID, () => {
8+
addons.add(ADDON_ID, {
9+
title: 'VSCode Themes',
10+
type: types.TOOL,
11+
match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),
12+
render: () => <ThemeSelector />,
13+
});
14+
});

0 commit comments

Comments
 (0)