Skip to content

refactor: ADR-006 T3+T4 — hoist setup, consolidate assertion helpers #1312

refactor: ADR-006 T3+T4 — hoist setup, consolidate assertion helpers

refactor: ADR-006 T3+T4 — hoist setup, consolidate assertion helpers #1312

Workflow file for this run

---
name: Test
on:
push:
branches: [ master ]
paths:
- '**.gemfile'
- '**.rb'
- '.github/workflows/**'
- '.github/actions/**'
- 'Gemfile*'
- '!bin/**'
pull_request:
types: [ opened, synchronize, reopened, review_requested ]
paths:
- '**.gemfile'
- '**.rb'
- '.github/workflows/**'
- '.github/actions/**'
- 'Gemfile*'
- '!bin/**'
workflow_dispatch:
env:
BUNDLE_GEMFILE: gemfiles/rails81_gems.rb
DEBIAN_FRONTEND: noninteractive
FERRUM_PROCESS_TIMEOUT: 40
JAVA_OPTS: -Xmn2g -Xms6g -Xmx6g -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -Xss1m
-XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=256m
-XX:+UseCodeCacheFlushing
JRUBY_OPTS: --dev -J-Djruby.thread.pool.enabled=true
MALLOC_ARENA_MAX: 2
RUBY_GC_HEAP_FREE_SLOTS: 600000
RUBY_GC_HEAP_GROWTH_FACTOR: 1.1
RUBY_YJIT_ENABLE: 1
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Test that new contributors can run the tests directly after checkout.
test-minimal-setup:
name: Test with minimal setup
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-ruby-and-dependencies
with:
ruby-version: "4.0"
- run: bin/rake test
env:
SCREENSHOT_DRIVER: vips
functional-test:
name: Functional Test
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- uses: ./.github/actions/setup-ruby-and-dependencies
with:
ruby-version: "4.0"
cache-apt-packages: true
- run: bin/rake test
env:
COVERAGE: enabled
DISABLE_SKIP_TESTS: 1
SCREENSHOT_DRIVER: vips
- uses: ./.github/actions/upload-screenshots
if: failure()
id: upload-screenshots
with:
name: base-screenshots
- name: Find existing report comment
if: always() && github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Screenshot diffs'
- name: Comment PR with report link
if: failure() && github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
### Screenshot diffs detected
| Artifact | Link |
|----------|------|
| HTML report (inline preview) | ${{ steps.upload-screenshots.outputs.report-url || 'N/A' }} |
| Full report with images | ${{ steps.upload-screenshots.outputs.report-full-url || 'N/A' }} |
| [All artifacts](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts) | Browse all |
- name: Job summary with report links
if: failure()
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
### Screenshot diffs detected
| Artifact | Link |
|----------|------|
| HTML report (inline) | ${{ steps.upload-screenshots.outputs.report-url || 'N/A' }} |
| Full report with images | ${{ steps.upload-screenshots.outputs.report-full-url || 'N/A' }} |
| [All artifacts](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts) | Browse all |
EOF
- name: Update comment on success
if: success() && github.event_name == 'pull_request' && steps.find-comment.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
### Screenshot diffs resolved
All screenshots match their baselines. Previous diffs have been fixed.
- name: Uploading Coverage Report
uses: actions/upload-artifact@v7
with:
name: coverage
retention-days: 1
path: coverage
matrix:
name: Test Ruby & Rails
# Test on master, when a review is requested or manually invoked.
if: >
github.ref == 'refs/heads/master' ||
github.event_name == 'workflow_dispatch' ||
github.event.pull_request.requested_reviewers.length > 0
needs: [ functional-test ]
runs-on: ubuntu-latest
timeout-minutes: ${{ contains(matrix.ruby-version, 'jruby') && 20 || 8 }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
ruby-version: [ "4.0", "3.4", "3.3", "jruby-10.0" ]
gemfile:
- rails71_gems.rb
- rails72_gems.rb
- rails80_gems.rb
- rails81_gems.rb
experimental: [ false ]
exclude:
# We already tested last version in the functional-test job
- ruby-version: "4.0"
gemfile: rails81_gems.rb
experimental: false
include:
- ruby-version: "4.0"
gemfile: edge_gems.rb
experimental: true
- ruby-version: jruby-head
gemfile: rails81_gems.rb
experimental: true
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-ruby-and-dependencies
with:
ruby-version: ${{ matrix.ruby-version }}
ruby-cache-version: ${{ matrix.ruby-version }}-${{ matrix.gemfile }}-1
cache-apt-packages: true
- name: Run tests (with 2 retries)
uses: nick-fields/retry@v4
with:
timeout_minutes: ${{ contains(matrix.ruby-version, 'jruby') && 7 || 3 }}
max_attempts: 3
command: bin/rake test
matrix-screenshot-driver:
name: Test Drivers
if: >
github.ref == 'refs/heads/master' ||
github.event.inputs ||
github.event_name == 'workflow_dispatch' ||
github.event.pull_request.requested_reviewers.length > 0
needs: [ 'functional-test' ]
strategy:
matrix:
capybara-driver: [ selenium_headless, selenium_chrome_headless, cuprite ]
screenshot-driver: [ vips, chunky_png ]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-ruby-and-dependencies
with:
ruby-version: "4.0"
cache-apt-packages: ${{ matrix.screenshot-driver == 'vips' }}
- name: Cache Selenium
uses: actions/cache@v5
with:
path: ~/.cache/selenium
key: ${{ runner.os }}-selenium-${{ matrix.capybara-driver }}
- run: bin/rake test:integration
env:
CAPYBARA_DRIVER: ${{ matrix.capybara-driver }}
SCREENSHOT_DRIVER: ${{ matrix.screenshot-driver }}
- uses: ./.github/actions/upload-screenshots
if: failure()
with:
name: screenshots-${{ matrix.capybara-driver }}-${{ matrix.screenshot-driver }}
test-report-upload:
name: Test Report Upload
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-ruby-and-dependencies
with:
ruby-version: "4.0"
cache-apt-packages: true
- name: Generate sample report
run: bin/rake 'report:sample[embed]'
- uses: ./.github/actions/upload-screenshots
id: upload-screenshots
with:
name: test-report
- name: Job summary with report links
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<'EOF'
### SnapDiff Report
| Artifact | Link |
|----------|------|
| HTML report (inline) | ${{ steps.upload-screenshots.outputs.report-url || 'N/A' }} |
| Full report with images | ${{ steps.upload-screenshots.outputs.report-full-url || 'N/A' }} |
EOF