Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use hash of master branch for Bazel cache key #2480

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 46 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Opt-in to newer CircleCI system
# Complete documentation is at https://circleci.com/docs/2.0/
version: 2
version: 2.1

# Note: YAML anchors allow an object to be re-used, reducing duplication.
# The ampersand declares an alias for an object, then later the `<<: *name`
Expand All @@ -27,6 +27,14 @@ var_6: &docs_in_node
var_7: &docs_in_browser
docker:
- image: circleci/node:10.13-browsers
var_8: &bazel_cache_key yarn-bazel-cache-{{ checksum "master.txt" }}-0.12.9

commands:
write_master_hash:
steps:
- run: git remote add upstream git@github.com:ngrx/platform.git
- run: git fetch upstream master
- run: git log --format='%h' -n 1 upstream/master > ~/project/master.txt

jobs:
install:
Expand All @@ -43,8 +51,6 @@ jobs:
paths:
- .cache/yarn
- .cache/Cypress
- .cache/bazel_repository_cache
- .cache/bazel_disk_cache
- node_modules

# Enforce some static analysis invariants.
Expand Down Expand Up @@ -88,10 +94,11 @@ jobs:
steps:
- checkout
- *set_bazel_options

- write_master_hash
- restore_cache:
keys:
- *cache_key
- *bazel_cache_key

# Build
- run: yarn bazel build //modules/...
Expand All @@ -105,9 +112,31 @@ jobs:
paths:
- ~/.cache/yarn
- ~/.cache/Cypress
- node_modules

update-master-hash:
<<: *run_in_node
steps:
- checkout
- *set_bazel_options
- write_master_hash
- restore_cache:
keys:
- *cache_key
- *bazel_cache_key

# Build
- run: yarn bazel build //modules/...
# Store artifacts from build
- persist_to_workspace:
root: dist
paths:
- bin/*
- save_cache:
key: *bazel_cache_key
paths:
- ~/.cache/bazel_repository_cache
- ~/.cache/bazel_disk_cache
- node_modules

schematics-core-check:
<<: *run_in_browser
Expand Down Expand Up @@ -214,9 +243,11 @@ jobs:
fingerprints:
- "c9:c2:b4:5e:13:23:b6:6d:d8:29:3e:68:c6:40:9c:ec"
- checkout
- write_master_hash
- restore_cache:
keys:
- *cache_key
- *bazel_cache_key
- attach_workspace:
at: dist
- run: yarn run deploy:builds
Expand All @@ -225,9 +256,11 @@ jobs:
<<: *run_in_node
steps:
- checkout
- write_master_hash
- restore_cache:
keys:
- *cache_key
- *bazel_cache_key
- attach_workspace:
at: dist
- run:
Expand All @@ -241,9 +274,11 @@ jobs:
<<: *run_in_node
steps:
- checkout
- write_master_hash
- restore_cache:
keys:
- *cache_key
- *bazel_cache_key
- attach_workspace:
at: dist
- run:
Expand Down Expand Up @@ -315,6 +350,12 @@ workflows:
filters:
branches:
only: master
- update-master-hash:
requires:
- install
filters:
branches:
only: master
- publish-stable:
requires:
- build
Expand Down