Skip to content

Commit

Permalink
Merge pull request #1756 from unboxed/simplify-workflow-linters
Browse files Browse the repository at this point in the history
Use a matrix test for linters to reduce boilerplate
  • Loading branch information
benjamineskola authored Apr 29, 2024
2 parents ce1082a + 455fcc8 commit cec842a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 111 deletions.
51 changes: 31 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,41 @@ concurrency:
cancel-in-progress: true

jobs:
brakeman:
uses: ./.github/workflows/linters.yml
with:
brakeman: true
linters:
name: Linters
runs-on: ubuntu-latest
strategy:
matrix:
task:
- brakeman
- rubocop
- biome
- erblint
- language_versions
fail-fast: false
env:
BUNDLE_WITHOUT: development
PUPPETEER_SKIP_DOWNLOAD: true
RAILS_ENV: test

rubocop:
uses: ./.github/workflows/linters.yml
with:
rubocop: true
steps:
- name: Check out code
uses: actions/checkout@v4

biome:
uses: ./.github/workflows/linters.yml
with:
biome: true
- name: Set up Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

erblint:
uses: ./.github/workflows/linters.yml
with:
erblint: true
- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
- run: yarn install

language-versions:
uses: ./.github/workflows/linters.yml
with:
language-versions: true
- name: Lint with ${{ matrix.task }}
run: |
bundle exec rake ${{ matrix.task }}
specs:
uses: ./.github/workflows/testing.yml
Expand Down
91 changes: 0 additions & 91 deletions .github/workflows/linters.yml

This file was deleted.

22 changes: 22 additions & 0 deletions bin/verify-language-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
set -e

NODE_VERSION=$(cat .node-version)
if ! grep -q "^ARG NODE_VERSION=$NODE_VERSION" docker/ruby/Dockerfile; then
echo "Dockerfile has wrong node: $(grep '^ARG NODE_MAJOR' docker/ruby/Dockerfile)" >&2
exit 1
fi
if ! grep -q "^ARG NODE_VERSION=$NODE_VERSION" Dockerfile.production; then
echo "Dockerfile.production has wrong node: $(grep '^ARG NODE_MAJOR' Dockerfile.production)" >&2
exit 1
fi

RUBY_VERSION=$(cat .ruby-version)
if ! grep -q "^ARG RUBY_VERSION=$RUBY_VERSION" docker/ruby/Dockerfile; then
echo "Dockerfile has wrong ruby: $(grep '^FROM ruby:' docker/ruby/Dockerfile)" >&2
exit 1
fi
if ! grep -q "^ARG RUBY_VERSION=$RUBY_VERSION" Dockerfile.production; then
echo "Dockerfile.production has wrong ruby: $(grep '^ARG RUBY_VERSION' Dockerfile.production)" >&2
exit 1
fi
6 changes: 6 additions & 0 deletions lib/tasks/language-versions.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

desc "Ensure language versions match"
task language_versions: :environment do
exit 1 unless system "bin/verify-language-versions.sh"
end

0 comments on commit cec842a

Please sign in to comment.