-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): add angular bazel architect
- Loading branch information
1 parent
7d7f85a
commit 6dc919d
Showing
39 changed files
with
10,746 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import %workspace%/../../common.bazelrc | ||
|
||
# The Angular CLI will by default try to write to a cache, but under Bazel it's a read only fs | ||
# so we need to disable it with this env var | ||
build --define=NG_BUILD_CACHE=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist | ||
/tmp | ||
/out-tsc | ||
# Only exists if Bazel was run | ||
/bazel-out | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# profiling files | ||
chrome-profiler-events*.json | ||
speed-measure-plugin*.json | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
.history/* | ||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
yarn-error.log | ||
testem.log | ||
/typings | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
load("@npm//@angular-devkit/architect-cli:index.bzl", "architect", "architect_test") | ||
|
||
architect( | ||
name = "build", | ||
args = [ | ||
"frontend:build", | ||
"--outputPath=$(@D)", | ||
], | ||
configuration_env_vars = ["NG_BUILD_CACHE"], | ||
data = glob( | ||
[ | ||
"src/*", | ||
"src/**", | ||
], | ||
exclude = [ | ||
"src/**/*.spec.ts", | ||
"src/test.ts", | ||
], | ||
) + [ | ||
"angular.json", | ||
"browserslist", | ||
"tsconfig.app.json", | ||
"tsconfig.json", | ||
"@npm//mime", | ||
"@npm//@angular/cli", | ||
"@npm//@angular/core", | ||
"@npm//@angular/router", | ||
"@npm//@angular/platform-browser-dynamic", | ||
"@npm//@angular-devkit/architect-cli", | ||
"@npm//@angular-devkit/build-angular", | ||
], | ||
output_dir = True, | ||
) | ||
|
||
architect_test( | ||
name = "test", | ||
args = ["frontend:test"], | ||
configuration_env_vars = ["NG_BUILD_CACHE"], | ||
data = glob([ | ||
"src/*", | ||
"src/**", | ||
]) + [ | ||
"angular.json", | ||
"karma.conf.js", | ||
"tsconfig.spec.json", | ||
"tsconfig.json", | ||
"@npm//@types/jasmine", | ||
"@npm//@types/node", | ||
"@npm//@angular/cli", | ||
"@npm//@angular/core", | ||
"@npm//@angular/router", | ||
"@npm//@angular/platform-browser-dynamic", | ||
"@npm//@angular-devkit/build-angular", | ||
"@npm//karma", | ||
"@npm//karma-chrome-launcher", | ||
"@npm//karma-coverage-istanbul-reporter", | ||
"@npm//karma-jasmine", | ||
"@npm//karma-jasmine-html-reporter", | ||
], | ||
tags = ["browser:chromium-local"], | ||
) | ||
|
||
# Just a dummy test so that we have a test target for //... on certain bazelci platforms with bazel_integration_test | ||
sh_test( | ||
name = "dummy_test", | ||
srcs = ["dummy_test.sh"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Angular Bazel Architect | ||
|
||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) | ||
|
||
This example showcases building and testing a project with the Angular CLI. | ||
Instead of using the Angular CLI directly we use Architect here, which is the lower level api for the Angular CLI. | ||
|
||
This requies one patch, which can be found under ./patches. | ||
This patch adjusts how the architect-cli prints stdio so that when running under Bazel you don't lose your logs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Bazel workspace created by @bazel/create 0.38.1 | ||
# Declares that this directory is the root of a Bazel workspace. | ||
# See https://docs.bazel.build/versions/master/build-ref.html#workspace | ||
workspace( | ||
# How this workspace would be referenced with absolute labels from another workspace | ||
name = "angular_cli_demo", | ||
) | ||
|
||
# Install the nodejs "bootstrap" package | ||
# This provides the basic tools for running and packaging nodejs programs in Bazel | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "build_bazel_rules_nodejs", | ||
sha256 = "3887b948779431ac443e6a64f31b9e1e17b8d386a31eebc53ec1d9b0a6cabd2b", | ||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.2.0/rules_nodejs-1.2.0.tar.gz"], | ||
) | ||
|
||
# The yarn_install rule runs yarn anytime the package.json or yarn.lock file changes. | ||
# It also extracts and installs any Bazel rules distributed in an npm package. | ||
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") | ||
|
||
yarn_install( | ||
# Name this npm so that Bazel Label references look like @npm//package | ||
name = "npm", | ||
data = ["//:patches/@angular-devkit+architect-cli+0.900.0-rc.7.patch"], | ||
package_json = "//:package.json", | ||
# Turn off symlink_node_modules here as it causes extreme flakiness on buildkite | ||
# macos CI with missing files in node_modules. | ||
# TODO: track down the root cause of the flakiness; it may be something to | ||
# do with how the Bazel team has setup their macos virtualization. | ||
symlink_node_modules = False, | ||
yarn_lock = "//:yarn.lock", | ||
) | ||
|
||
# Install any Bazel rules which were extracted earlier by the yarn_install rule. | ||
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies") | ||
|
||
install_bazel_dependencies() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"frontend": { | ||
"projectType": "application", | ||
"schematics": { | ||
"@schematics/angular:component": { | ||
"style": "scss" | ||
} | ||
}, | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"preserveSymlinks": true, | ||
"outputPath": "dist/frontend", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "tsconfig.app.json", | ||
"aot": true, | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.scss" | ||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"fileReplacements": [ | ||
{ | ||
"replace": "src/environments/environment.ts", | ||
"with": "src/environments/environment.prod.ts" | ||
} | ||
], | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"extractCss": true, | ||
"namedChunks": false, | ||
"aot": true, | ||
"extractLicenses": true, | ||
"vendorChunk": false, | ||
"buildOptimizer": true, | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "2mb", | ||
"maximumError": "5mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "6kb", | ||
"maximumError": "10kb" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"options": { | ||
"browserTarget": "frontend:build" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "frontend:build:production" | ||
} | ||
} | ||
}, | ||
"extract-i18n": { | ||
"builder": "@angular-devkit/build-angular:extract-i18n", | ||
"options": { | ||
"browserTarget": "frontend:build" | ||
} | ||
}, | ||
"test": { | ||
"builder": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"preserveSymlinks": true, | ||
"main": "src/test.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "tsconfig.spec.json", | ||
"karmaConfig": "karma.conf.js", | ||
"watch": false, | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.scss" | ||
], | ||
"scripts": [] | ||
} | ||
}, | ||
"lint": { | ||
"builder": "@angular-devkit/build-angular:tslint", | ||
"options": { | ||
"tsConfig": [ | ||
"tsconfig.app.json", | ||
"tsconfig.spec.json", | ||
"e2e/tsconfig.json" | ||
], | ||
"exclude": [ | ||
"**/node_modules/**" | ||
] | ||
} | ||
}, | ||
"e2e": { | ||
"builder": "@angular-devkit/build-angular:protractor", | ||
"options": { | ||
"protractorConfig": "e2e/protractor.conf.js", | ||
"devServerTarget": "frontend:serve" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"devServerTarget": "frontend:serve:production" | ||
} | ||
} | ||
} | ||
} | ||
}}, | ||
"defaultProject": "frontend" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. | ||
# For additional information regarding the format and rule options, please see: | ||
# https://github.com/browserslist/browserslist#queries | ||
|
||
# You can see what browsers were selected by your queries by running: | ||
# npx browserslist | ||
|
||
> 0.5% | ||
last 2 versions | ||
Firefox ESR | ||
not dead | ||
not IE 9-11 # For IE 9-11 support, remove 'not'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo "Just a dummy test so that we have a test target for //... on certain bazelci platforms with bazel_integration_test" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// @ts-check | ||
// Protractor configuration file, see link for more information | ||
// https://github.com/angular/protractor/blob/master/lib/config.ts | ||
|
||
const {SpecReporter} = require('jasmine-spec-reporter'); | ||
|
||
/** | ||
* @type { import("protractor").Config } | ||
*/ | ||
exports.config = { | ||
allScriptsTimeout: 11000, | ||
specs: ['./src/**/*.e2e-spec.ts'], | ||
capabilities: {'browserName': 'chrome'}, | ||
directConnect: true, | ||
baseUrl: 'http://localhost:4200/', | ||
framework: 'jasmine', | ||
jasmineNodeOpts: {showColors: true, defaultTimeoutInterval: 30000, print: function() {}}, | ||
onPrepare() { | ||
require('ts-node').register({project: require('path').join(__dirname, './tsconfig.json')}); | ||
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}})); | ||
} | ||
}; |
Oops, something went wrong.