Skip to content

Commit

Permalink
Migrate to GitHub Actions CI, fix test builds on main (#66)
Browse files Browse the repository at this point in the history
Two issues being resolved here:

- Test builds have started failing on `main` (due to Gems being
installed that are incompatible with Ruby 2.7.7), see note from Patrick
below on resolution
- Migrating away from Circle CI and on to GitHub Actions (now our
preferred CI platform)
  • Loading branch information
grega authored Jan 17, 2024
2 parents 2b3011b + 1ce8fb8 commit 67c03ec
Show file tree
Hide file tree
Showing 12 changed files with 946 additions and 503 deletions.
48 changes: 0 additions & 48 deletions .circleci/config.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
if: github.ref_type == 'branch' && github.ref_name != 'main'
uses: ./.github/workflows/test.yml
# code_quality:
# if: github.ref_type == 'branch' && github.ref_name != 'main'
# uses: ./.github/workflows/code_quality.yml
66 changes: 66 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Test
on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: ['2.7', '3.1', '3.2']
gemfile: [ rails_6.1, rails_7.0, rails_7.1 ]
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rspec

- name: Archive coverage
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: code-coverage-report-ruby_${{ matrix.ruby-version }}-${{ matrix.gemfile }}
path: ${{ github.workspace }}/coverage/

post_coverage:
runs-on: ubuntu-latest
needs: test
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v3
with:
name: code-coverage-report-ruby_3.2-rails_7.1
path: coverage/

- name: Install JQ
run: sudo apt-get install -y jq

- name: Determine coverage
id: coverage
run: |
# Check to see if coverage is under `result.line` or under `result.covered_percent` (older versions)
coverage=$(jq -r 'if .result.line then .result.line else .result.covered_percent end' < coverage/.last_run.json)
[ "${coverage}" = "null" ] && coverage="** Failed to determine coverage **"
echo value="${coverage}" >> "$GITHUB_OUTPUT"
- uses: mshick/add-pr-comment@v2
with:
message: |
* GitHub Actions [run \#${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
Test coverage: ${{ steps.coverage.outputs.value }}%
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 3.1.3
ruby 2.7.8
Loading

0 comments on commit 67c03ec

Please sign in to comment.