Skip to content

Commit

Permalink
build: run partial compilation tests with linker at JIT
Browse files Browse the repository at this point in the history
Runs partial compilation tests with the linker at JIT. This helps
validating the Angular linker to catch bugs as reported by Stackblitz
which relies on JIT compilation with its v1 non-webcontainer approach.
  • Loading branch information
devversion committed Nov 3, 2021
1 parent a801603 commit fb43821
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 14 deletions.
52 changes: 47 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ jobs:
- *yarn_install
- *setup_bazel_binary

- run: yarn integration-tests:partial-ivy
- run: yarn integration-tests
- run:
name: Running size integration tests (failures are reported in Slack only).
Expand All @@ -482,9 +481,47 @@ jobs:
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs all integration tests against Angular snapshot builds.
# Job that runs the AOT linker tests.
# ----------------------------------------------------------------------------
integration_tests_snapshot:
linker_aot_test:
<<: *job_defaults
resource_class: xlarge
environment:
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
steps:
- checkout_and_rebase
- *restore_cache
- *setup_bazel_ci_config
- *setup_bazel_remote_execution
- *yarn_install
- *setup_bazel_binary

- run: yarn test-linker-aot
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs the JIT linker tests.
# ----------------------------------------------------------------------------
linker_jit_test:
<<: *job_defaults
resource_class: xlarge
environment:
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
steps:
- checkout_and_rebase
- *restore_cache
- *setup_bazel_ci_config
- *setup_bazel_remote_execution
- *yarn_install
- *setup_bazel_binary

- run: yarn test-linker-jit
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs both AOT and JIT linker tests against Angular snapshot builds.
# ----------------------------------------------------------------------------
snapshot_linker_tests:
<<: *job_defaults
resource_class: xlarge
environment:
Expand All @@ -498,7 +535,8 @@ jobs:
- *yarn_install_loose_lockfile
- *setup_bazel_binary

- run: yarn integration-tests:partial-ivy
- run: yarn test-linker-aot
- run: yarn test-linker-jit
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -544,6 +582,10 @@ workflows:
filters: *ignore_presubmit_branch_filter
- integration_tests:
filters: *ignore_presubmit_branch_filter
- linker_aot_test:
filters: *ignore_presubmit_branch_filter
- linker_jit_test:
filters: *ignore_presubmit_branch_filter
- tests_local_browsers:
filters: *ignore_presubmit_branch_filter
- tests_browserstack:
Expand Down Expand Up @@ -578,7 +620,7 @@ workflows:
filters: *only_main_branch_filter
- mdc_snapshot_test_cronjob:
filters: *only_main_branch_filter
- integration_tests_snapshot:
- snapshot_linker_tests:
filters: *only_main_branch_filter

triggers:
Expand Down
1 change: 0 additions & 1 deletion integration/linker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ nodejs_test(
"@npm//glob",
],
entry_point = "link-packages-test.mjs",
tags = ["partial-compilation-integration"],
)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
"approve-api": "node ./scripts/approve-api-golden.js",
"approve-size-tests": "node ./scripts/approve-size-golden.js",
"integration-tests": "bazel test --test_tag_filters=-linker-integration-test --build_tests_only -- //integration/... -//integration/size-test/...",
"integration-tests:partial-ivy": "bazel test --partial_compilation --test_tag_filters=partial-compilation-integration,-firefox --build_tests_only -- //integration/... //src/...",
"integration-tests:size-test": "bazel test //integration/size-test/...",
"test-linker-aot": "bazel test --partial_compilation --test_tag_filters=partial-compilation-integration,-firefox --build_tests_only -- //integration/... //src/...",
"test-linker-jit": "bazel test --partial_compilation --test_tag_filters=partial-compilation-integration,-firefox --build_tests_only --//tools:force_partial_jit_compilation=True -- //integration/... //src/...",
"check-mdc-tests": "ts-node --project scripts/tsconfig.json scripts/check-mdc-tests.ts",
"check-mdc-exports": "ts-node --project scripts/tsconfig.json scripts/check-mdc-exports.ts",
"check-tooling-setup": "yarn tsc --project tools/tsconfig.json && yarn tsc --project .ng-dev/tsconfig.json",
Expand Down
19 changes: 19 additions & 0 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

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

exports_files([
Expand All @@ -13,6 +15,23 @@ config_setting(
},
)

# Command line flag that can be specified to force the JIT compilation to be used for tests
# with partial compilation. By default, tests are processed with the linker at build time.
bool_flag(
name = "force_partial_jit_compilation",
build_setting_default = False,
)

# Config setting that matches if the force JIT compilation build setting is enabled.
# This setting needs to be used in combination of the partial compilation build setting.
config_setting(
name = "force_partial_jit_compilation_enabled",
flag_values = {
"@npm//@angular/bazel/src:partial_compilation": "True",
":force_partial_jit_compilation": "True",
},
)

# Detect if the build is running with stamping enabled.
config_setting(
name = "stamp",
Expand Down
5 changes: 2 additions & 3 deletions tools/spec-bundling/esbuild.config-tmpl.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
// is generated and can end up in arbitrary Bazel packages.
import {createLinkerEsbuildPlugin} from 'angular_material/tools/angular/create_linker_esbuild_plugin.mjs';

// Conditionally, based on whether partial compilation is enabled, we run the
// linker on all files part of the test.
const plugins = TMPL_PARTIAL_COMPILATION_ENABLED
// Based on the Bazel action and its substitutions, we run the linker for all inputs.
const plugins = TMPL_RUN_LINKER
? [await createLinkerEsbuildPlugin(/.*/, /* ensureNoPartialDeclaration */ true)]
: [];

Expand Down
10 changes: 6 additions & 4 deletions tools/spec-bundling/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ def spec_bundle(name, platform, deps, **kwargs):
template = "//tools/spec-bundling:esbuild.config-tmpl.mjs",
output_name = "%s_config.mjs" % name,
substitutions = select({
# Pass through whether partial compilation is enabled or not. This is helpful
# for our integration tests which run all tests in partial compilation mode.
"//tools:partial_compilation_enabled": {"TMPL_PARTIAL_COMPILATION_ENABLED": "true"},
"//conditions:default": {"TMPL_PARTIAL_COMPILATION_ENABLED": "false"},
# Depending on whether partial compilation is enabled, we may want to run the linker
# to test the Angular compiler linker AOT processing. Additionally, a config setting
# can forcibly disable the linker to ensure tests rely on JIT linking at runtime.
"//tools:force_partial_jit_compilation_enabled": {"TMPL_RUN_LINKER": "false"},
"//tools:partial_compilation_enabled": {"TMPL_RUN_LINKER": "true"},
"//conditions:default": {"TMPL_RUN_LINKER": "false"},
}),
)

Expand Down

0 comments on commit fb43821

Please sign in to comment.