Skip to content

Commit f66d36d

Browse files
Repos integration test fixes (#71)
* repos integration test fixes * fix repo tests * remove ubuntu * run sdk and extension tests with same architecture sequential * run sdk and extension tests with same architecture sequential * run sdk and extension tests with same architecture sequential * run sdk and extension tests with same architecture sequential * run sdk and extension tests with same architecture sequential * remove redundant test * remove redundant test
1 parent 109218a commit f66d36d

File tree

3 files changed

+173
-143
lines changed

3 files changed

+173
-143
lines changed

.github/workflows/push.yml

Lines changed: 9 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -7,139 +7,24 @@ on:
77
branches: [main]
88

99
jobs:
10-
test-sdk:
11-
name: Test Databricks SDK
12-
runs-on: ${{ matrix.os }}
13-
10+
run-tests:
1411
strategy:
15-
matrix:
16-
os: [windows-latest, ubuntu-latest]
17-
node-version: [14.x, 18.x]
1812
fail-fast: false
19-
20-
defaults:
21-
run:
22-
shell: bash
23-
working-directory: packages/databricks-sdk-js
24-
env:
25-
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
26-
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
27-
TEST_DEFAULT_CLUSTER_ID: ${{ secrets.TEST_DEFAULT_CLUSTER_ID }}
28-
steps:
29-
- uses: actions/checkout@v3
30-
31-
- name: Use Node.js ${{ matrix.node-version }}
32-
uses: actions/setup-node@v3
33-
with:
34-
node-version: ${{ matrix.node-version }}
35-
cache: "yarn"
36-
37-
- run: yarn install --immutable
38-
39-
- name: Building packages
40-
run: yarn run build
41-
42-
- name: Prettier and Linting
43-
run: yarn run test:lint
44-
45-
- name: Unit Tests With Code Cov
46-
run: yarn test:cov
47-
48-
- name: Integration Tests
49-
uses: nick-fields/retry@v2
50-
with:
51-
max_attempts: 3
52-
retry_wait_seconds: 2
53-
timeout_minutes: 10
54-
retry_on: any
55-
command: yarn run test:integ:cov
56-
57-
- run: |
58-
cd coverage
59-
mkdir -p all && mkdir -p final
60-
mv integration/coverage-final.json all/integration.json
61-
mv unit/coverage-final.json all/unit.json
62-
yarn nyc merge all final/final.json
63-
yarn nyc report --reporter text -t ./coverage/final >> $GITHUB_STEP_SUMMARY
64-
65-
test-extension:
66-
name: Test VSCode Extension
67-
runs-on: ${{ matrix.os }}
68-
needs: [test-sdk]
69-
70-
strategy:
7113
matrix:
72-
os: [windows-latest, macos-latest]
14+
os: [macos-latest, windows-latest]
7315
node-version: [16.x]
7416
vscode-version: [stable, insiders]
75-
fail-fast: false
7617

77-
env:
78-
VSCODE_TEST_VERSION: ${{ matrix.vscode-version }}
79-
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
80-
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
81-
TEST_DEFAULT_CLUSTER_ID: ${{ secrets.TEST_DEFAULT_CLUSTER_ID }}
82-
83-
steps:
84-
- uses: actions/checkout@v3
85-
86-
- name: Use Node.js ${{ matrix.node-version }}
87-
uses: actions/setup-node@v3
88-
with:
89-
node-version: ${{ matrix.node-version }}
90-
cache: "yarn"
91-
92-
- run: yarn install --immutable
93-
94-
- name: Prettier and Linting
95-
run: yarn run test:lint
96-
working-directory: packages/databricks-vscode
97-
98-
- name: Building packages
99-
run: yarn run build
100-
101-
- name: Unit Tests with Coverage (OSX)
102-
uses: GabrielBB/xvfb-action@v1
103-
if: matrix.os != 'windows-latest'
104-
with:
105-
run: yarn run test:cov
106-
working-directory: packages/databricks-vscode
107-
108-
- name: Unit Tests with Coverage (Windows)
109-
if: matrix.os == 'windows-latest'
110-
run: yarn run test:cov
111-
working-directory: packages/databricks-vscode
112-
113-
- name: Show coverage test result
114-
continue-on-error: true
115-
run: yarn nyc report --reporter text -t ./coverage >> $GITHUB_STEP_SUMMARY
116-
working-directory: packages/databricks-vscode
117-
118-
- name: Integration Tests
119-
uses: nick-fields/retry@v2
120-
with:
121-
max_attempts: 3
122-
retry_wait_seconds: 2
123-
timeout_minutes: 10
124-
retry_on: any
125-
command: |
126-
yarn workspace databricks run test:integ:clean
127-
yarn install --immutable
128-
yarn build
129-
cd packages/databricks-vscode
130-
yarn run test:integ
131-
132-
- name: Upload test logs
133-
if: always()
134-
continue-on-error: true
135-
uses: actions/upload-artifact@v3
136-
with:
137-
name: test-logs ${{ join(matrix.*, ' - ') }} - ${{ github.event_name }}
138-
path: packages/databricks-vscode/src/test/logs
18+
uses: ./.github/workflows/tests.yml
19+
with:
20+
os: ${{ matrix.os }}
21+
node-version: ${{ matrix.node-version }}
22+
vscode-version: ${{ matrix.vscode-version }}
23+
secrets: inherit
13924

14025
package:
14126
name: Package VSIX
142-
needs: "test-extension"
27+
needs: "run-tests"
14328
runs-on: "macos-latest"
14429
steps:
14530
- uses: actions/checkout@v3

.github/workflows/tests.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: VSCode extension Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
node-version:
10+
required: true
11+
type: string
12+
vscode-version:
13+
required: true
14+
type: string
15+
16+
jobs:
17+
test-sdk:
18+
name: Test Databricks SDK
19+
runs-on: ${{ inputs.os }}
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
working-directory: packages/databricks-sdk-js
25+
env:
26+
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
27+
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
28+
TEST_DEFAULT_CLUSTER_ID: ${{ secrets.TEST_DEFAULT_CLUSTER_ID }}
29+
steps:
30+
- uses: actions/checkout@v3
31+
32+
- name: Use Node.js ${{ inputs.node-version }}
33+
uses: actions/setup-node@v3
34+
with:
35+
node-version: ${{ inputs.node-version }}
36+
cache: "yarn"
37+
38+
- run: yarn install --immutable
39+
40+
- name: Building packages
41+
run: yarn run build
42+
43+
- name: Prettier and Linting
44+
run: yarn run test:lint
45+
46+
- name: Unit Tests With Code Cov
47+
run: yarn test:cov
48+
49+
- name: Integration Tests
50+
uses: nick-fields/retry@v2
51+
with:
52+
max_attempts: 3
53+
retry_wait_seconds: 2
54+
timeout_minutes: 10
55+
retry_on: any
56+
command: yarn run test:integ:cov
57+
58+
- run: |
59+
cd coverage
60+
mkdir -p all && mkdir -p final
61+
mv integration/coverage-final.json all/integration.json
62+
mv unit/coverage-final.json all/unit.json
63+
yarn nyc merge all final/final.json
64+
yarn nyc report --reporter text -t ./coverage/final >> $GITHUB_STEP_SUMMARY
65+
66+
test-extension:
67+
name: Test VSCode Extension
68+
runs-on: ${{ inputs.os }}
69+
needs: [test-sdk]
70+
71+
env:
72+
VSCODE_TEST_VERSION: ${{ inputs.vscode-version }}
73+
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
74+
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
75+
TEST_DEFAULT_CLUSTER_ID: ${{ secrets.TEST_DEFAULT_CLUSTER_ID }}
76+
77+
steps:
78+
- uses: actions/checkout@v3
79+
80+
- name: Use Node.js ${{ inputs.node-version }}
81+
uses: actions/setup-node@v3
82+
with:
83+
node-version: ${{ inputs.node-version }}
84+
cache: "yarn"
85+
86+
- run: yarn install --immutable
87+
88+
- name: Prettier and Linting
89+
run: yarn run test:lint
90+
working-directory: packages/databricks-vscode
91+
92+
- name: Building packages
93+
run: yarn run build
94+
95+
- name: Unit Tests with Coverage (OSX)
96+
uses: GabrielBB/xvfb-action@v1
97+
if: inputs.os != 'windows-latest'
98+
with:
99+
run: yarn run test:cov
100+
working-directory: packages/databricks-vscode
101+
102+
- name: Unit Tests with Coverage (Windows)
103+
if: inputs.os == 'windows-latest'
104+
run: yarn run test:cov
105+
working-directory: packages/databricks-vscode
106+
107+
- name: Show coverage test result
108+
continue-on-error: true
109+
run: yarn nyc report --reporter text -t ./coverage >> $GITHUB_STEP_SUMMARY
110+
working-directory: packages/databricks-vscode
111+
112+
- name: Integration Tests
113+
uses: nick-fields/retry@v2
114+
with:
115+
max_attempts: 3
116+
retry_wait_seconds: 2
117+
timeout_minutes: 10
118+
retry_on: any
119+
command: |
120+
yarn workspace databricks run test:integ:clean
121+
yarn install --immutable
122+
yarn build
123+
cd packages/databricks-vscode
124+
yarn run test:integ
125+
126+
- name: Upload test logs
127+
if: always()
128+
continue-on-error: true
129+
uses: actions/upload-artifact@v3
130+
with:
131+
name: test-logs ${{ join(inputs.*, ' - ') }} - ${{ github.event_name }}
132+
path: packages/databricks-vscode/src/test/logs

packages/databricks-sdk-js/src/services/Repos.integ.ts

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,54 @@
33
import {IntegrationTestSetup, sleep} from "../test/IntegrationTestSetup";
44
import * as assert from "node:assert";
55
import {Repos} from "./Repos";
6-
import {ReposService} from "../apis/repos";
6+
import {GetRepoResponse, ReposService} from "../apis/repos";
77
import {randomUUID} from "node:crypto";
8+
import {WorkspaceService} from "../apis/workspace";
9+
import path from "node:path";
810

911
describe(__filename, function () {
1012
let integSetup: IntegrationTestSetup;
13+
const repoDir = "/Repos/js-sdk-tests";
14+
let testRepoDetails: GetRepoResponse;
1115

1216
this.timeout(10 * 60 * 1000);
1317

14-
before(async () => {
15-
integSetup = await IntegrationTestSetup.getInstance();
16-
});
17-
18-
it("should create a repo", async () => {
19-
const repos = new ReposService(integSetup.client);
18+
async function createRandomRepo(
19+
repoService?: ReposService
20+
): Promise<GetRepoResponse> {
21+
repoService = repoService ?? new ReposService(integSetup.client);
2022
const id = randomUUID();
21-
const response = await repos.createRepo({
22-
path: `/Repos/fabian.jakobs@databricks.com/test-${id}`,
23+
const resp = await repoService.createRepo({
24+
path: `${repoDir}/test-${id}`,
2325
url: "https://github.com/fjakobs/empty-repo.git",
2426
provider: "github",
2527
});
28+
assert.equal(resp.path, `${repoDir}/test-${id}`);
29+
30+
return resp;
31+
}
32+
33+
before(async () => {
34+
integSetup = await IntegrationTestSetup.getInstance();
35+
let workspaceService = new WorkspaceService(integSetup.client);
36+
await workspaceService.mkdirs({
37+
path: repoDir,
38+
});
2639

27-
try {
28-
assert.equal(
29-
response.path,
30-
`/Repos/fabian.jakobs@databricks.com/test-${id}`
31-
);
32-
} finally {
33-
await repos.deleteRepo({id: response.id});
34-
}
40+
testRepoDetails = await createRandomRepo(
41+
new ReposService(integSetup.client)
42+
);
43+
});
44+
45+
after(async () => {
46+
const repos = new ReposService(integSetup.client);
47+
await repos.deleteRepo({id: testRepoDetails.id});
3548
});
3649

3750
it("should list repos by prefix", async () => {
3851
let repos = new Repos(integSetup.client);
3952
let response = await repos.getRepos({
40-
path_prefix: "/Repos/fabian.jakobs@databricks.com",
53+
path_prefix: repoDir,
4154
});
4255
assert.ok(response.repos.length > 0);
4356
});
@@ -59,7 +72,7 @@ describe(__filename, function () {
5972

6073
let response = repos.getRepos(
6174
{
62-
path_prefix: "/Repos/.internal",
75+
path_prefix: repoDir,
6376
},
6477
token
6578
);

0 commit comments

Comments
 (0)