Skip to content

Commit 8c3457b

Browse files
devversionandrewseguin
authored andcommitted
build: move lint job to circleci (#13596)
* Runs the Lint job on CircleCI within a new workflow. * Adds comment for structuring the Circle config file (the file will become even larger in the future)
1 parent be65a2b commit 8c3457b

File tree

3 files changed

+87
-34
lines changed

3 files changed

+87
-34
lines changed

.circleci/config.yml

Lines changed: 85 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Configuration file for https://circleci.com/gh/angular/material2
22

3+
#
34
# Note: YAML anchors allow an object to be re-used, reducing duplication.
45
# The ampersand declares an alias for an object, then later the `<<: *name`
56
# syntax dereferences it.
@@ -10,59 +11,111 @@
1011
var_1: &docker_image angular/ngcontainer:0.6.0
1112
var_2: &cache_key v2-ng-mat-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.6.0
1213

13-
# Define common ENV vars
14-
var_3: &define_env_vars
15-
run: echo "export PROJECT_ROOT=$(pwd)" >> $BASH_ENV
16-
17-
# See remote cache documentation in /docs/BAZEL.md
18-
var_4: &setup-bazel-remote-cache
19-
run:
20-
name: Start up bazel remote cache proxy
21-
command: ~/bazel-remote-proxy -backend circleci://
22-
background: true
23-
2414
# Settings common to each job
25-
anchor_1: &job_defaults
15+
var_3: &job_defaults
2616
working_directory: ~/ng
2717
docker:
2818
- image: *docker_image
2919

30-
# After checkout, rebase on top of master.
31-
# Similar to travis behavior, but not quite the same.
32-
# By default, PRs are not rebased on top of master, which we want.
33-
# See https://discuss.circleci.com/t/1662
34-
anchor_2: &post_checkout
35-
post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge"
20+
# Job step for checking out the source code from GitHub. This also ensures that the source code
21+
# is rebased on top of master.
22+
var_4: &checkout_code
23+
checkout:
24+
# After checkout, rebase on top of master. By default, PRs are not rebased on top of master,
25+
# which we want. See https://discuss.circleci.com/t/1662
26+
post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge"
27+
28+
# Restores the cache that could be available for the current Yarn lock file. The cache usually
29+
# includes the node modules and the Bazel repository cache.
30+
var_5: &restore_cache
31+
restore_cache:
32+
key: *cache_key
33+
34+
# Saves the cache for the current Yarn lock file. We store the node modules and the Bazel
35+
# repository cache in order to make subsequent builds faster.
36+
var_6: &save_cache
37+
save_cache:
38+
key: *cache_key
39+
paths:
40+
- "node_modules"
41+
- "~/bazel_repository_cache"
3642

43+
# Job step that ensures that the node module dependencies are installed and up-to-date. We use
44+
# Yarn with the frozen lockfile option in order to make sure that lock file and package.json are
45+
# in sync. Unlike in Travis, we don't need to manually purge the node modules if stale because
46+
# CircleCI automatically discards the cache if the checksum of the lock file has changed.
47+
var_7: &yarn_install
48+
run: yarn install --frozen-lockfile --non-interactive
49+
50+
# Copies the Bazel config which is specifically for CircleCI to a location where Bazel picks it
51+
# up and merges it with the project-wide bazel configuration (tools/bazel.rc)
52+
var_8: &copy_bazel_config
53+
# Set up the CircleCI specific bazel configuration.
54+
run: sudo cp ./.circleci/bazel.rc /etc/bazel.bazelrc
55+
56+
# -----------------------------
57+
# Container version of CircleCI
58+
# -----------------------------
3759
version: 2
60+
61+
# -----------------------------------------------------------------------------------------
62+
# Job definitions. Jobs which are defined just here, will not run automatically. Each job
63+
# must be part of a workflow definition in order to run for PRs and push builds.
64+
# -----------------------------------------------------------------------------------------
3865
jobs:
39-
build:
66+
67+
# -----------------------------------
68+
# Build and test job that uses Bazel.
69+
# -----------------------------------
70+
bazel_build_test:
4071
<<: *job_defaults
4172
resource_class: xlarge
4273
steps:
43-
- checkout:
44-
<<: *post_checkout
45-
- restore_cache:
46-
key: *cache_key
47-
# Set up the CircleCI specific bazel configuration.
48-
- run: sudo cp ./.circleci/bazel.rc /etc/bazel.bazelrc
74+
- *checkout_code
75+
- *restore_cache
76+
- *copy_bazel_config
4977

5078
# TODO(jelbourn): Update this command to run all tests if the Bazel issues have been fixed.
5179
- run: bazel build src/cdk:npm_package
5280
- run: bazel test src/{cdk,lib}/schematics:unit_tests
5381

54-
- save_cache:
55-
key: *cache_key
56-
paths:
57-
- "node_modules"
58-
- "~/bazel_repository_cache"
82+
- *save_cache
5983

84+
# ----------------------------------
85+
# Lint job. Runs the gulp lint task.
86+
# ----------------------------------
87+
lint:
88+
<<: *job_defaults
89+
steps:
90+
- *checkout_code
91+
- *restore_cache
92+
- *yarn_install
93+
94+
- run: yarn ci:lint
95+
96+
- *save_cache
97+
98+
# ----------------------------------------------------------------------------------------
99+
# Workflow definitions. A workflow usually groups multiple jobs together. This is useful if
100+
# one job depends on another.
101+
# ----------------------------------------------------------------------------------------
60102
workflows:
61103
version: 2
62-
default_workflow:
104+
105+
# Build and test workflow. A workflow includes multiple jobs that run in parallel. All jobs
106+
# that build and test source code should be part of this workflow
107+
build_and_test:
108+
jobs:
109+
- bazel_build_test
110+
111+
# Lint workflow. As we want to lint in one job, this is a workflow with just one job.
112+
lint:
63113
jobs:
64-
- build
114+
- lint
65115

116+
# ---------------------------
117+
# General setup for CircleCI
118+
# ---------------------------
66119
general:
67120
branches:
68121
only:

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ branches:
2525

2626
jobs:
2727
include:
28-
- env: "MODE=lint"
2928
- env: "MODE=aot"
3029
- env: "MODE=payload"
3130
- env: "MODE=prerender"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"webdriver-manager": "webdriver-manager",
2323
"docs": "gulp docs",
2424
"api": "gulp api-docs",
25-
"breaking-changes": "gulp breaking-changes"
25+
"breaking-changes": "gulp breaking-changes",
26+
"ci:lint": "gulp ci:lint"
2627
},
2728
"version": "7.0.0-rc.1",
2829
"requiredAngularVersion": ">=7.0.0-rc.0",

0 commit comments

Comments
 (0)