Skip to content
Closed
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
40 changes: 40 additions & 0 deletions .github/workflows/erb_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ERB Format Check

on:
pull_request:
paths:
- 'app/views/**/*.erb'

jobs:
erb_format:
runs-on: ubuntu-24.04

steps:
# Checkout the repo
- uses: actions/checkout@v2

# Install Ruby and run bundler
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true

# Gather names of all files within 'app/views/**/*.erb' that have been changed within this PR
# Store those changed files in the `FILES` ENV variable
- name: Get list of changed `app/views/**/*.erb` files
run: |
FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- 'app/views/**/*.erb')

echo "FILES<<EOF" >> $GITHUB_ENV
echo "$FILES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

# Check formatting of changed .erb files using erb-format.
# If any file is not properly formatted, this step will fail.
- name: Execute erb-format against all changed `app/views/**/*.erb` files
run: |
if [ -n "$FILES" ]; then
echo "$FILES" | xargs bundle exec erb-format --check
else
echo "No changed files within `app/views/**/*.erb`"
fi
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ group :ci, :development do
# (http://github.com/stewartmckee/bundle-audit)
gem 'bundle-audit'

# ERB formatting tool
# https://github.com/nebulab/erb-formatter
gem 'erb-formatter', require: false

# RuboCop is a Ruby code style checking and code formatting tool. It aims to enforce
# the community-driven Ruby Style Guide.
gem 'rubocop'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ GEM
dragonfly (~> 1.0)
fog-aws
drb (2.2.1)
erb-formatter (0.7.3)
syntax_tree (~> 6.0)
erubi (1.13.1)
excon (1.2.5)
logger
Expand Down Expand Up @@ -395,6 +397,7 @@ GEM
pg (1.5.9)
pp (0.6.2)
prettyprint
prettier_print (1.2.1)
prettyprint (0.2.0)
prime (0.1.3)
forwardable
Expand Down Expand Up @@ -566,6 +569,8 @@ GEM
activesupport (>= 6.1)
sprockets (>= 3.0.0)
stringio (3.1.5)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
text (1.3.1)
Expand Down Expand Up @@ -639,6 +644,7 @@ DEPENDENCIES
dotenv-rails
dragonfly
dragonfly-s3_data_store
erb-formatter
factory_bot_rails
faker
flag_shih_tzu
Expand Down
Loading