Skip to content

Commit a0d21e5

Browse files
authored
Merge pull request #46 from bazelruby/kig/speed-up-ci
Speed up CircleCI/Travis ensure *correctness* with builds
2 parents 6edcf32 + 0e242a0 commit a0d21e5

File tree

20 files changed

+429
-299
lines changed

20 files changed

+429
-299
lines changed

.circleci/.bazelrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
build --verbose_failures --spawn_strategy=standalone --strategy=Genrule=standalone
1+
build --verbose_failures --spawn_strategy=standalone --strategy=Genrule=standalone --show_timestamps --show_progress --show_progress_rate_limit 0.5
22
test --spawn_strategy=standalone
33
common --color=yes
4-
test --verbose_failures --test_output=errors --test_verbose_timeout_warnings
4+
startup --max_idle_secs=1
5+
test --verbose_failures --test_output=errors --test_verbose_timeout_warnings --show_progress --show_progress_rate_limit 0.5
6+
run --verbose_failures --show_progress --show_progress_rate_limit 0.5

.circleci/config.yml

Lines changed: 35 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
jobs:
4-
ruby_style: &bazel_defaults
4+
rubocop: &bazel_defaults
55
working_directory: /home/circleci/repo
66
resource_class: medium
77
docker:
@@ -15,145 +15,98 @@ jobs:
1515

1616
steps:
1717
- checkout
18-
- restore_cache:
19-
keys:
20-
- v1-dependencies-{{ checksum "Gemfile.lock" }}
18+
2119
- run:
22-
name: Install Bundler
20+
name: "Install ~/.bazelrc and run setup"
2321
command: |
24-
gem install bundler:2.0.2 --no-doc
25-
bundle install --jobs=4 --retry=3 --path ${BUNDLE_PATH}
26-
27-
- save_cache:
28-
paths:
29-
- ${BUNDLE_PATH}
30-
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
22+
cp .circleci/.bazelrc ${HOME}
23+
/usr/bin/env bash bin/setup
3124
3225
- run:
33-
name: Which everything?
26+
name: Install Bundler
3427
command: |
35-
set +e
36-
bundle -v
37-
ruby --version
38-
gcc --version | head -1
39-
cc --version | head -1
40-
openssl version
28+
gem install bundler:2.0.2 --no-doc
29+
bundle install --jobs=4 --retry=3 --path ${BUNDLE_PATH}
4130
4231
- run:
4332
name: "Rubocop Style Check"
4433
command: bundle exec rubocop -E -P
4534

46-
bazel_rules:
35+
bazel_build_workspace:
4736
<<: *bazel_defaults
4837

4938
steps:
5039
- checkout
51-
- restore_cache:
52-
keys:
53-
- v1-bazel-{{ checksum ".bazelversion" }}
54-
- run:
55-
name: "Custom Setup Script"
56-
command: |
57-
/usr/bin/env bash bin/setup-linux
58-
59-
- save_cache:
60-
paths:
61-
- ${BUNDLE_PATH}
62-
key: v1-bazel-{{ checksum ".bazelversion" }}
6340

6441
- run:
65-
name: "Install ~/.bazelrc"
42+
name: "Install ~/.bazelrc and run setup"
6643
command: |
6744
cp .circleci/.bazelrc ${HOME}
45+
/usr/bin/env bash bin/setup
6846
6947
- run:
7048
name: "Show Bazel Info"
7149
command: |
72-
bazel $BAZEL_OPTS version
73-
bazel $BAZEL_OPTS info
74-
bazel $BAZEL_OPTS fetch --curses=no -- "//ruby/..."
75-
(cd examples && bazel $BAZEL_OPTS fetch --curses=no -- "//...")
50+
51+
/usr/bin/env bash bin/ci bazel-info
7652
7753
- run:
78-
name: "Bazel Rules Build"
54+
name: "Bazel Build & Test Workspace"
7955
command: |
80-
bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} -- //...
56+
/usr/bin/env bash bin/ci workspace
8157
82-
- run:
83-
name: "Bazel Rules Test"
84-
command: |
85-
bazel ${BAZEL_OPTS} test ${BAZEL_BUILD_OPTS} ${BAZEL_TEST_OPTS} -- //...
86-
87-
bazel_examples:
58+
bazel_build_examples:
8859
<<: *bazel_defaults
8960

9061
steps:
9162
- checkout
9263

93-
- restore_cache:
94-
keys:
95-
- v1-bazel-{{ checksum ".bazelversion" }}
96-
9764
- run:
98-
name: "Custom Setup Script"
65+
name: "Install ~/.bazelrc and run setup"
9966
command: |
100-
/usr/bin/env bash bin/setup-linux
101-
102-
- save_cache:
103-
paths:
104-
- ${BUNDLE_PATH}
105-
key: v1-bazel-{{ checksum ".bazelversion" }}
67+
cp .circleci/.bazelrc ${HOME}
68+
/usr/bin/env bash bin/setup
10669
10770
- run:
108-
name: "Install ~/.bazelrc"
71+
name: "Bazel Simple Script Example Build"
10972
command: |
110-
cp .circleci/.bazelrc ${HOME}
73+
cd examples/simple_script && bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} -- //...
11174
11275
- run:
113-
name: "Bazel Examples Build"
76+
name: "Bazel Simple Script Example Test"
11477
command: |
115-
(cd examples/simple_script && bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} -- //...)
78+
cd examples/simple_script && bazel ${BAZEL_OPTS} test ${BAZEL_BUILD_OPTS} ${BAZEL_TEST_OPTS} -- //...
11679
11780
- run:
118-
name: "Bazel Examples Test"
81+
name: "Bazel Simple Script Example Rubocop Check"
11982
command: |
120-
(cd examples/simple_script && bazel ${BAZEL_OPTS} test ${BAZEL_BUILD_OPTS} ${BAZEL_TEST_OPTS} -- //...)
83+
cd examples/simple_script && bazel ${BAZEL_OPTS} run ${BAZEL_BUILD_OPTS} -- :rubocop
12184
122-
bazel_buildifier:
85+
buildifier:
12386
<<: *bazel_defaults
12487

12588
steps:
12689
- checkout
12790

128-
- restore_cache:
129-
keys:
130-
- v1-bazel-{{ checksum ".bazelversion" }}
131-
13291
- run:
133-
name: "Custom Setup Script"
92+
name: "Install ~/.bazelrc and run setup"
13493
command: |
135-
/usr/bin/env bash bin/setup-linux
136-
137-
- save_cache:
138-
paths:
139-
- ${BAZEL_INSTALLER_DIR}
140-
key: v1-bazel-{{ checksum ".bazelversion" }}
94+
cp .circleci/.bazelrc ${HOME}
95+
/usr/bin/env bash bin/setup
14196
14297
- run:
143-
name: "Install ~/.bazelrc"
98+
name: "Bazel Buildifier Build"
14499
command: |
145-
cp .circleci/.bazelrc ${HOME}
100+
bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} :buildifier-check
146101
147102
- run:
148-
name: "Bazel Buildifier Check"
103+
name: "Bazel Buildifier Run"
149104
command: |
150-
bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} :buildifier-check
151105
bazel ${BAZEL_OPTS} run ${BAZEL_BUILD_OPTS} :buildifier-check
152106
153107
workflows:
154108
rules_ruby:
155109
jobs:
156-
- ruby_style
157-
- bazel_rules
158-
- bazel_examples
159-
- bazel_buildifier
110+
- bazel_build_workspace
111+
- bazel_build_examples
112+
- buildifier

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export BAZEL_INSTALLER_DIR="${BAZEL_INSTALLER_DIR:-"${HOME}/.bazel-installer-v$(cat .bazelversion)"}"
1+
# Sets environment for external programs
2+
export BUNDLE_PATH="${HOME}/.bundle/gems"

.envrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22

33
PATH_add bin
44

5-
source bin/deps
6-

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
**/bazel-*
22
**/.idea
3-
**/vendor/bundle
43
**/.bundle
5-
.DS_Store
4+
**/vendor/bundle/**
5+
**/.DS_Store
66
**/.vscode
7-

.rubocop.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
AllCops:
22
TargetRubyVersion: 2.6.5
33
Exclude:
4-
- bazel-*/**/*
5-
- examples/**/*
4+
- "**/rubocop"
5+
- "examples/**/*"
6+
- "bazel-*/**/*"
7+
- "**/external/**/*"
68
- "**/vendor/bundle/**/*"
79

810
inherit_gem:

.travis.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ sudo: true
44
language: java
55
jdk: openjdk11
66

7+
cache:
8+
directories:
9+
${HOME}/.rbenv
10+
${HOME}/.bundle/gems
11+
#${HOME}/.cache/bazel/_bazel_${USER}
12+
713
addons:
814
apt:
915
packages:
@@ -12,12 +18,17 @@ addons:
1218
- g++
1319

1420
script:
15-
- bin/setup-linux
21+
- /usr/bin/env bash bin/setup
22+
- /usr/bin/env bash bin/ci
23+
24+
after_script:
25+
- /usr/bin/env bash bin/show-env
1626

1727
env:
1828
global:
19-
- BUNDLE_PATH=vendor/bundle
20-
- PATH="~/.rbenv/bin:~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/opt/local/bin"
21-
- BAZEL_OPTS="--host_jvm_args=-Xmx500m --host_jvm_args=-Xms500m"
22-
- BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 20 --show_progress_rate_limit 0 "
23-
- BAZEL_TEST_OPTS="--verbose_failures --test_output=streamed --test_verbose_timeout_warnings "
29+
- CI=true
30+
- BUNDLE_PATH="${HOME}/.bundle/gems"
31+
- PATH="${HOME}/.rbenv/bin:${HOME}/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/opt/local/bin:${PATH}"
32+
- BAZEL_OPTS="--host_jvm_args=-Xmx700m --host_jvm_args=-Xms700m"
33+
- BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 20 --show_progress_rate_limit 0.5"
34+
- BAZEL_TEST_OPTS="--verbose_failures --test_output=streamed --test_verbose_timeout_warnings"

BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ buildifier(
66
name = "buildifier-check",
77
mode = "check",
88
)
9+
10+
buildifier(
11+
name = "buildifier-fix",
12+
mode = "fix",
13+
)

WORKSPACE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,15 @@ container_pull(
9090
registry = "docker.io",
9191
repository = "library/ruby",
9292
)
93+
94+
load("@bazelruby_ruby_rules//ruby:defs.bzl", "bundle_install")
95+
96+
bundle_install(
97+
name = "bundle",
98+
excludes = {
99+
"mini_portile": ["test/**/*"],
100+
},
101+
gemfile = "//:Gemfile",
102+
gemfile_lock = "//:Gemfile.lock",
103+
version = "2.0.2",
104+
)

0 commit comments

Comments
 (0)