Skip to content

Commit c83981c

Browse files
author
Konstantin Gredeskoul
committed
Adding CircleCI + upgrade Rubocop
* Using a custom Dockerfile/image to combine ruby + jdk + go * Skipping container test on CircleCI since we are already inside a container
1 parent b1caead commit c83981c

File tree

15 files changed

+440
-138
lines changed

15 files changed

+440
-138
lines changed

.circleci/.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build --verbose_failures --spawn_strategy=standalone --strategy=Genrule=standalone
2+
test --spawn_strategy=standalone
3+
common --color=yes
4+
test --verbose_failures --test_output=errors --test_verbose_timeout_warnings

.circleci/Dockerfile

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#
2+
# rules_ruby circleci Docker file.
3+
#
4+
FROM ruby:2.6.5-stretch
5+
6+
# make Apt non-interactive
7+
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \
8+
&& echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci
9+
10+
ENV DEBIAN_FRONTEND=noninteractive
11+
12+
# Debian Jessie is EOL'd and original repos don't work.
13+
# Switch to the archive mirror until we can get people to
14+
# switch to Stretch.
15+
RUN if grep -q Debian /etc/os-release && grep -q jessie /etc/os-release; then \
16+
rm /etc/apt/sources.list \
17+
&& echo "deb http://archive.debian.org/debian/ jessie main" >> /etc/apt/sources.list \
18+
&& echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list \
19+
; fi
20+
21+
# Make sure PATH includes ~/.local/bin
22+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=839155
23+
# This only works for root. The circleci user is done near the end of this Dockerfile
24+
RUN echo 'PATH="$HOME/.local/bin:$PATH"' >> /etc/profile.d/user-local-path.sh
25+
26+
# man directory is missing in some base images
27+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199
28+
RUN apt-get update \
29+
&& mkdir -p /usr/share/man/man1 \
30+
&& apt-get install -y \
31+
git mercurial xvfb apt \
32+
locales sudo openssh-client ca-certificates tar gzip parallel \
33+
net-tools netcat unzip zip bzip2 gnupg curl wget make
34+
35+
36+
# Set timezone to UTC by default
37+
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
38+
39+
# Use unicode
40+
RUN locale-gen C.UTF-8 || true
41+
ENV LANG=C.UTF-8
42+
43+
# install jq
44+
RUN JQ_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/jq-latest" \
45+
&& curl --silent --show-error --location --fail --retry 3 --output /usr/bin/jq $JQ_URL \
46+
&& chmod +x /usr/bin/jq \
47+
&& jq --version
48+
49+
# Install Docker
50+
51+
# Docker.com returns the URL of the latest binary when you hit a directory listing
52+
# We curl this URL and `grep` the version out.
53+
# The output looks like this:
54+
55+
#> # To install, run the following commands as root:
56+
#> curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-17.05.0-ce.tgz && tar --strip-components=1 -xvzf docker-17.05.0-ce.tgz -C /usr/local/bin
57+
#>
58+
#> # Then start docker in daemon mode:
59+
#> /usr/local/bin/dockerd
60+
61+
RUN set -ex \
62+
&& export DOCKER_VERSION=$(curl --silent --fail --retry 3 https://download.docker.com/linux/static/stable/x86_64/ | grep -o -e 'docker-[.0-9]*\.tgz' | sort -r | head -n 1) \
63+
&& DOCKER_URL="https://download.docker.com/linux/static/stable/x86_64/${DOCKER_VERSION}" \
64+
&& echo Docker URL: $DOCKER_URL \
65+
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/docker.tgz "${DOCKER_URL}" \
66+
&& ls -lha /tmp/docker.tgz \
67+
&& tar -xz -C /tmp -f /tmp/docker.tgz \
68+
&& mv /tmp/docker/* /usr/bin \
69+
&& rm -rf /tmp/docker /tmp/docker.tgz \
70+
&& which docker \
71+
&& (docker version || true)
72+
73+
# docker compose
74+
RUN COMPOSE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/docker-compose-latest" \
75+
&& curl --silent --show-error --location --fail --retry 3 --output /usr/bin/docker-compose $COMPOSE_URL \
76+
&& chmod +x /usr/bin/docker-compose \
77+
&& docker-compose version
78+
79+
# install dockerize
80+
RUN DOCKERIZE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/dockerize-latest.tar.gz" \
81+
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/dockerize-linux-amd64.tar.gz $DOCKERIZE_URL \
82+
&& tar -C /usr/local/bin -xzvf /tmp/dockerize-linux-amd64.tar.gz \
83+
&& rm -rf /tmp/dockerize-linux-amd64.tar.gz \
84+
&& dockerize --version
85+
86+
RUN groupadd --gid 3434 circleci \
87+
&& useradd --uid 3434 --gid circleci --shell /bin/bash --create-home circleci \
88+
&& echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci \
89+
&& echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep
90+
91+
RUN apt-get update && apt-get upgrade
92+
93+
RUN apt-get install -y openjdk-8-jdk python2.7 python3 golang-go
94+
95+
RUN curl -L -o /usr/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.0/bazelisk-linux-amd64 \
96+
&& sudo chmod +x /usr/bin/bazel
97+
98+
USER circleci
99+
ENV PATH /home/circleci/.local/bin:/home/circleci/bin:/usr/local/bin:/usr/bin:/bin:/sbin:${PATH}
100+
101+
CMD ["/bin/sh"]

.circleci/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
docker build . -t bazelruby/ruby-2.6.5
6+
docker push bazelruby/ruby-2.6.5
7+

.circleci/config.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
version: 2.1
2+
3+
jobs:
4+
ruby_style: &bazel_defaults
5+
working_directory: /home/circleci/repo
6+
resource_class: medium
7+
docker:
8+
- image: bazelruby/ruby-2.6.5
9+
environment:
10+
PATH: "/usr/local/bin:/usr/bin:/sbin:/opt/bin:/home/circleci/repo/bin:/bin:/sbin:/usr/sbin"
11+
BUNDLE_PATH: /home/circleci/.bundle_cache
12+
BAZEL_OPTS: "--host_jvm_args=-Xmx400m --host_jvm_args=-Xms400m"
13+
BAZEL_BUILD_OPTS: "--curses=no --verbose_failures --jobs 10"
14+
BAZEL_TEST_OPTS: "--verbose_failures --test_output=streamed --test_verbose_timeout_warnings "
15+
16+
steps:
17+
- checkout
18+
- restore_cache:
19+
keys:
20+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
21+
- run:
22+
name: Install Bundler
23+
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" }}
31+
32+
- run:
33+
name: Which everything?
34+
command: |
35+
set +e
36+
bundle -v
37+
ruby --version
38+
gcc --version | head -1
39+
cc --version | head -1
40+
openssl version
41+
42+
- run:
43+
name: "Rubocop Style Check"
44+
command: bundle exec rubocop -E -P
45+
46+
bazel_rules:
47+
<<: *bazel_defaults
48+
49+
steps:
50+
- 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" }}
63+
64+
- run:
65+
name: "Install ~/.bazelrc"
66+
command: |
67+
cp .circleci/.bazelrc ${HOME}
68+
69+
- run:
70+
name: "Show Bazel Info"
71+
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 -- "//...")
76+
77+
- run:
78+
name: "Bazel Rules Build"
79+
command: |
80+
bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} -- //...
81+
82+
- run:
83+
name: "Bazel Rules Test"
84+
command: |
85+
bazel ${BAZEL_OPTS} test ${BAZEL_BUILD_OPTS} ${BAZEL_TEST_OPTS} -- //...
86+
87+
bazel_examples:
88+
<<: *bazel_defaults
89+
90+
steps:
91+
- checkout
92+
93+
- restore_cache:
94+
keys:
95+
- v1-bazel-{{ checksum ".bazelversion" }}
96+
97+
- run:
98+
name: "Custom Setup Script"
99+
command: |
100+
/usr/bin/env bash bin/setup-linux
101+
102+
- save_cache:
103+
paths:
104+
- ${BUNDLE_PATH}
105+
key: v1-bazel-{{ checksum ".bazelversion" }}
106+
107+
- run:
108+
name: "Install ~/.bazelrc"
109+
command: |
110+
cp .circleci/.bazelrc ${HOME}
111+
112+
- run:
113+
name: "Bazel Examples Build"
114+
command: |
115+
(cd examples/simple_script && bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} -- //...)
116+
117+
- run:
118+
name: "Bazel Examples Test"
119+
command: |
120+
(cd examples/simple_script && bazel ${BAZEL_OPTS} test ${BAZEL_BUILD_OPTS} ${BAZEL_TEST_OPTS} -- //...)
121+
122+
bazel_buildifier:
123+
<<: *bazel_defaults
124+
125+
steps:
126+
- checkout
127+
128+
- restore_cache:
129+
keys:
130+
- v1-bazel-{{ checksum ".bazelversion" }}
131+
132+
- run:
133+
name: "Custom Setup Script"
134+
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" }}
141+
142+
- run:
143+
name: "Install ~/.bazelrc"
144+
command: |
145+
cp .circleci/.bazelrc ${HOME}
146+
147+
- run:
148+
name: "Bazel Buildifier Check"
149+
command: |
150+
bazel ${BAZEL_OPTS} build ${BAZEL_BUILD_OPTS} :buildifier-check
151+
bazel ${BAZEL_OPTS} run ${BAZEL_BUILD_OPTS} :buildifier-check
152+
153+
workflows:
154+
rules_ruby:
155+
jobs:
156+
- ruby_style
157+
- bazel_rules
158+
- bazel_examples
159+
- bazel_buildifier

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export BAZEL_INSTALLER_DIR="${BAZEL_INSTALLER_DIR:-"${HOME}/.bazel-installer-v$(cat .bazelversion)"}"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
**/bazel-*
22
**/.idea
3-
3+
**/vendor/bundle
4+
**/.bundle
45
.DS_Store
56
**/.vscode
67

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
AllCops:
2+
TargetRubyVersion: 2.6.5
23
Exclude:
34
- bazel-*/**/*
45
- examples/**/*
6+
- "**/vendor/bundle/**/*"
57

68
inherit_gem:
79
relaxed-rubocop: .rubocop.yml

.travis.yml

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,23 @@
11
os: linux
22
dist: bionic
3-
sudo: false
3+
sudo: true
44
language: java
55
jdk: openjdk11
66

7-
#branches:
8-
# only:
9-
# - master
10-
11-
before_cache:
12-
- rm -rf $HOME/.cache/bazel/_bazel_travis/install/
13-
cache:
14-
directories:
15-
- $HOME/local
16-
- $HOME/.bazel
17-
- $HOME/.cache/bazel
18-
197
addons:
208
apt:
21-
sources:
22-
- ubuntu-toolchain-r-test
239
packages:
24-
- libstdc++6
25-
- build-essential
26-
- g++
10+
- libstdc++6
11+
- build-essential
12+
- g++
2713

28-
before_install:
29-
- bin/setup-linux 1.2.1
30-
- bazel $BAZEL_OPTS version
31-
- bazel $BAZEL_OPTS info
32-
- bazel $BAZEL_OPTS fetch --curses=no -- "//ruby/..."
33-
- (cd examples && bazel $BAZEL_OPTS fetch --curses=no -- "//...")
34-
- bundle install
35-
install:
36-
- bazel $BAZEL_OPTS build $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 -- //...
37-
- (cd examples/simple_script && bazel $BAZEL_OPTS build $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 -- //...)
3814
script:
39-
- bazel $BAZEL_OPTS test $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 --test_output=streamed -- //...
40-
- (cd examples/simple_script && bazel $BAZEL_OPTS test $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 --test_output=streamed -- //...)
41-
# If this fails run `bazel run :buildifier`
42-
- bazel run :buildifier-check
43-
# If this fails run `bundle exec rubocop -a`
44-
- bundle exec rubocop
15+
- bin/setup-linux
4516

4617
env:
4718
global:
48-
- PATH=$PATH:$HOME/local/bin
49-
- BAZEL_OPTS="--host_jvm_args=-Xmx500m --host_jvm_args=-Xms500m"
50-
- BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 20"
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 "

Gemfile

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

33
source 'https://rubygems.org'
44

5-
gem 'relaxed-rubocop'
6-
gem 'rubocop', '~> 0.76.0', require: false
5+
gem 'relaxed-rubocop', '~> 2.4'
6+
gem 'rubocop', '~> 0.77'

0 commit comments

Comments
 (0)