Skip to content
Merged
Show file tree
Hide file tree
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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,48 @@ jobs:
ruby-version: 3.2.8
- run: ./do_test

examples-rails:
name: Examples / Rails
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
ruby:
- 3.4.5
os:
- ubuntu-latest
- macos-latest
- windows-latest
mode:
- bzlmod
exclude:
# Previews are not available via RubyInstaller.
- os: windows-latest
ruby: 3.5.0-preview1
# TruffleRuby doesn't work on Windows.
- os: windows-latest
ruby: truffleruby-24.2.1
defaults:
run:
working-directory: examples/rails
steps:
- uses: actions/checkout@v5
- uses: bazel-contrib/setup-bazel@0.15.0
with:
# Move autoload_externally to .bazelrc once Bazel 6 support is dropped.
bazelrc: common --announce_rc --incompatible_autoload_externally=
module-root: examples/rails
# Workaround for long path issues: https://github.com/jruby/jruby/issues/3995.
output-base: ${{ matrix.os == 'windows-latest' && 'D:/b' || '' }}
repository-cache: true
- run: echo ${{ matrix.ruby }} > .ruby-version
- if: matrix.ruby == 'system'
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4.5
- run: ./do_test

release:
name: Release
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ bazel-*

# Ignore Bazel lock file.
MODULE.bazel.lock


examples/rails/people_tracker/log/**
examples/rails/people_tracker/storage/**
examples/rails/people_tracker/tmp/***

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ register_toolchains("@ruby_toolchains//:all")

- See [repository rules][3] for the documentation of `WORKSPACE` rules.
- See [rules][4] for the documentation of `BUILD` rules.
- See [rails][18] for the documentation of Ruby on Rails rules.

## Examples

Expand Down Expand Up @@ -173,3 +174,4 @@ However, some are known not to work or work only partially (e.g. mRuby has no bu
[15]: https://bazel.build/remote/rbe
[16]: https://bazel.build/reference/command-line-reference#flag--experimental_inprocess_symlink_creation
[17]: https://github.com/bazelbuild/bazel/issues/4327
[18]: docs/rails.md
5 changes: 5 additions & 0 deletions docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ stardoc_with_diff_test(
bzl_library_target = "//ruby:deps",
)

stardoc_with_diff_test(
name = "rails",
bzl_library_target = "//rails:rails_test_factory",
)

update_docs(name = "update")
67 changes: 67 additions & 0 deletions docs/rails.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions examples/rails/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Verbose Failures
build --verbose_failures

# Test output information
test --test_output=errors --test_summary=detailed

# Strict PATH. Helps prevent build cache invalidation due to PATH differences.
build --incompatible_strict_action_env=true

# Don't allow empty glob patterns by default
build --incompatible_disallow_empty_glob

# Enable bzlmod
common --enable_bzlmod

# Download the JDK to run Bazel
build --java_runtime_version=remotejdk_11
9 changes: 9 additions & 0 deletions examples/rails/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bazel_env_dir="bazel-out/bazel_env-opt/bin/bazel_env/bin"

watch_file "${bazel_env_dir}"
PATH_add "${bazel_env_dir}"

if [ ! -d "${bazel_env_dir}" ]; then
log_error "ERROR[bazel_env.bzl]: Run 'bazel run //:bazel_env' to" \
"regenerate ${bazel_env_dir}"
fi
1 change: 1 addition & 0 deletions examples/rails/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.4.5
1 change: 1 addition & 0 deletions examples/rails/.standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Config file for Standardrb
40 changes: 40 additions & 0 deletions examples/rails/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
load("@bazel_env.bzl", "bazel_env")
load("@bazel_skylib//rules:build_test.bzl", "build_test")

# MARK: - bazel_env

_RUBY_BINARIES = [
"bundle",
"bundler",
"erb",
"gem",
"irb",
"racc",
"rake",
"rbs",
"rdbg",
"rdoc",
"ri",
"ruby",
]

# This is a runnable target that is used to configure direnv to make the listed
# tools available at the command-line.
bazel_env(
name = "bazel_env",
tools = {
"buildifier": "@buildifier_prebuilt//:buildifier",
"rails": "@root_bundle//bin:rails",
} | {
rbin: "@ruby//:{}".format(rbin)
for rbin in _RUBY_BINARIES
},
visibility = ["//:__subpackages__"],
)

build_test(
name = "bazel_env_build_test",
targets = [
":bazel_env",
],
)
6 changes: 6 additions & 0 deletions examples/rails/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

source "https://rubygems.org"

# Rails for generating and running the People Tracker Rails application
gem "rails", "~> 8.0"
Loading
Loading