Skip to content

Commit

Permalink
Add rspec-specific GitHub workflow (#215)
Browse files Browse the repository at this point in the history
* Add rspec-specific GitHub workflow
  • Loading branch information
zzaakiirr authored Jul 23, 2024
1 parent c9f6adf commit 66e532b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/rspec-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ name: RSpec Shared
on:
workflow_call:
inputs:
os-version:
os_version:
required: true
type: string
ruby-version:
ruby_version:
required: true
type: string
test-tag:
required: true
test_tag:
required: false
type: string
spec_paths:
required: false
type: string

jobs:
rspec:
runs-on: ${{ inputs.os-version }}
runs-on: ${{ inputs.os_version }}
env:
RAILS_ENV: test
# We have to add "_CI" to the end, otherwise it messes with tests where we switch profiles,
Expand All @@ -28,7 +31,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.ruby-version }}
ruby-version: ${{ inputs.ruby_version }}
bundler-cache: true
- name: Install dependencies
run: bundle install
Expand All @@ -41,16 +44,16 @@ jobs:
cpln profile create default --token $CPLN_TOKEN_CI --org $CPLN_ORG
cpln image docker-login
- name: Run tests
run: bundle exec rspec --format documentation --tag ${{ inputs.test-tag }}
run: bundle exec rspec --format documentation ${{ inputs.test_tag && format('--tag {0}', inputs.test_tag) }} ${{ inputs.spec_paths }}
- name: Upload spec log
uses: actions/upload-artifact@master
if: always()
with:
name: spec-${{ inputs.test-tag }}-${{ github.run_id }}-${{ inputs.os-version }}-${{ inputs.ruby-version }}.log
name: spec-${{ inputs.test_tag }}-${{ github.run_id }}-${{ inputs.os_version }}-${{ inputs.ruby_version }}.log
path: spec.log
- name: Upload coverage results
uses: actions/upload-artifact@master
if: always()
with:
name: coverage-report-${{ inputs.test-tag }}-${{ github.run_id }}-${{ inputs.os-version }}-${{ inputs.ruby-version }}
name: coverage-report-${{ inputs.test_tag }}-${{ github.run_id }}-${{ inputs.os_version }}-${{ inputs.ruby_version }}
path: coverage
18 changes: 18 additions & 0 deletions .github/workflows/rspec-specific.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: RSpec Specific

on:
workflow_dispatch:
inputs:
spec_paths:
description: "Test files or directories that should be run"
required: true

jobs:
rspec-specific:
name: RSpec (Specific)
uses: ./.github/workflows/rspec-shared.yml
with:
os_version: ubuntu-latest
ruby_version: "3.2"
spec_paths: ${{ inputs.spec_paths }}
secrets: inherit
12 changes: 6 additions & 6 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
name: RSpec (Fast)
uses: ./.github/workflows/rspec-shared.yml
with:
os-version: ubuntu-latest
ruby-version: "3.2"
test-tag: ~slow
os_version: ubuntu-latest
ruby_version: "3.2"
test_tag: ~slow
secrets: inherit

rspec-slow:
name: RSpec (Slow)
uses: ./.github/workflows/rspec-shared.yml
if: github.event_name == 'workflow_dispatch'
with:
os-version: ubuntu-latest
ruby-version: "3.2"
test-tag: slow
os_version: ubuntu-latest
ruby_version: "3.2"
test_tag: slow
secrets: inherit

0 comments on commit 66e532b

Please sign in to comment.