Skip to content

Commit 10814f0

Browse files
authored
chore(ci): add a separate PR workflow for forks (#915)
1 parent 6ada4e9 commit 10814f0

35 files changed

+156
-69
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Test and Build (from fork)
2+
on:
3+
pull_request_target:
4+
branches:
5+
- main
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
test-and-build:
12+
name: Test and Build
13+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository
14+
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, windows-latest, macos-latest]
18+
fail-fast: false
19+
20+
runs-on: ${{ matrix.os }}
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Node.js Environment
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 20.16.0
32+
33+
- name: Install Dependencies
34+
run: npm ci --omit=optional
35+
36+
- name: Run Checks
37+
run: npm run check
38+
# the glob here just fails
39+
if: ${{ runner.os != 'Windows' }}
40+
41+
- name: Run Tests
42+
env:
43+
NODE_OPTIONS: "--max_old_space_size=4096"
44+
SEGMENT_KEY: ${{ secrets.SEGMENT_KEY_DEV }}
45+
run: npm run test
46+
47+
- name: Enable auto-merge for Dependabot PRs
48+
if: github.event.pull_request.user.login == 'dependabot[bot]'
49+
run: gh pr merge --auto --merge "$PR_URL"
50+
env:
51+
PR_URL: ${{github.event.pull_request.html_url}}
52+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/test-and-build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ permissions:
1616
jobs:
1717
test-and-build:
1818
name: Test and Build
19+
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
1920

2021
strategy:
2122
matrix:

src/commands/launchMongoShell.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const launchMongoDBShellWithEnv = ({
1212
mdbConnectionString: string;
1313
envVariableString: string;
1414
parentHandle?: string;
15-
}) => {
15+
}): void => {
1616
const mongoDBShell = vscode.window.createTerminal({
1717
name: 'MongoDB Shell',
1818
env: {
@@ -29,19 +29,19 @@ const launchMongoDBShellWithEnv = ({
2929
mongoDBShell.show();
3030
};
3131

32-
const getPowershellEnvString = () => {
32+
const getPowershellEnvString = (): string => {
3333
return '$Env:MDB_CONNECTION_STRING';
3434
};
3535

36-
const getCmdEnvString = () => {
36+
const getCmdEnvString = (): string => {
3737
return '%MDB_CONNECTION_STRING%';
3838
};
3939

40-
const getGitBashEnvString = () => {
40+
const getGitBashEnvString = (): string => {
4141
return '$MDB_CONNECTION_STRING';
4242
};
4343

44-
const getBashEnvString = () => {
44+
const getBashEnvString = (): string => {
4545
return '$MDB_CONNECTION_STRING';
4646
};
4747

src/editors/documentIdStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class DocumentIdStore {
3232
return newDocument.documentIdReference;
3333
}
3434

35-
get(documentIdReference: string) {
35+
get(documentIdReference: string): any {
3636
const existingDocument = this._documents.find(
3737
(item) => item.documentIdReference === documentIdReference
3838
);

src/explorer/databaseTreeItem.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export default class DatabaseTreeItem
129129
const sortFunction = (
130130
collectionA: CollectionDetailsType,
131131
collectionB: CollectionDetailsType
132-
) => (collectionA.name || '').localeCompare(collectionB.name || '');
132+
): number =>
133+
(collectionA.name || '').localeCompare(collectionB.name || '');
133134

134135
const collectionTreeEntries = [
135136
...otherCollections.sort(sortFunction),

src/featureFlags.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ const FEATURE_FLAGS = {
44

55
export type FeatureFlag = keyof typeof FEATURE_FLAGS;
66

7-
export const getFeatureFlag = (flag: FeatureFlag) => {
7+
export const getFeatureFlag = (flag: FeatureFlag): boolean => {
88
if (typeof window === 'object') {
99
return (window as any).MDB_FEATURE_FLAGS?.[flag];
1010
}
1111
return FEATURE_FLAGS[flag];
1212
};
1313

14-
export const getFeatureFlagsScript = (nonce: string) => {
14+
export const getFeatureFlagsScript = (nonce: string): string => {
1515
return `
1616
<script nonce="${nonce}">window['MDB_FEATURE_FLAGS']=${JSON.stringify(
1717
FEATURE_FLAGS

src/logging.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Logger implements ILogger {
5757
);
5858
}
5959

60-
private append(type: string, message: string) {
60+
private append(type: string, message: string): void {
6161
// https://code.visualstudio.com/api/references/vscode-api#window.createOutputChannel
6262

6363
Logger.channel.appendLine(

src/storage/storageController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class StorageController {
9191
return Promise.resolve();
9292
}
9393

94-
getUserIdentity() {
94+
getUserIdentity(): { anonymousId: string } {
9595
let anonymousId = this.get(StorageVariables.GLOBAL_ANONYMOUS_ID);
9696

9797
// The anonymousId becomes required with analytics-node v6.

src/test/runTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { TEST_DATABASE_PORT } from './suite/dbTestHelper';
88

99
// More information on vscode specific tests: https://github.com/microsoft/vscode-test
1010

11-
async function startTestMongoDBServer() {
11+
async function startTestMongoDBServer(): Promise<MongoCluster> {
1212
console.log('Starting MongoDB server on port', TEST_DATABASE_PORT);
1313
return await MongoCluster.start({
1414
topology: 'standalone',
@@ -19,7 +19,7 @@ async function startTestMongoDBServer() {
1919

2020
let testMongoDBServer: MongoCluster;
2121

22-
function cleanup() {
22+
function cleanup(): void {
2323
console.log('Stopping MongoDB server on port', TEST_DATABASE_PORT);
2424
void testMongoDBServer?.close();
2525
}

src/test/setup-webview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ Object.assign(global, { TextDecoder, TextEncoder });
6464

6565
(global as any).vscodeFake = {
6666
// eslint-disable-next-line @typescript-eslint/no-unused-vars
67-
postMessage: (message: unknown) => {},
67+
postMessage: (message: unknown): void => {},
6868
};
6969

70-
(global as any).acquireVsCodeApi = () => {
70+
(global as any).acquireVsCodeApi = (): any => {
7171
return (global as any).vscodeFake;
7272
};

0 commit comments

Comments
 (0)