Skip to content

Update Ruby for Rails 8 integration #202

Update Ruby for Rails 8 integration

Update Ruby for Rails 8 integration #202

name: Rails integration tests
on:
pull_request:
push:
branches:
- main
jobs:
set-matrix:
runs-on: ubuntu-latest
name: Set Rails versions
outputs:
RAILS_VERSIONS: ${{ steps.compute-outputs.outputs.RAILS_VERSIONS }}
steps:
# Get latest Rails versions for 6.x.x and 7.x.x
- id: compute-outputs
name: Compute outputs
# fetches current Rails versions numbers > 5 and not 'beta'
run: |
rails_versions=$(curl https://rubygems.org/api/v1/versions/rails.json | jq '[.[] | select(.number | test("beta") | not)] | group_by(.number[:1])[] | (.[0].number) | select(.[:1]|tonumber > 5)' | jq -s -c)
echo "RAILS_VERSIONS=$rails_versions" >> $GITHUB_OUTPUT
build-rails:
strategy:
fail-fast: false
matrix:
# Build containers with the latest 6.x.x and 7.x.x Rails versions
rails: ${{ fromJSON(needs.set-matrix.outputs.RAILS_VERSIONS) }}
runs-on: ubuntu-latest
name: Build and cache Docker containers
needs: set-matrix
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and cache
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: |
RAILS_VERSION=${{ matrix.rails }}
MAIL_NOTIFY_BRANCH=${{ github.head_ref || github.ref_name }}
RUBY_VERSION=3.2.6
push: false
tags: mail-notify-integration-rails-${{ matrix.rails }}:latest
outputs: type=docker, dest=/tmp/rails-${{ matrix.rails }}-image.tar
cache-from: type=gha,scope=build-${{ matrix.rails }}
cache-to: type=gha,mode=min,scope=build-${{ matrix.rails }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rails-${{ matrix.rails }}-image
path: /tmp/rails-${{ matrix.rails }}-image.tar
mailer-previews:
strategy:
fail-fast: false
# Run against the latest 6.x.x and 7.x.x Rails versions
matrix:
rails: ${{ fromJSON(needs.set-matrix.outputs.RAILS_VERSIONS) }}
runs-on: ubuntu-latest
needs:
- set-matrix
- build-rails
steps:
- name: Download image
uses: actions/download-artifact@v4
with:
name: rails-${{ matrix.rails }}-image
path: /tmp
- name: Load image
run: docker load --input /tmp/rails-${{ matrix.rails }}-image.tar
- name: Run integration tests
env:
NOTIFY_API_KEY: ${{ secrets.NOTIFY_API_KEY }}
run: |
docker run --rm -e "NOTIFY_API_KEY=$NOTIFY_API_KEY" \
mail-notify-integration-rails-${{ matrix.rails }}:latest bin/rails test:system
sending:
strategy:
fail-fast: false
# Run against the latest 5.x.x, 6.x.x and 7.x.x Rails versions
matrix:
rails: ${{ fromJSON(needs.set-matrix.outputs.RAILS_VERSIONS) }}
runs-on: ubuntu-latest
needs:
- set-matrix
- build-rails
steps:
- name: Download image
uses: actions/download-artifact@v4
with:
name: rails-${{ matrix.rails }}-image
path: /tmp
- name: Load image
run: docker load --input /tmp/rails-${{ matrix.rails }}-image.tar
- name: Run integration tests
env:
NOTIFY_API_KEY: ${{ secrets.NOTIFY_API_KEY }}
run: |
docker run --rm -e "NOTIFY_API_KEY=$NOTIFY_API_KEY" \
mail-notify-integration-rails-${{ matrix.rails }}:latest bin/rails test
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: All integration tests
needs:
- mailer-previews
- sending
steps:
# If any of the previous actions failed, we return a non-zero exit code
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}