Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better parallelize CI jobs #1507

Merged
merged 2 commits into from
Oct 10, 2024
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
68 changes: 28 additions & 40 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,51 @@ jobs:
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
name: screenshots-devenv
path: |
demo/tmp/screenshots
demo/tmp/capybara
- name: Archive Rails logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: rails_logs
name: rails_logs-devenv
path: demo/log

test:
name: Test
name: Test - ${{ matrix.gemfile }} - Ruby ${{ matrix.ruby }} - PG ${{ matrix.pg }}
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
ruby: ["3.0", 3.1, 3.2, 3.3]
gemfile: [rails_6.1, rails_7.0, rails_7.1, rails_7.2, rails_8.0, rails_head]
pg: [17]
include:
- ruby: 3.3
gemfile: rails_7.2
pg: 10
exclude:
# Rails 7.2 is >= 3.1
- ruby: "3.0"
gemfile: rails_7.2
# Rails 8.0 is >= 3.2
- ruby: "3.0"
gemfile: rails_8.0
- ruby: 3.1
gemfile: rails_8.0
# Rails head is >= 3.2
- ruby: "3.0"
gemfile: rails_head
- ruby: 3.1
gemfile: rails_head

env:
PGHOST: localhost
PGUSER: good_job
RAILS_ENV: test
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
Expand All @@ -125,59 +142,30 @@ jobs:
uses: actions/checkout@v4
- name: Update .ruby-version with matrix value
run: echo "${{ matrix.ruby }}" >| .ruby-version
- name: Set Rubygems version
id: rubygems
run: |
if [[ "${{ matrix.ruby }}" == "2.6" || "${{ matrix.ruby }}" == "2.7" || "${{ matrix.ruby }}" == "jruby-9.3" ]]; then
echo "version=3.3.27" >> $GITHUB_OUTPUT
else
echo "version=latest" >> $GITHUB_OUTPUT
fi
# Dependencies
- name: Remove Gemfile.lock
run: rm Gemfile.lock
- name: Set up generic Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false
- name: Recreate Gemfile.lock
run: bundle lock --update && cat Gemfile.lock
- name: Set up Ruby and bundle install
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: ${{ steps.rubygems.outputs.version }}
- name: Generate Appraisal Gemfile.lock files
run: |
bundle exec appraisal bundle lock --update
- name: Cache Appraisal gems
uses: actions/cache@v4
with:
path: gemfiles/vendor/bundle
key: v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock', 'gemfiles/*.gemfile.lock') }}
restore-keys: |
v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-
- name: Install Appraisal gems
run: bundle exec appraisal install
rubygems: latest

# Test
- name: Set up test database
run: bundle exec appraisal demo/bin/rails db:test:prepare
run: bundle exec demo/bin/rails db:test:prepare
- name: Run Unit tests
run: |
bundle exec appraisal rspec --exclude-pattern "spec/system/**/*_spec.rb, spec/generators/**/*_spec.rb" \
bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb, spec/generators/**/*_spec.rb" \
--require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter
- name: Run System tests
if: ${{ !contains(matrix.ruby, 'jruby') }}
run: |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \
bundle exec rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
spec/system

- name: Run Generators tests
run: |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \
bundle exec rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
spec/generators

Expand All @@ -186,13 +174,13 @@ jobs:
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
name: screenshots-${{ matrix.gemfile }}-${{ matrix.ruby }}-${{ matrix.pg }}
path: |
demo/tmp/screenshots
demo/tmp/capybara
- name: Archive Rails logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: rails_logs
name: rails_logs-${{ matrix.gemfile }}-${{ matrix.ruby }}-${{ matrix.pg }}
path: demo/log
46 changes: 0 additions & 46 deletions Appraisals

This file was deleted.

17 changes: 10 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,25 @@ gemspec
# your gem to rubygems.org.

gem 'activerecord-jdbcpostgresql-adapter', platforms: [:jruby]
gem 'appraisal'
gem 'matrix'
gem 'nokogiri'
gem 'pg', platforms: [:mri, :mingw, :x64_mingw]
gem 'rack', '~> 2.2'
gem 'rails'

rails_versions = {
"6.1" => { github: "rails/rails", branch: "6-1-stable" }, # https://github.com/bensheldon/good_job/issues/1280
"7.0" => "~> 7.0.1", # Ruby 3.1 requires Rails 7.0.1+
"7.1" => "~> 7.1.0",
"7.2" => "~> 7.2.0",
"8.0" => "~> 8.0.0.a",
"head" => { github: "rails/rails", branch: "main" },
}
gem 'rails', rails_versions[ENV.fetch("RAILS_VERSION", nil)]

platforms :ruby do
gem "bootsnap"
gem "dotenv-rails"
gem "foreman"
gem "gem-release"
gem "github_changelog_generator", require: false
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false

group :debug do
gem "activerecord-explain-analyze", require: false
Expand Down
10 changes: 0 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
ast (2.4.2)
async (2.14.2)
console (~> 1.25, >= 1.25.2)
Expand Down Expand Up @@ -505,7 +501,6 @@ PLATFORMS
DEPENDENCIES
activerecord-explain-analyze
activerecord-jdbcpostgresql-adapter
appraisal
benchmark-ips
bootsnap
brakeman
Expand All @@ -521,13 +516,8 @@ DEPENDENCIES
i18n-tasks
kramdown
kramdown-parser-gfm
matrix
mdl
memory_profiler
net-imap
net-pop
net-smtp
nokogiri
pg
puma
rack (~> 2.2)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1715,14 +1715,14 @@ Environment variables that may help with debugging:
- `LOUD=1`: display all stdout/stderr output from all sources. This is helpful because GoodJob wraps some tests with `quiet { }` for cleaner test output, but it can hinder debugging.
- `SHOW_BROWSER=1`: Run system tests headfully with Chrome/Chromedriver. Use `binding.irb` in the system tests to pause.

Appraisal can be used to run a test matrix of multiple versions of Rails:
The gemfiles in `gemfiles/` can be used to run tests against different rails versions:

```bash
# Install Appraisal matrix of gemfiles
bin/appraisal
# Install dependencies
BUNDLE_GEMFILE=gemfiles/rails_6.1.gemfile bundle install

# Run tests against matrix
bin/appraisal bin/rspec
# Run the tests
BUNDLE_GEMFILE=gemfiles/rails_6.1.gemfile bin/rspec
```

### Release
Expand Down
3 changes: 0 additions & 3 deletions bin/appraisal

This file was deleted.

109 changes: 0 additions & 109 deletions gemfiles/bin/bundle

This file was deleted.

Loading