Skip to content

Commit 2453038

Browse files
Merge branch 'main' into robertbrignull/telemetry_ui
2 parents 47f63f6 + 817db85 commit 2453038

78 files changed

Lines changed: 2895 additions & 1426 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Create a PR if one doesn't exists
2+
description: >
3+
Creates a commit with the current changes to the repo, and opens a PR for that commit. If
4+
any PR with the same title exists, then this action is marked as succeeded.
5+
inputs:
6+
commit-message:
7+
description: >
8+
The message for the commit to be created.
9+
required: true
10+
11+
title:
12+
description: >
13+
The title of the PR. If empty, the title and body will be determined from the commit message.
14+
default: ''
15+
required: false
16+
17+
body:
18+
description: >
19+
The body (description) of the PR. The `title` input must be specified in order for this input to be used.
20+
default: ''
21+
required: false
22+
23+
head-branch:
24+
description: >
25+
The name of the branch to hold the new commit. If an existing open PR with the same head
26+
branch exists, the new branch will be force-pushed to that PR instead of creating a new PR.
27+
required: true
28+
29+
base-branch:
30+
description: >
31+
The base branch to target with the new PR.
32+
required: true
33+
34+
token:
35+
description: |
36+
The GitHub token to use. It must have enough privileges to
37+
make API calls to create and close pull requests.
38+
required: true
39+
40+
runs:
41+
using: composite
42+
steps:
43+
- name: Update git config
44+
shell: bash
45+
run: |
46+
git config --global user.email "github-actions@github.com"
47+
git config --global user.name "github-actions[bot]"
48+
- name: Commit, Push and Open PR
49+
shell: bash
50+
env:
51+
COMMIT_MESSAGE: ${{ inputs.commit-message }}
52+
HEAD_BRANCH: ${{ inputs.head-branch }}
53+
BASE_BRANCH: ${{ inputs.base-branch }}
54+
GH_TOKEN: ${{ inputs.token }}
55+
TITLE: ${{ inputs.title }}
56+
BODY: ${{ inputs.body }}
57+
run: |
58+
set -exu
59+
if ! [[ $(git diff --stat) != '' ]]; then
60+
exit 0 # exit early
61+
fi
62+
# stage changes in the working tree
63+
git add .
64+
git commit -m "$COMMIT_MESSAGE"
65+
git checkout -b "$HEAD_BRANCH"
66+
# CAUTION: gits history changes with the following
67+
git push --force origin "$HEAD_BRANCH"
68+
PR_JSON=$(gh pr list --state open --json number --head "$HEAD_BRANCH")
69+
if [[ $? -ne 0 ]]; then
70+
echo "Failed to fetch existing PRs."
71+
exit 1
72+
fi
73+
PR_NUMBERS=$(echo $PR_JSON | jq '. | length')
74+
if [[ $PR_NUMBERS -ne 0 ]]; then
75+
echo "Found existing open PR: $PR_NUMBERS"
76+
exit 0
77+
fi
78+
gh pr create --head "$HEAD_BRANCH" --base "$BASE_BRANCH" --title "$TITLE" --body "$BODY" --assignee ${{ github.actor }}
79+
if [[ $? -ne 0 ]]; then
80+
echo "Failed to create new PR."
81+
exit 1
82+
fi

.github/workflows/bump-cli.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bump CLI version
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- .github/actions/create-pr/action.yml
8+
- .github/workflows/bump-cli.yml
9+
schedule:
10+
- cron: 0 0 */14 * * # run every 14 days
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
build:
18+
name: Build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 1
25+
- name: Bump CLI
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
scripts/replace-cli-version.sh
30+
- name: Commit, Push and Open a PR
31+
uses: ./.github/actions/create-pr
32+
with:
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
base-branch: main
35+
head-branch: github-action/bump-cli
36+
commit-message: Bump CLI version from ${{ env.PREVIOUS_VERSION }} to ${{ env.LATEST_VERSION }} for integration tests
37+
title: Bump CLI Version to ${{ env.LATEST_VERSION }} for integration tests
38+
body: >
39+
Bumps CLI version from ${{ env.PREVIOUS_VERSION }} to ${{ env.LATEST_VERSION }}

.github/workflows/main.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,25 @@ jobs:
183183
run: |
184184
npm run integration
185185
186+
set-matrix:
187+
name: Set Matrix for cli-test
188+
runs-on: ubuntu-latest
189+
steps:
190+
- name: Checkout
191+
uses: actions/checkout@v3
192+
- name: Set the variables
193+
id: set-variables
194+
run: echo "cli-versions=$(cat ./supported_cli_versions.json | jq -rc)" >> $GITHUB_OUTPUT
195+
outputs:
196+
cli-versions: ${{ steps.set-variables.outputs.cli-versions }}
186197
cli-test:
187198
name: CLI Test
188199
runs-on: ${{ matrix.os }}
189-
needs: [find-nightly]
200+
needs: [find-nightly, set-matrix]
190201
strategy:
191202
matrix:
192203
os: [ubuntu-latest, windows-latest]
193-
version: ['v2.7.6', 'v2.8.5', 'v2.9.4', 'v2.10.5', 'v2.11.6', 'nightly']
204+
version: ${{ fromJson(needs.set-matrix.outputs.cli-versions) }}
194205
fail-fast: false
195206
env:
196207
CLI_VERSION: ${{ matrix.version }}

CONTRIBUTING.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ More information about Storybook can be found inside the **Overview** page once
9595

9696
We have several types of tests:
9797

98-
* Unit tests: these live in the `tests/pure-tests/` directory
98+
* Unit tests: these live in the `tests/unit-tests/` directory
9999
* View tests: these live in `src/view/variant-analysis/__tests__/`
100-
* VSCode integration tests: these live in `test/vscode-tests/no-workspace` and `test/vscode-tests/minimal-workspace`
100+
* VSCode integration tests:
101+
* `test/vscode-tests/no-workspace` tests: These are intended to cover functionality that is meant to work before you even have a workspace open.
102+
* `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.
101103
* CLI integration tests: these live in `test/vscode-tests/cli-integration`
104+
* These tests are intendended to be cover functionality that is related to the integration between the CodeQL CLI and the extension.
102105

103106
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.
104107

extensions/ql-vscode/.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ gulpfile.js/**
1414
tsconfig.json
1515
.prettierrc
1616
vsc-extension-quickstart.md
17+
node_modules/**

extensions/ql-vscode/gulpfile.ts/appInsights.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function injectAppInsightsKey() {
1313
}
1414

1515
// replace the key
16-
return src(["out/telemetry.js"])
16+
return src(["out/extension.js"])
1717
.pipe(replace(/REPLACE-APP-INSIGHTS-KEY/, process.env.APP_INSIGHTS_KEY))
1818
.pipe(dest("out/"));
1919
}

extensions/ql-vscode/gulpfile.ts/deploy.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,27 @@ const packageFiles = [
2222
"language-configuration.json",
2323
"snippets.json",
2424
"media",
25-
"node_modules",
2625
"out",
2726
"workspace-databases-schema.json",
2827
];
2928

29+
async function copyDirectory(
30+
sourcePath: string,
31+
destPath: string,
32+
): Promise<void> {
33+
console.log(`copying ${sourcePath} to ${destPath}`);
34+
await copy(sourcePath, destPath);
35+
}
36+
3037
async function copyPackage(
3138
sourcePath: string,
3239
destPath: string,
3340
): Promise<void> {
34-
for (const file of packageFiles) {
35-
console.log(
36-
`copying ${resolve(sourcePath, file)} to ${resolve(destPath, file)}`,
37-
);
38-
await copy(resolve(sourcePath, file), resolve(destPath, file));
39-
}
41+
await Promise.all(
42+
packageFiles.map((file) =>
43+
copyDirectory(resolve(sourcePath, file), resolve(destPath, file)),
44+
),
45+
);
4046
}
4147

4248
export async function deployPackage(
@@ -88,6 +94,12 @@ export async function deployPackage(
8894
);
8995
await copyPackage(sourcePath, distPath);
9096

97+
// This is necessary for vsce to know the dependencies
98+
await copyDirectory(
99+
resolve(sourcePath, "node_modules"),
100+
resolve(distPath, "node_modules"),
101+
);
102+
91103
return {
92104
distPath,
93105
name: packageJson.name,

extensions/ql-vscode/gulpfile.ts/index.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1-
import { series, parallel } from "gulp";
2-
import { compileTypeScript, watchTypeScript, cleanOutput } from "./typescript";
1+
import { parallel, series } from "gulp";
2+
import {
3+
compileEsbuild,
4+
watchEsbuild,
5+
checkTypeScript,
6+
watchCheckTypeScript,
7+
cleanOutput,
8+
copyWasmFiles,
9+
} from "./typescript";
310
import { compileTextMateGrammar } from "./textmate";
4-
import { copyTestData, watchTestData } from "./tests";
511
import { compileView, watchView } from "./webpack";
612
import { packageExtension } from "./package";
713
import { injectAppInsightsKey } from "./appInsights";
814

915
export const buildWithoutPackage = series(
1016
cleanOutput,
1117
parallel(
12-
compileTypeScript,
18+
compileEsbuild,
19+
copyWasmFiles,
20+
checkTypeScript,
1321
compileTextMateGrammar,
1422
compileView,
15-
copyTestData,
1623
),
1724
);
1825

26+
export const watch = parallel(watchEsbuild, watchCheckTypeScript, watchView);
27+
1928
export {
2029
cleanOutput,
2130
compileTextMateGrammar,
22-
watchTypeScript,
31+
watchEsbuild,
32+
watchCheckTypeScript,
2333
watchView,
24-
compileTypeScript,
25-
copyTestData,
26-
watchTestData,
34+
compileEsbuild,
35+
copyWasmFiles,
36+
checkTypeScript,
2737
injectAppInsightsKey,
2838
compileView,
2939
};

extensions/ql-vscode/gulpfile.ts/package.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { deployPackage } from "./deploy";
33
import { spawn } from "child-process-promise";
44

55
export async function packageExtension(): Promise<void> {
6-
const deployedPackage = await deployPackage(resolve("package.json"));
6+
const deployedPackage = await deployPackage(
7+
resolve(__dirname, "../package.json"),
8+
);
79
console.log(
810
`Packaging extension '${deployedPackage.name}@${deployedPackage.version}'...`,
911
);
@@ -16,7 +18,7 @@ export async function packageExtension(): Promise<void> {
1618
`${deployedPackage.name}-${deployedPackage.version}.vsix`,
1719
),
1820
];
19-
const proc = spawn("./node_modules/.bin/vsce", args, {
21+
const proc = spawn(resolve(__dirname, "../node_modules/.bin/vsce"), args, {
2022
cwd: deployedPackage.distPath,
2123
});
2224
proc.childProcess.stdout!.on("data", (data) => {

extensions/ql-vscode/gulpfile.ts/tests.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)