Skip to content

Workflow file for this run

name: Build
on:
push:
branches: master
env:
# CodeClimate only shows coverage for the default branch
# As this action is only triggered by tags, assume the branch is 'master'
GIT_BRANCH: master
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
jobs:
setup:
name: Setup test coverage reporting
runs-on: ubuntu-latest
steps:
- name: Download CodeClimate test reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- name: Notify CodeClimate of a pending report
run: ./cc-test-reporter before-build
frontend:
name: Test and lint frontend
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version-file: .tool-versions
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint and test
run: npm test
- name: Upload test coverage artifact
uses: actions/upload-artifact@v4
with:
name: lcov.info
path: coverage/frontend/lcov.info
backend:
name: Lint and test backend
needs: setup
runs-on: ubuntu-latest
env:
RAILS_ENV: test
DATABASE_URL: postgresql://postgres@localhost
BUNDLE_WITHOUT: production
services:
postgres:
image: postgres:11.3
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install ruby and gem dependencies
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup database
run: bundle exec rake db:create db:migrate
- name: Lint
run: bundle exec rubocop
- name: Test
run: bundle exec rake
- name: Upload test coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage.json
path: coverage/backend/coverage.json
report:
name: Send coverage report to CodeClimate
needs: [frontend, backend]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download CodeClimate test reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- name: Download frontend test coverage artifact
uses: actions/download-artifact@v4
with:
name: lcov.info
path: coverage/frontend
- name: Download backend test coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage.json
path: coverage/backend
- name: Format backend coverage
run: ./cc-test-reporter format-coverage --input-type simplecov --output coverage/codeclimate.backend.json coverage/backend/coverage.json
- name: Format frontend coverage
run: ./cc-test-reporter format-coverage --input-type lcov --output coverage/codeclimate.frontend.json coverage/frontend/lcov.info
- name: Merge backend and frontend coverage
run: ./cc-test-reporter sum-coverage --parts 2 coverage/codeclimate.*.json
- name: Upload coverage report
run: ./cc-test-reporter upload-coverage