Skip to content

Commit e7f6121

Browse files
committed
build: run bazel tests on CI and generate bazel build dist/npm_bazel folder
Next steps after this are testing of all local workflows and cut-over to a bazel built release. Will co-ordinate with Angular team on this.
1 parent 8553115 commit e7f6121

File tree

12 files changed

+94
-43
lines changed

12 files changed

+94
-43
lines changed

.circleci/config.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,12 @@ jobs:
2727
- run: scripts/format.sh
2828
- run: scripts/build.sh << parameters.dependency_type >>
2929
- run: scripts/test.sh
30-
bazel-build-and-test:
31-
docker:
32-
- image: cimg/node:14.18.3@sha256:30583ce79b08d318b1fc5e17a613d21ef960091e5442b06eb49c56fa180a3b30
33-
steps:
34-
- checkout
35-
- node/install-packages:
36-
pkg-manager: yarn
37-
# Disable bazel build & test temporarily
38-
- run: yarn bazel info
3930
workflows:
4031
build-and-test:
4132
jobs:
4233
- build-and-test:
4334
name: build-and-test
4435
dependency_type: "package.json"
45-
bazel-build-and-test:
46-
jobs:
47-
- bazel-build-and-test:
48-
name: bazel-build-and-test
4936
buid-and-test-against-builds:
5037
jobs:
5138
- build-and-test:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.npmrc
21
.vscode-test
32
.DS_Store
43
node_modules

.npmrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on
2+
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what
3+
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules)
4+
hoist=false
5+
6+
# Allow for missing peer dependencies on pnpm import.
7+
# See https://github.com/aspect-build/rules_js/pull/445 for more context.
8+
strict-peer-dependencies=false

BUILD.bazel

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
load("@aspect_rules_js//js:defs.bzl", "js_library")
2+
load("@aspect_rules_js//js/private:expand_template.bzl", "expand_template")
23
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
34
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
45
load("@npm//:defs.bzl", "npm_link_all_packages")
56
load("@npm//:vsce/package_json.bzl", vsce_bin = "bin")
7+
load(":version.bzl", "VERSION")
68

79
npm_link_all_packages(name = "node_modules")
810

@@ -18,10 +20,20 @@ ts_config(
1820
visibility = ["//visibility:public"]
1921
)
2022

23+
expand_template(
24+
name = "package_json_expanded",
25+
template = "package.json",
26+
out = "package_expanded.json",
27+
substitutions = {
28+
"0.0.0-PLACEHOLDER": VERSION,
29+
"./dist/client/src/extension": "./index",
30+
}
31+
)
32+
2133
npm_package(
22-
name = "npm",
34+
name = "vsix_sandbox",
2335
srcs = [
24-
"package.json",
36+
"package_expanded.json",
2537
"angular.png",
2638
"CHANGELOG.md",
2739
"README.md",
@@ -57,22 +69,34 @@ npm_package(
5769
"**/*.map",
5870
],
5971
replace_prefixes = {
72+
"package_expanded.json": "package.json",
6073
"client/": "",
6174
"syntaxes/src/": "syntaxes/",
6275
},
63-
visibility = ["//integration:__subpackages__"],
6476
)
6577

6678
vsce_bin.vsce(
6779
name = "vsix",
6880
srcs = [
69-
":npm",
81+
":vsix_sandbox",
7082
],
71-
outs = ["ng-template.vsix"],
72-
chdir = "npm",
83+
outs = ["ng-template-{}.vsix".format(VERSION)],
84+
chdir = "vsix_sandbox",
7385
args = [
7486
"package",
7587
"-o",
76-
"../ng-template.vsix"
88+
"../ng-template-{}.vsix".format(VERSION)
89+
],
90+
)
91+
92+
npm_package(
93+
name = "npm",
94+
srcs = [
95+
":vsix_sandbox",
96+
":vsix",
97+
],
98+
root_paths = [
99+
"vsix_sandbox"
77100
],
101+
visibility = ["//integration:__subpackages__"],
78102
)

WORKSPACE

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22

33
http_archive(
44
name = "aspect_rules_js",
5-
sha256 = "538049993bec3ee1ae9b1c3cd669156bca04eb67027b222883e47b0a2aed2e67",
6-
strip_prefix = "rules_js-1.0.0",
7-
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.0.0.tar.gz",
5+
sha256 = "fbfcfb5a1e4bccd8030b64522e561046731bdacd4a9ff8fa3334fed0e6c61af1",
6+
# 1.2.0 pre-release
7+
strip_prefix = "rules_js-9f6f33c72ac49dd829de7a622bd8fd81ec9d03e1",
8+
url = "https://github.com/aspect-build/rules_js/archive/9f6f33c72ac49dd829de7a622bd8fd81ec9d03e1.tar.gz",
89
)
910

1011
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
@@ -13,9 +14,9 @@ rules_js_dependencies()
1314

1415
http_archive(
1516
name = "aspect_rules_ts",
16-
sha256 = "1945d5a356d0ec85359dea411467dec0f98502503a53798ead7f54aef849598b",
17-
strip_prefix = "rules_ts-1.0.0-rc1",
18-
url = "https://github.com/aspect-build/rules_ts/archive/refs/tags/v1.0.0-rc1.tar.gz",
17+
sha256 = "3eb3171c26eb5d0951d51ae594695397218fb829e3798eea5557814723a1b3da",
18+
strip_prefix = "rules_ts-1.0.0-rc3",
19+
url = "https://github.com/aspect-build/rules_ts/archive/refs/tags/v1.0.0-rc3.tar.gz",
1920
)
2021

2122
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
@@ -24,9 +25,9 @@ rules_ts_dependencies(ts_version_from = "//:package.json",)
2425

2526
http_archive(
2627
name = "aspect_rules_jasmine",
27-
sha256 = "741d3376fdbf0c0c742e3bac0f854b1d49dbe1998d3530ef6f22f467675ca177",
28-
strip_prefix = "rules_jasmine-0.0.1",
29-
url = "https://github.com/aspect-build/rules_jasmine/archive/refs/tags/v0.0.1.tar.gz",
28+
sha256 = "938a2818100fd89e7600a45b7ba4fcd4114c11c5b5741db30ff7c6e0dcb2ea4b",
29+
strip_prefix = "rules_jasmine-0.1.0",
30+
url = "https://github.com/aspect-build/rules_jasmine/archive/refs/tags/v0.1.0.tar.gz",
3031
)
3132

3233
load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependencies")
@@ -35,9 +36,9 @@ rules_jasmine_dependencies()
3536

3637
http_archive(
3738
name = "aspect_rules_esbuild",
38-
sha256 = "6446a784e72b04c33bc48debd84c5a54db4727f0a4a61a0da9faa64bededd7c2",
39-
strip_prefix = "rules_esbuild-0909898c1344569f59fa83f70a1db7548563c274",
40-
url = "https://github.com/aspect-build/rules_esbuild/archive/0909898c1344569f59fa83f70a1db7548563c274.tar.gz",
39+
sha256 = "1e365451341ffb2490193292dfd9953f2ca009586c2381cb4dc08d01e48866b7",
40+
strip_prefix = "rules_esbuild-0.12.0",
41+
url = "https://github.com/aspect-build/rules_esbuild/archive/refs/tags/v0.12.0.tar.gz",
4142
)
4243

4344
load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")
@@ -58,11 +59,11 @@ esbuild_register_toolchains(
5859
esbuild_version = ESBUILD_LATEST_VERSION,
5960
)
6061

61-
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
62+
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
6263

6364
nodejs_register_toolchains(
6465
name = "nodejs",
65-
node_version = DEFAULT_NODE_VERSION,
66+
node_version = "14.20.0",
6667
)
6768

6869
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
@@ -71,6 +72,7 @@ npm_translate_lock(
7172
name = "npm",
7273
yarn_lock = "//:yarn.lock",
7374
package_json = "//:package.json",
75+
npmrc = "//:.npmrc",
7476
verify_node_modules_ignored = "//:.bazelignore",
7577
public_hoist_packages = {
7678
# Hoist transitive closure of npm deps needed for vsce; this set was determined manually by
@@ -96,6 +98,7 @@ npm_translate_lock(
9698
name = "npm_integration_workspace",
9799
yarn_lock = "//integration/workspace:yarn.lock",
98100
package_json = "//integration/workspace:package.json",
101+
npmrc = "//:.npmrc",
99102
verify_node_modules_ignored = "//:.bazelignore",
100103
)
101104

@@ -107,6 +110,7 @@ npm_translate_lock(
107110
name = "npm_integration_pre_apf_project",
108111
yarn_lock = "//integration/pre_apf_project:yarn.lock",
109112
package_json = "//integration/pre_apf_project:package.json",
113+
npmrc = "//:.npmrc",
110114
verify_node_modules_ignored = "//:.bazelignore",
111115
)
112116

@@ -118,6 +122,7 @@ npm_translate_lock(
118122
name = "npm_integration_project",
119123
yarn_lock = "//integration/project:yarn.lock",
120124
package_json = "//integration/project:package.json",
125+
npmrc = "//:.npmrc",
121126
verify_node_modules_ignored = "//:.bazelignore",
122127
)
123128

integration/e2e/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ js_test(
2626
"//:npm",
2727
"//integration",
2828
"//integration/project",
29-
"//server:index",
3029
# Depend on //:node_modules/jasmine as a temporary work-around for jasmine escaping its
3130
# runfiles likely due to esm import issue in rules_js https://github.com/aspect-build/rules_js/issues/362
3231
"//:node_modules/jasmine",

integration/e2e/completion_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import * as vscode from 'vscode';
32

43
import {activate, COMPLETION_COMMAND, FOO_TEMPLATE_URI} from './helper';

integration/e2e/jasmine.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export async function run(): Promise<void> {
3333

3434
console.log(`Expecting to run ${jasmine.specFiles.length} specs.`);
3535

36+
console.log(JSON.stringify(jasmine.specFiles, null, 2))
37+
3638
if (jasmine.specFiles.length === 0) {
3739
throw new Error('No specs found');
3840
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@
212212
"test": "yarn compile:test && jasmine --config=jasmine.json",
213213
"test:inspect": "yarn compile:test && node --inspect-brk node_modules/jasmine/bin/jasmine.js --config=jasmine.json",
214214
"test:lsp": "yarn compile:integration && jasmine --config=integration/lsp/jasmine.json",
215-
"test:lsp-bazel": "yarn bazel test --test_output=streamed //integration:lsp_test",
215+
"test:lsp-bazel": "yarn bazel test --test_output=streamed //integration/lsp:test",
216216
"test:e2e": "yarn compile:integration && node dist/integration/e2e",
217-
"test:e2e-bazel": "yarn bazel test --test_output=streamed //integration/e2e:e2e_test",
217+
"test:e2e-bazel": "yarn bazel test --test_output=streamed //integration/e2e:test",
218218
"test:syntaxes": "yarn compile:syntaxes-test && yarn build:syntaxes && jasmine dist/syntaxes/test/driver.js",
219219
"test:bazel": "yarn bazel test --test_tag_filters=unit_test //...",
220220
"test:bazel-watch": "yarn ibazel test --test_tag_filters=unit_test //..."

scripts/build.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,32 @@ fi
3030

3131
set -ex -o pipefail
3232

33+
# Clean up from last build
34+
rm -rf dist
35+
36+
# Run legacy yarn install to update the lock file since we may have modified the package.json above
37+
# and so that we can call bazel via yarn bazel
38+
yarn install
39+
40+
# Build the npm package with bazel
41+
yarn bazel build //:npm
42+
43+
# Copy the bazel built package to dist/npm_bazel
44+
# TODO: copy to dist/npm when ready to cut-over
45+
mkdir -p dist/npm_bazel
46+
cp -r bazel-bin/npm/ dist/npm_bazel
47+
chmod -R +w dist/npm_bazel
48+
49+
################################################################################
50+
#### LEGACY PRE-BAZEL BUILD --- can be removed after cut-over
51+
################################################################################
52+
3353
# Enable extended pattern matching features
3454
shopt -s extglob
3555

3656
# Clean up from last build
37-
rm -rf dist
3857
rm -rf **/*.tsbuildinfo
3958

40-
41-
yarn install;
42-
4359
# Build the client and server
4460
yarn run compile
4561

scripts/test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
set -ex -o pipefail
44

5+
yarn bazel test //...
6+
7+
# E2E test that brings up full vscode
8+
# TODO: Disabled for now because it cannot be run on CircleCI
9+
# bazel test --test_output=streamed //integration/e2e:test
10+
11+
################################################################################
12+
#### LEGACY PRE-BAZEL BUILD --- can be removed after cut-over
13+
################################################################################
14+
515
# Install test project dependencies
616
if [[ -z "${CI}" ]]; then
717
(cd integration/project && yarn)

version.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This version is used by Bazel to generate the release artifacts
2+
VERSION="14.2.0"

0 commit comments

Comments
 (0)