Skip to content

Commit f6311a2

Browse files
committed
WIP
1 parent d8e77d6 commit f6311a2

File tree

22 files changed

+473
-162
lines changed

22 files changed

+473
-162
lines changed

.circleci/config.yml

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,35 @@ jobs:
312312
resource_class: xlarge
313313
environment:
314314
SAUCE_USERNAME: "angular-components"
315-
SAUCE_ACCESS_KEY: "63348201a846-eeb9-3ee4-300f-ea990b8a"
316-
# Note: This number should not be too high because otherwise we might run into
317-
# a rate limit exception.
318-
KARMA_PARALLEL_BROWSERS: 2
315+
SAUCE_ACCESS_KEY: "a8b099ae-f003-4ee3-9bee-648a10284336"
316+
SAUCE_TUNNEL_IDENTIFIER: angular-material-<< pipeline.id >>
319317
steps:
320318
- checkout_and_rebase
321319
- *restore_cache
322320
- *setup_bazel_ci_config
323321
- *yarn_install
324322

325-
- run: ./scripts/circleci/run-saucelabs-tests.sh
323+
- run:
324+
name: Saucelabs tunnel
325+
command: ./scripts/saucelabs/start-tunnel.sh
326+
background: true
327+
- run:
328+
name: Waiting for Saucelabs tunnel
329+
command: ./scripts/saucelabs/wait-tunnel.sh
330+
- run:
331+
name: Saucelabs browser daemon
332+
command: yarn -s sauce-bazel-daemon
333+
background: true
334+
335+
- run:
336+
name: Running tests
337+
command: |
338+
TESTS=$(yarn -s bazel query --output label 'attr("tags", "saucelabs", //src/...)')
339+
yarn -s bazel test ${TESTS} --jobs=2
340+
341+
- run:
342+
name: Shutting down tunnel
343+
command: ./scripts/saucelabs/stop-tunnel.sh
326344
- *slack_notify_on_failure
327345

328346
# ----------------------------------
@@ -663,46 +681,8 @@ workflows:
663681

664682
default_workflow:
665683
jobs:
666-
- bazel_build:
667-
filters: *ignore_presubmit_branch_filter
668-
- view_engine_build:
669-
filters: *ignore_presubmit_branch_filter
670-
- view_engine_test:
671-
filters: *ignore_presubmit_branch_filter
672-
- api_golden_checks:
673-
filters: *ignore_presubmit_branch_filter
674-
- integration_tests:
675-
filters: *ignore_presubmit_branch_filter
676-
- tests_local_browsers:
677-
filters: *ignore_presubmit_branch_filter
678-
- tests_browserstack:
679-
filters: *ignore_presubmit_branch_filter
680684
- tests_saucelabs:
681685
filters: *ignore_presubmit_branch_filter
682-
- e2e_tests:
683-
filters: *ignore_presubmit_branch_filter
684-
- build_release_packages:
685-
filters: *ignore_presubmit_branch_filter
686-
- upload_release_packages:
687-
# We don't want to run this job on push builds because for those, the
688-
# `publish_snapshots` runs, and publishes build artifacts.
689-
filters: *only_on_pull_requests_filter
690-
requires:
691-
- build_release_packages
692-
- lint:
693-
filters: *ignore_presubmit_branch_filter
694-
- ngcc_compatibility:
695-
filters: *ignore_presubmit_branch_filter
696-
requires:
697-
- build_release_packages
698-
- ngcc_compatibility_snapshot:
699-
filters: *only_main_branch_filter
700-
requires:
701-
- build_release_packages
702-
- publish_snapshots:
703-
filters: *publish_branches_filter
704-
requires:
705-
- build_release_packages
706686

707687
# Snapshot tests workflow that is scheduled to run all specified jobs every hour.
708688
# This workflow runs various jobs against the Angular snapshot builds from Github.

BUILD.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,3 @@ genrule(
2626
outs = ["entry_points_manifest.json"],
2727
cmd = "echo '%s' > $@" % entryPoints,
2828
)
29-
30-
genrule(
31-
name = "saucelabs_tunnel_identifier",
32-
outs = ["saucelabs_tunnel_identifier.txt"],
33-
cmd = "$(execpath //scripts/saucelabs:extract-tunnel-identifier) > $@",
34-
stamp = True,
35-
tools = ["//scripts/saucelabs:extract-tunnel-identifier"],
36-
)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"integration-tests:size-test": "bazel test //integration/size-test/...",
4949
"check-mdc-tests": "ts-node --project scripts/tsconfig.json scripts/check-mdc-tests.ts",
5050
"check-mdc-exports": "ts-node --project scripts/tsconfig.json scripts/check-mdc-exports.ts",
51-
"check-tools": "yarn tsc --project tools/tsconfig-ci.json"
51+
"check-tools": "yarn tsc --project tools/tsconfig-ci.json",
52+
"sauce-bazel-daemon": "ts-node --project tools/saucelabs-bazel/tsconfig.json tools/saucelabs-bazel/background-service/cli.ts"
5253
},
5354
"version": "12.1.0-next.0",
5455
"dependencies": {

scripts/circleci/run-saucelabs-tests.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

scripts/saucelabs/BUILD.bazel

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/saucelabs/extract-tunnel-identifier.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/material-experimental/mdc-form-field/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ sass_library(
8787
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib",
8888
"//src/material/core:core_scss_lib",
8989
],
90-
)
90+
)

test/BUILD.bazel

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("//tools:create-system-config.bzl", "create_system_config")
2-
load("//tools:defaults.bzl", "ts_library")
2+
load("//tools:defaults.bzl", "js_library", "ts_library")
33

44
package(default_visibility = ["//visibility:public"])
55

@@ -33,3 +33,21 @@ create_system_config(
3333
output_name = "system-config.js",
3434
packages_dir = "dist/packages",
3535
)
36+
37+
js_library(
38+
name = "karma-browser-config",
39+
srcs = [
40+
"browser-providers.js",
41+
"karma-browsers.json",
42+
],
43+
)
44+
45+
js_library(
46+
name = "karma-saucelabs-config",
47+
srcs = ["karma-saucelabs.conf.js"],
48+
deps = [
49+
":karma-browser-config",
50+
"//tools/saucelabs-bazel/launcher",
51+
"@npm//@bazel/runfiles",
52+
],
53+
)

test/karma-browsers.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
{
2-
"ChromeHeadlessCI": {
3-
"base": "ChromeHeadless",
4-
"flags": [
5-
"--window-size=1024,768",
6-
"--no-sandbox"
7-
]
8-
},
92
"ChromeLocalDebug": {
103
"base": "Chrome",
114
"flags": [
125
"--window-size=1024,768"
136
]
147
},
158
"SAUCELABS_IOS13": {
16-
"base": "SauceLabs",
9+
"base": "SauceLabsDaemon",
1710
"browserName": "Safari",
1811
"platformVersion": "13.2",
1912
"platformName": "iOS",

test/karma-saucelabs.conf.js

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
1-
const {readFileSync} = require('fs');
1+
const {runfiles} = require('@bazel/runfiles');
22
const {customLaunchers, platformMap} = require('./browser-providers');
33

4+
// Since we load a Karma plugin directly from the sources, we load the NodeJS require
5+
// patch. This is needed as the TypeScript output uses absolute manifest paths between files.
6+
// TODO: Consider removing if we switch the repository to `ts_project`, or if the linker
7+
// symlinks the workspace root by default.
8+
runfiles.patchRequire();
9+
410
module.exports = karmaConfig => {
511
const config = {
612
plugins: [
7-
require('karma-sauce-launcher')
13+
require(runfiles.resolveWorkspaceRelative('tools/saucelabs-bazel/launcher/index.js')),
814
],
915
customLaunchers: customLaunchers,
10-
sauceLabs: {
11-
testName: 'Angular Material Unit Tests',
12-
startConnect: false,
13-
recordVideo: false,
14-
recordScreenshots: false,
15-
idleTimeout: 600,
16-
commandTimeout: 600,
17-
maxDuration: 5400,
18-
},
19-
browserNoActivityTimeout: 300000,
20-
browserDisconnectTimeout: 180000,
21-
browserDisconnectTolerance: 3,
22-
captureTimeout: 180000,
16+
browserNoActivityTimeout: 90000,
17+
browserDisconnectTimeout: 90000,
18+
browserDisconnectTolerance: 2,
19+
captureTimeout: 90000,
2320
browsers: platformMap.saucelabs,
24-
25-
// Try Websocket for a faster transmission first. Fallback to polling if necessary.
26-
transports: ['websocket', 'polling'],
21+
transports: ['polling', 'websocket'],
2722
};
2823

29-
// The tunnel identifier has been written to a stamped genrule that access the tunnel
30-
// identifier through a volatile status key. This ensures that test and build results
31-
// are not invalidated whenever the tunnel identifier changes (which it does for each PR).
32-
const tunnelIdentifier = readFileSync(
33-
require.resolve('../saucelabs_tunnel_identifier.txt'), 'utf8');
34-
35-
config.sauceLabs.build = tunnelIdentifier;
36-
config.sauceLabs.tunnelIdentifier = tunnelIdentifier;
37-
3824
karmaConfig.set(config);
3925
};

tools/defaults.bzl

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Re-export of Bazel rules with repository-wide defaults
22

3+
load("@build_bazel_rules_nodejs//:index.bzl", _js_library = "js_library")
34
load("@io_bazel_rules_sass//:defs.bzl", _sass_binary = "sass_binary", _sass_library = "sass_library")
45
load("@npm//@angular/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
56
load("@npm//@bazel/jasmine:index.bzl", _jasmine_node_test = "jasmine_node_test")
@@ -31,6 +32,9 @@ def sass_binary(sourcemap = False, **kwargs):
3132
def sass_library(**kwargs):
3233
_sass_library(**kwargs)
3334

35+
def js_library(**kwargs):
36+
_js_library(**kwargs)
37+
3438
def ts_library(tsconfig = None, deps = [], testonly = False, **kwargs):
3539
# Add tslib because we use import helpers for all public packages.
3640
local_deps = ["@npm//tslib"] + deps
@@ -156,22 +160,25 @@ def ng_e2e_test_library(deps = [], tsconfig = None, **kwargs):
156160
)
157161

158162
def karma_web_test(name, **kwargs):
159-
tags = kwargs.pop("tags", [])
160-
# Custom standalone web test that can be run to test against any browser
161-
# that is manually connected to.
162-
_karma_web_test(
163-
name = "%s_bin" % name,
164-
tags = ["manual"],
165-
**kwargs
166-
)
167-
168-
# Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1429
169-
native.sh_test(
170-
name = "%s" % name,
171-
srcs = ["%s_bin" % name],
172-
tags = tags + ["ibazel_notify_changes"],
173-
)
163+
tags = kwargs.pop("tags", [])
164+
timeout = kwargs.pop("timeout", None)
174165

166+
# Custom standalone web test that can be run to test against any browser
167+
# that is manually connected to.
168+
_karma_web_test(
169+
name = "%s_bin" % name,
170+
tags = ["manual"],
171+
timeout = timeout,
172+
**kwargs
173+
)
174+
175+
# Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1429
176+
native.sh_test(
177+
name = "%s" % name,
178+
srcs = ["%s_bin" % name],
179+
timeout = timeout,
180+
tags = tags + ["ibazel_notify_changes"],
181+
)
175182

176183
def karma_web_test_suite(name, **kwargs):
177184
web_test_args = {}
@@ -204,13 +211,8 @@ def karma_web_test_suite(name, **kwargs):
204211
)
205212

206213
sauce_web_test_args = dict(**web_test_args)
207-
sauce_web_test_args["data"] = sauce_web_test_args.get("data", []) + [
208-
"//:saucelabs_tunnel_identifier",
209-
"//test:browser-providers.js",
210-
"//test:karma-browsers.json"
211-
]
212214
sauce_web_test_args["deps"] = sauce_web_test_args.get("deps", []) + [
213-
"@npm//karma-sauce-launcher"
215+
"//test:karma-saucelabs-config",
214216
]
215217

216218
# Add a saucelabs target for these karma tests
@@ -219,6 +221,7 @@ def karma_web_test_suite(name, **kwargs):
219221
timeout = "long",
220222
config_file = "//test:karma-saucelabs.conf.js",
221223
tags = ["manual", "saucelabs", "no-remote-exec"],
224+
flaky = False,
222225
**sauce_web_test_args
223226
)
224227

tools/saucelabs-bazel/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
ts_library(
6+
name = "saucelabs-bazel",
7+
srcs = [
8+
"browser.ts",
9+
"ipc-messages.ts",
10+
],
11+
deps = [],
12+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
ts_library(
6+
name = "background-service",
7+
srcs = glob(["**/*.ts"]),
8+
deps = [
9+
"//tools/saucelabs-bazel",
10+
"@npm//@types/node",
11+
"@npm//@types/selenium-webdriver",
12+
"@npm//chalk",
13+
],
14+
)

0 commit comments

Comments
 (0)