Skip to content

Commit

Permalink
Clean up the main workflow file and add standardrb
Browse files Browse the repository at this point in the history
  • Loading branch information
jagthedrummer committed Nov 22, 2023
1 parent f728c53 commit 6e544b7
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 80 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/_run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This workflow runs the main test suite.
#
# This workflow is pimarily meant to be called by other workflows, but it can be run manually.
name: "🧪 ~ Run gem tests"
on:
workflow_call:
workflow_dispatch:

jobs:
test:
name: "🧪"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- "3.2"
gem:
- "bullet_train"
- "bullet_train-api"
- "bullet_train-fields"
- "bullet_train-has_uuid"
- "bullet_train-incoming_webhooks"
- "bullet_train-integrations"
- "bullet_train-integrations-stripe"
- "bullet_train-obfuscates_id"
- "bullet_train-outgoing_webhooks"
- "bullet_train-roles"
- "bullet_train-scope_questions"
- "bullet_train-scope_validator"
- "bullet_train-sortable"
- "bullet_train-super_load_and_authorize_resource"
- "bullet_train-super_scaffolding"
- "bullet_train-themes"
- "bullet_train-themes-light"
- "bullet_train-themes-tailwind_css"

name: ${{ format('{0} / {1}', matrix.gem, matrix.ruby-version) }} #'

services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-timeout 2s
--health-retries 5
ports:
- 5432:5432

env:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
RAILS_ENV: test

defaults:
run:
working-directory: ${{ matrix.gem }}

steps:
- uses: "actions/checkout@v4"

- uses: "ruby/setup-ruby@v1"
with:
rubygems: latest
bundler: latest
bundler-cache: true
ruby-version: ${{ matrix.ruby-version }}
working-directory: ${{ matrix.gem }} # setup-ruby does't pick up the job default.

# TODO: Sometimes the step above complains about the lockfile being fronzen.
# When that happens you can get things moving again by chaning the bundler-cache
# option above to false. Then _must_ uncomment the line for `bundle install` and
# you can also uncomment the following lines to find out what changed unexpectedly.
# I _think_ I've got things set up so that this shouldn't be an issue any more, but
# I'm leaving this stuff here in case it comes in handy in the near future.
#
#- run: bundle install
#- run: cat Gemfile.lock
#- run: git diff Gemfile.lock

- run: bin/rails db:setup
if: ${{ hashFiles(format('{0}/test/dummy/db/schema.rb', matrix.gem)) != '' }}

- name: Run Tests
run: bin/rails test

- name: Test Summary
uses: test-summary/action@v2
with:
paths: "test/reports/**/TEST-*.xml"
if: always()
27 changes: 27 additions & 0 deletions .github/workflows/_standardrb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will run standardrb.
#
# This workflow is pimarily meant to be called by other workflows, but it can be run manually.
name: "🔬 ~ Standardrb"
on:
workflow_call:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
BUNDLE_JOBS: 2
BUNDLE_RETRY: 3
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Run Standardrb
id: run-standardrb
run : bundle exec standardrb
88 changes: 8 additions & 80 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,11 @@ on:
branches: [ "main" ]

jobs:
test:
strategy:
fail-fast: false
matrix:
ruby-version:
- "3.2"
gem:
- "bullet_train"
- "bullet_train-api"
- "bullet_train-fields"
- "bullet_train-has_uuid"
- "bullet_train-incoming_webhooks"
- "bullet_train-integrations"
- "bullet_train-integrations-stripe"
- "bullet_train-obfuscates_id"
- "bullet_train-outgoing_webhooks"
- "bullet_train-roles"
- "bullet_train-scope_questions"
- "bullet_train-scope_validator"
- "bullet_train-sortable"
- "bullet_train-super_load_and_authorize_resource"
- "bullet_train-super_scaffolding"
- "bullet_train-themes"
- "bullet_train-themes-light"
- "bullet_train-themes-tailwind_css"

name: ${{ format('{0} / {1}', matrix.gem, matrix.ruby-version) }}
runs-on: "ubuntu-latest"

services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-timeout 2s
--health-retries 5
ports:
- 5432:5432

env:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
RAILS_ENV: test

defaults:
run:
working-directory: ${{ matrix.gem }}

steps:
- uses: "actions/checkout@v3"

- uses: "ruby/setup-ruby@v1"
with:
rubygems: latest
bundler: latest
bundler-cache: true
ruby-version: ${{ matrix.ruby-version }}
working-directory: ${{ matrix.gem }} # setup-ruby does't pick up the job default.

# TODO: Sometimes the step above complains about the lockfile being fronzen.
# When that happens you can get things moving again by chaning the bundler-cache
# option above to false. Then _must_ uncomment the line for `bundle install` and
# you can also uncomment the following lines to find out what changed unexpectedly.
# I _think_ I've got things set up so that this shouldn't be an issue any more, but
# I'm leaving this stuff here in case it comes in handy in the near future.
#
#- run: bundle install
#- run: cat Gemfile.lock
#- run: git diff Gemfile.lock

- run: bin/rails db:setup
if: ${{ hashFiles(format('{0}/test/dummy/db/schema.rb', matrix.gem)) != '' }}

- name: Run Tests
run: bin/rails test
gem_tests:
name: 🧪 Gem Tests
uses: ./.github/workflows/_run_tests.yml
secrets: inherit
standardrb:
name: 🔬 Standardrb
uses: ./.github/workflows/_standardrb.yml
secrets: inherit

0 comments on commit 6e544b7

Please sign in to comment.