diff --git a/.circleci/config.yml b/.circleci/config.yml index 9eed75a271b48..b9df7f3f7379f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -334,8 +334,6 @@ jobs: command: yarn --cwd aio test:ci no_output_timeout: 20m - # TODO: run the following tests under bazel - # Check the bundle sizes. - run: yarn --cwd aio payload-size @@ -360,8 +358,6 @@ jobs: command: yarn --cwd aio test-local:ci no_output_timeout: 20m - # TODO: run the following tests under bazel - # Check the bundle sizes. - run: yarn --cwd aio payload-size aio-local diff --git a/aio/BUILD.bazel b/aio/BUILD.bazel index b8324f4d98d22..771c96bf3150f 100644 --- a/aio/BUILD.bazel +++ b/aio/BUILD.bazel @@ -172,6 +172,9 @@ E2E_DEPS = APPLICATION_DEPS + [ "//aio/tools:windows-chromium-path", ] +# Poll period for architect rules that watch for changes +ARCHITECT_POLL_MS = 1000 + # Stamp npm_link targets for all dependencies that correspond to a # first-party equivalent pacakge in angular. link_local_packages(all_aio_deps = collections.uniq(APPLICATION_DEPS + TEST_DEPS + E2E_DEPS)) @@ -188,7 +191,6 @@ architect( "--output-path=build-app", ], chdir = "$(RULEDIR)", - configuration_env_vars = ["NG_BUILD_CACHE"], data = [":application_files_bin"] + select({ ":aio_local_deps": substitute_local_package_deps(APPLICATION_DEPS), "//conditions:default": APPLICATION_DEPS, @@ -247,7 +249,7 @@ aio_test( args = [ "site:test", "--watch", - "--poll=1000", + "--poll=%d" % ARCHITECT_POLL_MS, ], data = TEST_DATA, tags = [ @@ -265,7 +267,6 @@ architect_test( "--port=0", ], chdir = package_name(), - configuration_env_vars = ["NG_BUILD_CACHE"], data = E2E_FILES + select({ ":aio_local_deps": substitute_local_package_deps(E2E_DEPS), "//conditions:default": E2E_DEPS, @@ -285,7 +286,7 @@ architect( args = [ "site:serve", "--open", - "--poll=1000", + "--poll=%d" % ARCHITECT_POLL_MS, "--live-reload", "--watch", ], diff --git a/aio/aio_targets.bzl b/aio/aio_targets.bzl index 5490184a08345..bd05604d685b3 100644 --- a/aio/aio_targets.bzl +++ b/aio/aio_targets.bzl @@ -5,7 +5,6 @@ def aio_test(name, data, args, **kwargs): name = name, args = args, chdir = native.package_name(), - configuration_env_vars = ["NG_BUILD_CACHE"], data = data, env = { "CHROME_BIN": "../$(CHROMIUM)", diff --git a/aio/angular.json b/aio/angular.json index acf46a8bdfae5..959f0729e0a97 100644 --- a/aio/angular.json +++ b/aio/angular.json @@ -6,7 +6,12 @@ "warnings": { "typescriptMismatch": false }, - "analytics": false + "analytics": false, + "cache": { + // Disable build caching as the cache folder will just be dropped + // when run under Bazel sandboxed execution. + "enabled": false + } }, "newProjectRoot": "projects", "projects": { diff --git a/aio/content/examples/examples.bzl b/aio/content/examples/examples.bzl index 44300a4679ee8..17aa04cc42344 100644 --- a/aio/content/examples/examples.bzl +++ b/aio/content/examples/examples.bzl @@ -206,7 +206,6 @@ def docs_example(name, test = True, test_tags = [], test_exec_properties = {}, f "//aio:aio_local_deps": LOCAL_PACKAGE_ARGS, "//conditions:default": [], }), - configuration_env_vars = ["NG_BUILD_CACHE"], entry_point = "//aio/tools/examples:run-example-e2e.mjs", env = { "CHROME_BIN": "$(CHROMIUM)", diff --git a/aio/content/examples/view-encapsulation/e2e/src/app.e2e-spec.ts b/aio/content/examples/view-encapsulation/e2e/src/app.e2e-spec.ts index 901ef6d9d4e89..5a7bddf9a6640 100644 --- a/aio/content/examples/view-encapsulation/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/view-encapsulation/e2e/src/app.e2e-spec.ts @@ -92,8 +92,7 @@ describe('View Encapsulation App', () => { async function findShadowDomElement(shadowHostSelector: string, shadowElementSelector: string): Promise { const shadowHost = browser.findElement(by.css(shadowHostSelector)); const shadowRoot: any = await browser.executeScript('return arguments[0].shadowRoot', shadowHost); - // TODO: Using this solution to find the shadow element after Chrome 97: https://stackoverflow.com/a/70611425. - // Is there a better way to do this? + // Using this solution to find the shadow element after Chrome 97: https://stackoverflow.com/a/70611425. const rootKey = Object.keys(shadowRoot)[0]; const rootId = shadowRoot[rootKey]; return new WebElement(browser, rootId).findElement(by.css(shadowElementSelector)); diff --git a/aio/scripts/local-workspace-status.mjs b/aio/scripts/local-workspace-status.mjs index b486dec6560e3..29f375960d31c 100644 --- a/aio/scripts/local-workspace-status.mjs +++ b/aio/scripts/local-workspace-status.mjs @@ -14,7 +14,7 @@ const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); const pkgJsonPath = path.join(__dirname, '..', 'package.json'); const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8')); -const aioAngularVersion = pkgJson.dependencies['@angular/core'].replace(/^[\^~]/, '') + "+locallySubstituted"; +const aioAngularVersion = pkgJson.dependencies['@angular/core'].replace(/^[\^~]/, '') + "+forAIOLocalBuildToAvoidMismatch"; // Output the workspace status variable format to stdout so Bazel can read it console.log(`\ diff --git a/aio/scripts/run-with-local-server.mjs b/aio/scripts/run-with-local-server.mjs index 384d4fce0205b..6eaa7dea8df00 100644 --- a/aio/scripts/run-with-local-server.mjs +++ b/aio/scripts/run-with-local-server.mjs @@ -36,19 +36,16 @@ async function main(args) { '--quiet' ]; const lightserverProcess = sh.exec(lightserverCmd.join(' '), {async: true, silent: true}); - const command = [ testScript, ...testScriptArgs ].join(' ').replace('LOCALHOST_URL', `http://localhost:${port}`); - sh.exec(command); - + const returnCode = sh.exec(command).code; + await killProcess(lightserverProcess); - // TODO: On Windows something remains unresolved and node does not exit. - // It does not appear to be the lightserver process. - process.exit(0); + process.exit(returnCode); } (async() => await main(process.argv.slice(2)))(); @@ -63,4 +60,4 @@ function killProcess(childProcess) { resolve(); }); }); -} \ No newline at end of file +} diff --git a/aio/tools/examples/BUILD.bazel b/aio/tools/examples/BUILD.bazel index b4ca861c5f2c4..05b27d819db11 100644 --- a/aio/tools/examples/BUILD.bazel +++ b/aio/tools/examples/BUILD.bazel @@ -10,58 +10,61 @@ exports_files([ "run-example-e2e.mjs", ]) -EXAMPLE_BOILERPLATE_SRCS = [ - "example-boilerplate.js", - "constants.js", - "//aio/tools/examples/shared", - "//aio/content/examples", -] - -EXAMPLE_BOILERPLATE_DEPS = [ - "@aio_npm//canonical-path", - "@aio_npm//fs-extra", - "@aio_npm//ignore", - "@aio_npm//shelljs", - "@aio_npm//yargs", -] +js_library( + name = "example-boilerplate-lib", + srcs = [ + "constants.js", + "example-boilerplate.js", + ], + deps = [ + "//aio/content/examples", + "//aio/tools/examples/shared", + "@aio_npm//canonical-path", + "@aio_npm//fs-extra", + "@aio_npm//ignore", + "@aio_npm//shelljs", + "@aio_npm//yargs", + ], +) nodejs_binary( name = "example-boilerplate", - data = EXAMPLE_BOILERPLATE_SRCS + EXAMPLE_BOILERPLATE_DEPS, + data = [":example-boilerplate-lib"], entry_point = "example-boilerplate.js", ) jasmine_node_test( name = "example-boilerplate-test", srcs = ["example-boilerplate.spec.js"], - deps = EXAMPLE_BOILERPLATE_SRCS + EXAMPLE_BOILERPLATE_DEPS, + deps = [":example-boilerplate-lib"], ) -CREATE_EXAMPLE_SRCS = [ - "create-example.js", - "constants.js", -] + glob(["shared/**"]) - -CREATE_EXAMPLE_DEPS = [ - "@aio_npm//@bazel/buildozer", - "@aio_npm//canonical-path", - "@aio_npm//fs-extra", - "@aio_npm//ignore", - "@aio_npm//shelljs", - "@aio_npm//yargs", -] +js_library( + name = "create-example-lib", + srcs = [ + "create-example.js", + "constants.js", + ] + glob(["shared/**"]), + deps = [ + "@aio_npm//@bazel/buildozer", + "@aio_npm//canonical-path", + "@aio_npm//fs-extra", + "@aio_npm//ignore", + "@aio_npm//shelljs", + "@aio_npm//yargs", + ], +) nodejs_binary( name = "create-example", - data = CREATE_EXAMPLE_SRCS + CREATE_EXAMPLE_DEPS, + data = [":create-example-lib"], entry_point = "create-example.js", ) jasmine_node_test( name = "create-example-test", srcs = ["create-example.spec.js"], - deps = - CREATE_EXAMPLE_SRCS + CREATE_EXAMPLE_DEPS, + deps = [":create-example-lib"], ) js_library( diff --git a/aio/tools/examples/create-example.js b/aio/tools/examples/create-example.js index 3033ca3a5a4eb..7b34213fe8812 100644 --- a/aio/tools/examples/create-example.js +++ b/aio/tools/examples/create-example.js @@ -56,11 +56,20 @@ if (require.main === module) { * Create the directory and marker files for the new example. */ function createEmptyExample(exampleName, examplePath) { + validateExampleName(exampleName); ensureExamplePath(examplePath); writeExampleConfigFile(examplePath); writeStackBlitzFile(exampleName, examplePath); } +function validateExampleName(exampleName) { + if (/\s/.test(exampleName)) { + throw new Error( + `Unable to create example. The example name contains spaces: '${exampleName}'` + ) + } +} + /** * Ensure that the new example directory exists. */ @@ -144,4 +153,4 @@ exports.ensureExamplePath = ensureExamplePath; exports.writeExampleConfigFile = writeExampleConfigFile; exports.writeStackBlitzFile = writeStackBlitzFile; exports.copyExampleFiles = copyExampleFiles; -exports.titleize = titleize; \ No newline at end of file +exports.titleize = titleize; diff --git a/aio/tools/examples/create-example.spec.js b/aio/tools/examples/create-example.spec.js index dee00825f3e71..4b0bc009f10e0 100644 --- a/aio/tools/examples/create-example.spec.js +++ b/aio/tools/examples/create-example.spec.js @@ -30,6 +30,12 @@ describe('create-example tool', () => { .toHaveBeenCalledWith( path.resolve(`/path/to/foo-bar/${STACKBLITZ_CONFIG_FILENAME}`), jasmine.any(String)); }); + + it('should fail if the example name contains spaces', () => { + expect(() => createEmptyExample('foo bar', '/path/to/foo-bar')).toThrowError( + `Unable to create example. The example name contains spaces: 'foo bar'` + ); + }); }); describe('ensureExamplePath', () => { diff --git a/aio/tools/transforms/cli-docs-package/index.js b/aio/tools/transforms/cli-docs-package/index.js index aa64b89ce6330..626858c494d47 100644 --- a/aio/tools/transforms/cli-docs-package/index.js +++ b/aio/tools/transforms/cli-docs-package/index.js @@ -20,7 +20,7 @@ function resolveCliSourcePath() { return path; } // Case: bazel test, find in runfiles - return runfiles.resolveWorkspaceRelative('../angular_cli_src'); + return runfiles.resolve('angular_cli_src'); } // Define the dgeni package for generating the docs