Skip to content

pr comment

pr comment #30

Workflow file for this run

name: CI
on: [push]
permissions:
issues: write
pull-requests: write
contents: write
env:
RAILS_ENV: test
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CI: 'true'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
jobs:
linters:
name: Linters
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run Code Analysis
run: |
bundle exec rake code:analysis
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 20
services:
db:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
# Set N number of parallel jobs you want to run tests on.
# Use higher number if you have slow tests to split them on more parallel jobs.
# Remember to update ci_node_index below to 0..N-1
ci_node_total: [1]
# set N-1 indexes for parallel jobs
# When you run 2 parallel jobs then first job will have index 0, the second job will have index 1 etc
ci_node_index: [0]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup Code Climate test-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: Setup Database
run: |
bundle exec rake parallel:load_schema
- name: Check for untracked changes in schema.rb
uses: rootstrap/check_untracked_changes@v1
with:
path: "./db/schema.rb"
- name: Get CPU info
id: cpu_info
run: |
echo "cpu_cores=$(nproc)" >> $GITHUB_ENV
- name: Run Tests
env:
KNAPSACK_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
KNAPSACK_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
PARALLEL_TESTS_CONCURRENCY: ${{ env.cpu_cores }}
run: |
bundle exec parallel_rspec -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests'
- name: Check for missing annotations
run: bundle exec annotate
- name: Check for untracked changes in app and spec directories
uses: rootstrap/check_untracked_changes@v1
with:
path: "./app/ ./spec/"
- name: Report to CodeClimate
run: |
./cc-test-reporter format-coverage --output "coverage/coverage.${{ matrix.ci_node_index }}.json"
- name: Upload partial converage
uses: actions/upload-artifact@v2
with:
name: coverage
path: "coverage/coverage.${{ matrix.ci_node_index }}.json"
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: tests
steps:
- name: Setup Code Climate 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 coverage reports
uses: actions/download-artifact@v2
with:
name: coverage
path: coverage/coverage.*.json
- name: report coverage
run: |
./cc-test-reporter sum-coverage coverage/**/*.json
./cc-test-reporter upload-coverage