Skip to content

Commit 237e629

Browse files
All AuthProviders must implement a non silent check. (#936)
## Changes * Moving forward, we want to avoid having silent checks to make reasoning about auth easier. This PR makes it so that all AuthProviders must implement the `check` method. * Each check method must handle it's own Retry Loop, error handling and display. Since now checks are always interactive, we do not want calling code to manage the interactions. ## Tests * manual
1 parent a2c3df0 commit 237e629

33 files changed

+7232
-84
lines changed

.github/workflows/nightly-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish nightly release
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, bundle-integ]
66
workflow_dispatch:
77

88
jobs:
@@ -24,8 +24,8 @@ jobs:
2424
- name: Update nightly release
2525
uses: softprops/action-gh-release@v1
2626
with:
27-
name: Nightly
27+
name: Nightly - ${{ github.ref_name }}
2828
prerelease: true
29-
tag_name: nightly
29+
tag_name: nightly-${{ github.ref_name }}
3030
token: ${{ secrets.GITHUB_TOKEN }}
3131
files: "packages/databricks-vscode/databricks*/*.vsix"

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: VSCode Extensions CI
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, bundle-integ]
66
pull_request:
7-
branches: [main]
7+
branches: [main, bundle-integ]
88

99
jobs:
1010
run-tests:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": ["eslint-plugin-local-rules"],
3+
"rules": {
4+
"local-rules/mutex-synchronised-decorator": "error"
5+
}
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
require("ts-node").register({
3+
transpileOnly: true,
4+
compilerOptions: {
5+
module: "commonjs",
6+
},
7+
});
8+
9+
module.exports = {
10+
"mutex-synchronised-decorator":
11+
require("./rules/mutexSynchronisedDecorator").default,
12+
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* eslint-disable no-console */
2+
import {ESLintUtils, AST_NODE_TYPES} from "@typescript-eslint/utils";
3+
4+
const rule = ESLintUtils.RuleCreator.withoutDocs({
5+
create(context) {
6+
return {
7+
// eslint-disable-next-line @typescript-eslint/naming-convention
8+
Decorator(node) {
9+
if (
10+
node.expression.type === "CallExpression" &&
11+
node.expression.callee.type ===
12+
AST_NODE_TYPES.MemberExpression &&
13+
node.expression.callee.object.type ===
14+
AST_NODE_TYPES.Identifier &&
15+
node.expression.callee.object.name === "Mutex" &&
16+
node.expression.callee.property.type ===
17+
AST_NODE_TYPES.Identifier &&
18+
node.expression.callee.property.name === "synchronise" &&
19+
node.expression.arguments.length > 0
20+
) {
21+
const mutexName =
22+
node.expression.arguments[0].type ===
23+
AST_NODE_TYPES.Literal
24+
? (node.expression.arguments[0].value as string)
25+
: "";
26+
27+
if (node.parent.parent?.type !== AST_NODE_TYPES.ClassBody) {
28+
return context.report({
29+
node,
30+
messageId: "decoratorNotInClass",
31+
});
32+
}
33+
34+
const exists = node.parent.parent.body.some((element) => {
35+
return (
36+
element.type ===
37+
AST_NODE_TYPES.PropertyDefinition &&
38+
element.key.type === AST_NODE_TYPES.Identifier &&
39+
element.key.name === mutexName
40+
);
41+
});
42+
43+
const className =
44+
node.parent.parent.parent?.type ===
45+
AST_NODE_TYPES.ClassDeclaration
46+
? node.parent.parent.parent.id?.name
47+
: undefined;
48+
49+
if (!exists) {
50+
return context.report({
51+
node,
52+
messageId: "synchronisedMutexNotInClass",
53+
data: {
54+
mutexName,
55+
className,
56+
},
57+
});
58+
}
59+
}
60+
},
61+
};
62+
},
63+
meta: {
64+
type: "problem",
65+
schema: [],
66+
messages: {
67+
decoratorNotInClass:
68+
"Mutex.synchronized() should be used inside a class",
69+
synchronisedMutexNotInClass:
70+
'Mutex "{{mutexName}}" is not defined in class "{{className}}".',
71+
},
72+
},
73+
defaultOptions: [],
74+
});
75+
76+
export default rule;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"transpileOnly": true,
3+
"compilerOptions": {
4+
"module": "Node16"
5+
}
6+
}

packages/databricks-vscode/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@
666666
"package:cli:link": "rm -f ./bin/databricks && mkdir -p bin && ln -s ../../../../cli/cli bin/databricks",
667667
"package:wrappers:write": "ts-node ./scripts/writeIpynbWrapper.ts -s ./resources/python/notebook.workflow-wrapper.py -o ./resources/python/generated/notebook.workflow-wrapper.json",
668668
"package:jupyter-init-script:write": "ts-node ./scripts/writeJupyterInitFileWithVersion.ts",
669+
"package:bundle-schema:write": "yarn package:cli:fetch && ts-node ./scripts/writeBundleSchema.ts ./bin/databricks ./src/bundle/BundleSchema.d.ts",
669670
"package:compile": "yarn run esbuild:base",
670671
"package:copy-webview-toolkit": "cp ./node_modules/@vscode/webview-ui-toolkit/dist/toolkit.js ./out/toolkit.js",
671672
"esbuild:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --sourcemap --target=es2019",
@@ -687,6 +688,7 @@
687688
"dependencies": {
688689
"@databricks/databricks-sdk": "file:../../vendor/databricks-sdk.tgz",
689690
"@databricks/databricks-vscode-types": "workspace:^",
691+
"@types/lodash": "^4.14.199",
690692
"@vscode/debugadapter": "^1.61.0",
691693
"@vscode/extension-telemetry": "^0.9.0",
692694
"@vscode/webview-ui-toolkit": "^1.2.2",
@@ -702,8 +704,9 @@
702704
"@sinonjs/fake-timers": "^11.2.2",
703705
"@types/bcryptjs": "^2.4.2",
704706
"@types/chai": "^4.3.5",
707+
"@types/eslint": "^8.44.6",
705708
"@types/fs-extra": "^11.0.1",
706-
"@types/mocha": "^10.0.1",
709+
"@types/mocha": "^10.0.2",
707710
"@types/mock-require": "^2.0.1",
708711
"@types/node": "^20.4.2",
709712
"@types/sinonjs__fake-timers": "^8.1.2",
@@ -713,6 +716,7 @@
713716
"@types/yargs": "^17.0.24",
714717
"@typescript-eslint/eslint-plugin": "^6.0.0",
715718
"@typescript-eslint/parser": "^6.0.0",
719+
"@typescript-eslint/utils": "^6.9.0",
716720
"@vscode/test-electron": "^2.3.3",
717721
"@wdio/cli": "^8.12.2",
718722
"@wdio/local-runner": "^8.12.1",
@@ -722,8 +726,10 @@
722726
"chai": "^4.3.7",
723727
"esbuild": "^0.19.4",
724728
"eslint": "^8.51.0",
729+
"eslint-plugin-local-rules": "^2.0.0",
725730
"fs-extra": "^11.1.1",
726-
"glob": "^10.3.3",
731+
"glob": "^10.3.10",
732+
"json-schema-to-typescript": "^13.1.1",
727733
"mocha": "^10.2.0",
728734
"mock-require": "^3.0.3",
729735
"nyc": "^15.1.0",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* This script generates the BundleSchema.d.ts file from the bundle schema.
3+
* It MUST be run after a yarn package:cli:fetch
4+
*/
5+
6+
import * as cp from "child_process";
7+
import * as fs from "fs";
8+
import {compileFromFile} from "json-schema-to-typescript";
9+
import {tmpdir} from "os";
10+
import path from "path";
11+
import {argv} from "process";
12+
13+
const output = cp.execFileSync(argv[2], ["bundle", "schema"]);
14+
15+
const tmpFile = path.join(tmpdir(), "BundleSchema.json");
16+
fs.writeFileSync(tmpFile, output);
17+
18+
// eslint-disable-next-line no-console
19+
console.log("Bundle schema written to", tmpFile);
20+
21+
// compile from file
22+
compileFromFile(tmpFile).then((ts) => fs.writeFileSync(argv[3], ts));
23+
24+
// eslint-disable-next-line no-console
25+
console.log("BundleSchema.d.ts written to", argv[3]);

0 commit comments

Comments
 (0)