Skip to content

Use setup-selective action #31

Use setup-selective action

Use setup-selective action #31

Workflow file for this run

name: RSpec Suite
on: [push]
env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
RAILS_ENV: test
RACK_ENV: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15.2-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports: ['5432:5432']
# needed because the postgres container does not provide a healthcheck
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:6.2
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
strategy:
fail-fast: false
matrix:
ci_node_total: [4]
ci_node_index: [0, 1, 2, 3]
env:
SELECTIVE_API_KEY: ${{ secrets.SELECTIVE_API_KEY }}
SELECTIVE_RUNNER_ID: ${{ matrix.ci_node_index }}
steps:
- uses: actions/checkout@v4
- name: Setup Selective
uses: selectiveci/setup-selective@a74f60e
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.5'
bundler-cache: true
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Yarn Install
run: yarn install
- name: Prepare DB
run: bundle exec rails db:schema:load --trace
- name: Set ENV for CodeClimate
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
- name: Prepare for test
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: RSpec Suite Run
env:
NODE_OPTIONS: --openssl-legacy-provider
run: |
bundle exec selective rspec --format progress \
--format RspecJunitFormatter \
--out junit/rspec-$SELECTIVE_RUNNER_ID.xml
./cc-test-reporter format-coverage -t simplecov -o $GITHUB_WORKSPACE/coverage/codeclimate.$SELECTIVE_RUNNER_ID.json
- name: Upload coverage artifacts
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
- name: Upload JUnit artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: junit
path: junit
upload-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Download coverage artifacts
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage
- name: Prepare CodeClimate Reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Upload coverage to CodeClimate
run: |
./cc-test-reporter sum-coverage coverage/codeclimate.*.json
./cc-test-reporter upload-coverage