Skip to content

Commit 36b8587

Browse files
authored
Merge pull request #66 from kigster/kig/coinbase-merge
Merging select features from Coinbase upstream branch
2 parents dc4b8d7 + cc2415f commit 36b8587

31 files changed

+492
-107
lines changed

.circleci/.bazelrc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
build --verbose_failures --spawn_strategy=standalone --strategy=Genrule=standalone --show_timestamps --show_progress --show_progress_rate_limit 0.5
2-
test --spawn_strategy=standalone
1+
# Common options
32
common --color=yes
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
3+
common --show_progress
4+
common --show_progress_rate_limit=0.5
5+
6+
# Build options
7+
build --spawn_strategy=standalone
8+
build --strategy=Genrule=standalone
9+
build --show_timestamps
10+
build --curses=no
11+
build --jobs=10
12+
13+
# Test options
14+
test --spawn_strategy=standalone
15+
test --test_output=all
16+
test --test_verbose_timeout_warnings
17+
test --verbose_failures

.circleci/config.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
environment:
1010
PATH: "/usr/local/bin:/usr/bin:/sbin:/opt/bin:/home/circleci/repo/bin:/bin:/sbin:/usr/sbin"
1111
BUNDLE_PATH: /home/circleci/.bundle_cache
12-
BAZEL_OPTS: "--max_idle_secs=1 --host_jvm_args=-Xmx500m --host_jvm_args=-Xms500m"
12+
BAZEL_OPTS: "--host_jvm_args=-Xmx500m --host_jvm_args=-Xms500m"
1313
BAZEL_BUILD_OPTS: "--curses=no --verbose_failures --jobs 10"
1414
BAZEL_TEST_OPTS: "--verbose_failures --test_output=streamed --test_verbose_timeout_warnings "
1515

@@ -48,7 +48,7 @@ jobs:
4848
command: |
4949
/usr/bin/env bash bin/test-suite workspace
5050
51-
bazel_build_examples:
51+
bazel_example_script:
5252
<<: *bazel_defaults
5353

5454
steps:
@@ -65,6 +65,23 @@ jobs:
6565
command: |
6666
/usr/bin/env bash bin/test-suite simple-script
6767
68+
bazel_example_gem:
69+
<<: *bazel_defaults
70+
71+
steps:
72+
- checkout
73+
74+
- run:
75+
name: "Install ~/.bazelrc and run setup"
76+
command: |
77+
cp .circleci/.bazelrc ${HOME}
78+
/usr/bin/env bash bin/setup
79+
80+
- run:
81+
name: "Bazel Build & Test Example"
82+
command: |
83+
/usr/bin/env bash bin/test-suite example-gem
84+
6885
buildifier:
6986
<<: *bazel_defaults
7087

@@ -91,5 +108,6 @@ workflows:
91108
rules_ruby:
92109
jobs:
93110
- bazel_build_workspace
94-
- bazel_build_examples
111+
- bazel_example_gem
112+
- bazel_example_script
95113
- buildifier

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ env:
2828
- CI=true
2929
- BUNDLE_PATH="${HOME}/.bundle/gems"
3030
- PATH="${HOME}/.rbenv/bin:${HOME}/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/opt/local/bin:${PATH}"
31-
- BAZEL_OPTS="--max_idle_secs=1 --host_jvm_args=-Xmx1200m --host_jvm_args=-Xms1200m"
32-
- BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 30 --show_progress_rate_limit 0.5"
31+
- BAZEL_OPTS="--host_jvm_args=-Xmx1200m --host_jvm_args=-Xms1200m"
32+
- BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 10 --show_progress_rate_limit 0.5"
3333
- BAZEL_TEST_OPTS="--verbose_failures --test_output=streamed --test_verbose_timeout_warnings"

README.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [ruby_binary](#ruby_binary)
99
* [ruby_test](#ruby_test)
1010
* [ruby_bundle](#ruby_bundle)
11+
* [ruby_gem](#rb_gem)
1112
* [What's coming next](#whats-coming-next)
1213
* [Contributing](#contributing)
1314
* [Setup](#setup)
@@ -483,11 +484,88 @@ ruby_bundle(name, gemfile, gemfile_lock, bundler_version = "2.1.2")
483484
</tbody>
484485
</table>
485486

487+
## rb_gem
488+
Used to generate a zipped gem containing its srcs, dependencies and a gemspec.
489+
490+
<pre>
491+
rb_gem(name, gem_name, version, srcs, authors, deps, data, includes)
492+
</pre>
493+
<table class="table table-condensed table-bordered table-params">
494+
<colgroup>
495+
<col class="col-param" />
496+
<col class="param-description" />
497+
</colgroup>
498+
<thead>
499+
<tr>
500+
<th colspan="2">Attributes</th>
501+
</tr>
502+
</thead>
503+
<tbody>
504+
<tr>
505+
<td><code>name</code></td>
506+
<td>
507+
<code>Name, required</code>
508+
<p>A unique name for this rule.</p>
509+
</td>
510+
</tr>
511+
<tr>
512+
<td><code>gem_name</code></td>
513+
<td>
514+
<code>Name of the gem, required</code>
515+
<p>The name of the gem to be generated.</p>
516+
</td>
517+
</tr>
518+
<tr>
519+
<tr>
520+
<td><code>version</code></td>
521+
<td>
522+
<code>Label, required</code>
523+
<p>
524+
The version of the gem. Is used to name the output file,
525+
which becomes <code>name-version.zip</code>, and also
526+
included in the Gemspec.
527+
</p>
528+
</td>
529+
</tr>
530+
<tr>
531+
<td><code>authors</code></td>
532+
<td>
533+
<code>List of Strings, required</code>
534+
<p>
535+
List of human readable names of the gem authors.
536+
Required to generate a valid gemspec.
537+
</p>
538+
</td>
539+
</tr>
540+
<tr>
541+
<td><code>srcs</code></td>
542+
<td>
543+
<code>List of Labels, optional</code>
544+
<p>
545+
List of <code>.rb</code> files.
546+
</p>
547+
<p>At least <code>srcs</code> or <code>deps</code> must be present</p>
548+
</td>
549+
</tr>
550+
<tr>
551+
<td><code>deps</code></td>
552+
<td>
553+
<code>List of labels, optional</code>
554+
<p>
555+
List of targets that are required by the <code>srcs</code> Ruby
556+
files.
557+
</p>
558+
<p>At least <code>srcs</code> or <code>deps</code> must be present</p>
559+
</td>
560+
</tr>
561+
</tbody>
562+
</table>
563+
486564
## What's coming next
487565

488566
1. Building native extensions in gems with Bazel
489567
2. Using a specified version of Ruby.
490-
3. Building and releasing your gems with Bazel
568+
3. Releasing your gems with Bazel
491569

492570
## Contributing
493571

WORKSPACE

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ container_pull(
9191
repository = "library/ruby",
9292
)
9393

94-
load("@bazelruby_ruby_rules//ruby:defs.bzl", "bundle_install")
94+
load("@bazelruby_ruby_rules//ruby:defs.bzl", "ruby_bundle")
9595

96-
bundle_install(
96+
ruby_bundle(
9797
name = "bundle",
9898
bundler_version = "2.1.2",
9999
excludes = {
@@ -102,3 +102,7 @@ bundle_install(
102102
gemfile = "//:Gemfile",
103103
gemfile_lock = "//:Gemfile.lock",
104104
)
105+
106+
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
107+
108+
rules_pkg_dependencies()

bin/linter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ lint::all() {
104104
hr
105105
echo
106106
info "ACTION: ${bldylw}Please add any respective files to the commit and retry."
107-
retrn 1
107+
return 1
108108
else
109109
echo
110110
success "No changes detected, changes passed linter inspection."

bin/test-suite

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
2+
# vim: ft=bash
33
set -e
44

55
# shellcheck disable=SC1091
@@ -10,8 +10,8 @@ export BUNDLE_PATH="${BUNDLE_PATH:-${HOME}/.bundle/gems}"
1010
export PATH="${HOME}/.rbenv/bin:${HOME}/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/opt/local/bin"
1111

1212
export BAZEL_OPTS="--host_jvm_args=-Xmx500m --host_jvm_args=-Xms500m"
13-
export BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 15 --show_progress_rate_limit 0 "
14-
export BAZEL_TEST_OPTS="--verbose_failures --test_output=streamed --test_verbose_timeout_warnings "
13+
export BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 30 --progress_report_interval=2"
14+
export BAZEL_TEST_OPTS="--verbose_failures --test_verbose_timeout_warnings --verbose_explanations"
1515
export RUBY_VERSION=2.7.0
1616

1717
export BashMatic__Expr="
@@ -147,10 +147,17 @@ test::buildifier() {
147147
test::simple-script() {
148148
__test::exec simple-script "
149149
cd examples/simple_script
150-
${Bazel__BuildSteps}
150+
${Bazel__BuildSteps}
151151
echo run :bin; bazel ${BAZEL_OPTS} run ${BAZEL_BUILD_OPTS} :bin
152152
echo run :rubocop; bazel ${BAZEL_OPTS} run ${BAZEL_BUILD_OPTS} :rubocop
153+
"
154+
}
153155

156+
# Builds and runs workspace inside examples/simple_script
157+
test::example-gem() {
158+
__test::exec example-gem "
159+
cd examples/example_gem
160+
echo bazel ${BAZEL_OPTS} build ...:all; bazel ${BAZEL_OPTS} build ...:all
154161
"
155162
}
156163

@@ -180,9 +187,10 @@ test::all() {
180187
test::bazel-info
181188
test::workspace
182189
test::simple-script
183-
test::buildifier
190+
test::example-gem
184191
test::rubocop
185192
test::rspec
193+
test::buildifier
186194
}
187195

188196
test-suite::setup() {

examples/example_gem/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package(default_visibility = ["//:__subpackages__"])
2+
3+
load(
4+
"@bazelruby_ruby_rules//ruby:defs.bzl",
5+
"rb_gem",
6+
)
7+
8+
rb_gem(
9+
name = "default_gem",
10+
authors = ["Coinbase"],
11+
gem_name = "example_gem",
12+
version = "0.1.0",
13+
deps = [
14+
"//lib:example_gem",
15+
],
16+
)

examples/example_gem/WORKSPACE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
workspace(name = "bazelruby_ruby_rules_example_gem")
2+
3+
# Importing rules_ruby from the parent directory for developing
4+
# rules_ruby itself...
5+
local_repository(
6+
name = "bazelruby_ruby_rules",
7+
path = "../..",
8+
)
9+
10+
load(
11+
"@bazelruby_ruby_rules//ruby:deps.bzl",
12+
"ruby_register_toolchains",
13+
"ruby_rules_dependencies",
14+
)
15+
16+
ruby_rules_dependencies()
17+
18+
ruby_register_toolchains()
19+
20+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
21+
22+
bazel_skylib_workspace()

examples/example_gem/lib/BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package(default_visibility = ["//:__subpackages__"])
2+
3+
load(
4+
"@bazelruby_ruby_rules//ruby:defs.bzl",
5+
"rb_library",
6+
)
7+
8+
rb_library(
9+
name = "example_gem",
10+
srcs = ["example_gem.rb"],
11+
deps = ["//lib/foo:default_library"],
12+
)

0 commit comments

Comments
 (0)