Skip to content

Commit 6a3137b

Browse files
authored
VSCode: Package bricks from GH actions (#83)
1 parent 7196f7b commit 6a3137b

File tree

6 files changed

+135
-18
lines changed

6 files changed

+135
-18
lines changed

.github/workflows/nightly-release.yml

Lines changed: 86 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,107 @@ name: Publish nightly release
33
on:
44
push:
55
branches: [main]
6+
tags:
7+
- "v*.*.*"
8+
workflow_dispatch:
69

710
jobs:
8-
archive-build-artifacts:
9-
runs-on: ubuntu-latest
11+
create-build-artifacts:
12+
strategy:
13+
matrix:
14+
# VSIX architextures: https://github.com/microsoft/vscode-vsce/blob/main/src/package.ts
15+
arch:
16+
[
17+
{
18+
bricks_arch: darwin_arm64,
19+
vsix_arch: darwin-arm64,
20+
os: macos-latest,
21+
},
22+
{
23+
bricks_arch: darwin_amd64,
24+
vsix_arch: darwin-x64,
25+
os: macos-latest,
26+
},
27+
{
28+
bricks_arch: linux_arm64,
29+
vsix_arch: linux-arm64,
30+
os: ubuntu-latest,
31+
},
32+
{
33+
bricks_arch: linux_amd64,
34+
vsix_arch: linux-x64,
35+
os: ubuntu-latest,
36+
},
37+
{
38+
bricks_arch: windows_arm64,
39+
vsix_arch: win32-arm64,
40+
os: windows-latest,
41+
},
42+
{
43+
bricks_arch: windows_amd64,
44+
vsix_arch: win32-x64,
45+
os: windows-latest,
46+
},
47+
{
48+
bricks_arch: windows_386,
49+
vsix_arch: win32-ia32,
50+
os: windows-latest,
51+
},
52+
]
53+
node-version: [16.x]
54+
55+
runs-on: ${{ matrix.arch.os }}
56+
57+
env:
58+
BRICKS_ARCH: ${{ matrix.arch.bricks_arch }}
59+
1060
steps:
1161
- uses: actions/checkout@v3
1262

13-
- name: Use Node.js 18.x
63+
- name: Use Node.js ${{ matrix.node-version }}
1464
uses: actions/setup-node@v3
1565
with:
16-
node-version: 18.x
66+
node-version: ${{ matrix.node-version }}
1767

1868
- run: yarn install
1969
- run: yarn run build
2070

21-
- run: yarn run package
71+
- run: yarn run package:cli:fetch
2272
working-directory: packages/databricks-vscode
73+
env:
74+
# TODO: Remove this once the bricks repo is public
75+
GH_TOKEN: ${{ secrets.DECO_GITHUB_TOKEN }}
76+
77+
- run: yarn run package -t ${{ matrix.arch.vsix_arch }}
78+
working-directory: packages/databricks-vscode
79+
80+
- uses: actions/upload-artifact@v2
81+
with:
82+
name: databricks-${{ matrix.arch.vsix_arch }}
83+
path: "packages/databricks-vscode/*.vsix"
84+
85+
create-release:
86+
needs: "create-build-artifacts"
87+
runs-on: ubuntu-latest
88+
89+
steps:
90+
- uses: actions/download-artifact@v3
91+
with:
92+
path: packages/databricks-vscode
93+
94+
- run: ls -lR packages/databricks-vscode
2395

2496
- name: Update nightly release
25-
uses: eine/tip@master
97+
uses: pyTooling/Actions/releaser@r0
98+
if: startsWith(github.ref, 'refs/heads/')
2699
with:
27100
tag: nightly
28101
rm: true
29102
token: ${{ secrets.GITHUB_TOKEN }}
30-
files: "packages/databricks-vscode/*.vsix"
103+
files: "packages/databricks-vscode/databricks*/*.vsix"
104+
105+
- name: Release
106+
uses: softprops/action-gh-release@v1
107+
if: startsWith(github.ref, 'refs/tags/')
108+
with:
109+
files: "packages/databricks-vscode/databricks*/*.vsix"

.github/workflows/push.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
os: [macos-latest, windows-latest]
14+
arch:
15+
[
16+
{bricks_arch: darwin_amd64, os: macos-latest},
17+
{bricks_arch: windows_amd64, os: windows-latest},
18+
]
1519
node-version: [16.x]
1620
vscode-version: [stable, insiders]
1721

1822
uses: ./.github/workflows/tests.yml
1923
with:
20-
os: ${{ matrix.os }}
24+
os: ${{ matrix.arch.os }}
2125
node-version: ${{ matrix.node-version }}
2226
vscode-version: ${{ matrix.vscode-version }}
27+
bricks_arch: ${{ matrix.arch.bricks_arch }}
2328
secrets: inherit
2429

2530
package:
@@ -37,13 +42,20 @@ jobs:
3742

3843
- run: yarn install --immutable
3944

45+
- run: yarn run package:cli:fetch
46+
working-directory: packages/databricks-vscode
47+
env:
48+
# TODO: Remove this once the bricks repo is public
49+
GH_TOKEN: ${{ secrets.DECO_GITHUB_TOKEN }}
50+
BRICKS_ARCH: darwin_amd64
51+
4052
- name: Building packages
4153
run: yarn run build
4254

4355
- run: mkdir -p packages/databricks-vscode/artifacts
4456

4557
- name: Build VSIX
46-
run: yarn workspace databricks package -o artifacts
58+
run: yarn workspace databricks package -o artifacts -t darwin-x64
4759

4860
- name: Upload artifacts
4961
uses: actions/upload-artifact@v3

.github/workflows/tests.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
vscode-version:
1313
required: true
1414
type: string
15+
bricks_arch:
16+
required: true
17+
type: string
1518

1619
jobs:
1720
test-sdk:
@@ -26,6 +29,7 @@ jobs:
2629
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
2730
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
2831
TEST_DEFAULT_CLUSTER_ID: ${{ secrets.TEST_DEFAULT_CLUSTER_ID }}
32+
2933
steps:
3034
- uses: actions/checkout@v3
3135

@@ -73,6 +77,7 @@ jobs:
7377
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
7478
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
7579
TEST_DEFAULT_CLUSTER_ID: ${{ secrets.TEST_DEFAULT_CLUSTER_ID }}
80+
BRICKS_ARCH: ${{ inputs.bricks_arch }}
7681

7782
steps:
7883
- uses: actions/checkout@v3
@@ -89,6 +94,13 @@ jobs:
8994
run: yarn run test:lint
9095
working-directory: packages/databricks-vscode
9196

97+
- name: Fetching Bricks CLI
98+
run: yarn run package:cli:fetch
99+
working-directory: packages/databricks-vscode
100+
env:
101+
# TODO: Remove this once the bricks repo is public
102+
GH_TOKEN: ${{ secrets.DECO_GITHUB_TOKEN }}
103+
92104
- name: Building packages
93105
run: yarn run build
94106

packages/databricks-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@
435435
"scripts": {
436436
"vscode:prepublish": "rm -rf out && yarn run package:compile && yarn run package:copy-webview-toolkit",
437437
"package": "vsce package",
438-
"package:cli:fetch": "bash ./scripts/fetch-bricks-cli.sh v0.0.1 ${BRICKS_ARCH:-}",
438+
"package:cli:fetch": "BRICKS_VERSION=v0.0.2 && bash ./scripts/fetch-bricks-cli.sh ${BRICKS_VERSION} ${BRICKS_ARCH:-}",
439439
"package:cli:link": "rm -f ./bin/bricks && ln -s ../../../../bricks/bricks bin",
440440
"package:compile": "yarn run esbuild:base --minify",
441441
"package:copy-webview-toolkit": "cp ./node_modules/@vscode/webview-ui-toolkit/dist/toolkit.js ./out/toolkit.js",

packages/databricks-vscode/scripts/fetch-bricks-cli.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ if [ -z "$BRICKS_ARCH" ]; then
88
BRICKS_ARCH="$(uname -s | awk '{print tolower($0)}')_$(uname -m)"
99
fi
1010

11-
pushd /tmp
12-
rm -rf bricks_*
13-
gh release download $BRICKS_VERSION -R databricks/bricks -p "*$BRICKS_ARCH.tar.gz"
14-
tar -xvf bricks_*_$BRICKS_ARCH.tar.gz
11+
BRICKS_DIR=$(mktemp -d -t bricks-XXXXXXXXXX)
12+
pushd $BRICKS_DIR
13+
gh release download $BRICKS_VERSION -R databricks/bricks -p "*$BRICKS_ARCH.zip"
14+
unzip bricks_*_$BRICKS_ARCH.zip
15+
rm bricks_*_$BRICKS_ARCH.zip
16+
ls
1517

1618
popd
1719
mkdir -p bin
1820
cd ./bin
1921
rm -rf bricks
20-
mv /tmp/bricks ./
22+
BRICKS_BINARY=$(cd $BRICKS_DIR && ls bricks*)
23+
# strip the version from the binary name but keep exe on Windows
24+
BRICKS_TARGET_NAME=$(echo $BRICKS_BINARY | sed -E 's/(.*)_v[0-9]\.[0-9]\.[0-9](\.exe)?/\1\2/g')
25+
mv $BRICKS_DIR/$BRICKS_BINARY $BRICKS_TARGET_NAME
26+
rm -rf $BRICKS_DIR

packages/databricks-vscode/src/cli/CliWrapper.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import * as assert from "assert";
22
import {Uri} from "vscode";
33
import {SyncDestination} from "../configuration/SyncDestination";
4-
import {ExtensionContext} from "vscode";
4+
import {promisify} from "node:util";
5+
import {execFile as execFileCb} from "node:child_process";
56

67
import {CliWrapper} from "./CliWrapper";
7-
import {mock, spy} from "ts-mockito";
8+
9+
const execFile = promisify(execFileCb);
810

911
describe(__filename, () => {
12+
it("should embed a working bricks CLI", async () => {
13+
let bricksPath = __dirname + "/../../bin/bricks";
14+
let result = await execFile(bricksPath, ["--help"]);
15+
assert.ok(result.stdout.indexOf("bricks") > 0);
16+
});
17+
1018
it("should create sync command", () => {
1119
const cli = new CliWrapper({
1220
asAbsolutePath(path: string) {

0 commit comments

Comments
 (0)