Skip to content

Commit

Permalink
Parallel CI (#4060)
Browse files Browse the repository at this point in the history
* Extract rubygems.org CI setup into reusable custom action.

* Run system tests in parallel.

* Add collecting rails tests passing simple job.
  • Loading branch information
simi authored Sep 9, 2023
1 parent bd98ad4 commit 9f19e00
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 24 deletions.
40 changes: 40 additions & 0 deletions .github/actions/setup-rubygems.org/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Setup rubygems.org'
description: 'Setup steps for rubygems.org'
inputs:
ruby-version:
description: 'Ruby version to use'
required: true
rubygems-version:
description: 'RubyGems version to use'
required: true
runs:
using: "composite"
steps:
- name: Install and start services
shell: bash
run: |
docker-compose up -d
- name: Wait for ES to boot
shell: bash
run: |
timeout 300 bash -c "until curl --silent --output /dev/null http://localhost:9200/_cat/health?h=st; do printf '.'; sleep 5; done; printf '\n'"
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.149.0
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true
- name: set rubygems version
shell: bash
run: |
if [ "${{ inputs.rubygems-version }}" != "latest" ]; then
gem update --system ${{ inputs.rubygems-version }};
else
gem update --system
fi
gem --version
bundle --version
- name: Prepare environment
shell: bash
run: |
cp config/database.yml.sample config/database.yml
bundle exec rake db:setup
50 changes: 26 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ permissions:
contents: read

jobs:
# This is umbrella job for all tests needed to pass to make it simpler
# to maintain GitHub Actions status required checks since job names and
# amount change over the time and it is easier to maintian having just
# this umbrella check set as required.
status_check:
name: All required tests passing check
needs: [rails]
runs-on: ubuntu-22.04
steps:
- run: echo "All required tests passed!"

rails:
strategy:
fail-fast: false
Expand All @@ -18,47 +29,38 @@ jobs:
- name: latest
version: latest
ruby_version: ["3.2.2"]
name: Rails tests (RubyGems ${{ matrix.rubygems.name }})
tests:
- name: general
command: test
- name: system
command: test:system
name: Rails tests ${{ matrix.tests.name }} (RubyGems ${{ matrix.rubygems.name }})
runs-on: ubuntu-22.04
env:
RUBYGEMS_VERSION: ${{ matrix.rubygems.version }}
# Fail hard when Toxiproxy is not running to ensure all tests (even Toxiproxy optional ones) are passing
REQUIRE_TOXIPROXY: true
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Install and start services
run: |
docker-compose up -d
- name: Wait for ES to boot
run: |
timeout 300 bash -c "until curl --silent --output /dev/null http://localhost:9200/_cat/health?h=st; do printf '.'; sleep 5; done; printf '\n'"
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.149.0

- name: Setup rubygems.org
uses: ./.github/actions/setup-rubygems.org
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: set rubygems version
run: |
if [ "$RUBYGEMS_VERSION" != "latest" ]; then
gem update --system $RUBYGEMS_VERSION;
else
gem update --system
fi
gem --version
bundle --version
- name: Prepare environment
run: |
cp config/database.yml.sample config/database.yml
bundle exec rake db:setup
- name: Tests
rubygems-version: ${{ matrix.rubygems.version }}

- name: Tests ${{ matrix.tests.name }}
id: test-all
run: bin/rails test:all
run: bin/rails ${{ matrix.tests.command }}

- name: Save capybara screenshots
if: steps.test-all.outcome == 'failure'
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: capybara-screenshots
path: tmp/capybara
if-no-files-found: ignore

- name: Upload coverage to Codecov
if: matrix.rubygems.name == 'locked' && (success() || failure())
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4

0 comments on commit 9f19e00

Please sign in to comment.