Skip to content

Commit

Permalink
Config gh ci (#63)
Browse files Browse the repository at this point in the history
* Config GH actions

* Fix rubocop config

* Try to fix simplecov

* Try to fix simplecov

* Add undercover and rubycritic

* Add missing dependency

* Update simplecov

* Add rspec experiment

* Report rspec failures

* Install cmake on CircleCI

* Install cmake before bundler

* Fix rubocop

* Remove CC reporter

* Update versions

* Try another config

* Clean up
  • Loading branch information
felipefreitag authored Oct 11, 2021
1 parent 3215d97 commit f2d2c91
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 80 deletions.
15 changes: 4 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
- run:
name: install dependencies
command: |
sudo apt update
sudo apt install postgresql-client cmake
gem install bundler -v '2.1.4'
bundle install --jobs=4 --retry=3 --path vendor/bundle
sudo apt update
sudo apt install postgresql-client
sudo npm install -g [email protected]
- save_cache:
paths:
Expand All @@ -51,24 +51,17 @@ jobs:
# Database setup
- run: todos/bin/setup

# Setup coverage report
- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
# run tests!
- run:
name: Run tests
command: |
mkdir /tmp/test-results
./cc-test-reporter before-build
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress
./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
# collect reports
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
Expand Down
135 changes: 135 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: CI

on:
workflow_dispatch:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
name: Run unit tests
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST: 'localhost'
RAILS_ENV: test

runs-on: ubuntu-latest

services:
redis:
image: redis
ports: ['6379:6379']
options: --entrypoint redis-server
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 'postgres'
POSTGRES_DB: postgres
POSTGRES_HOST_AUTH_METHOD: 'trust'
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

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Install dependencies
run: |
sudo apt update
sudo apt install postgresql-client cmake
sudo npm install -g [email protected]
- name: Database setup
run: |
todos/bin/setup
- run: mkdir tmp/

- name: Run rspec
run: bundle exec rspec -f j -o tmp/rspec_results.json

- name: RSpec Report
uses: SonicGarden/rspec-report-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
json-path: tmp/rspec_results.json
if: always()

- name: Generate Undercover report
run: |
bundle exec undercover -c origin/master > tmp/undercover.txt || \
echo "Running undercover and ignoring exit status ..."
bundle exec undercover-checkstyle --compare origin/master > tmp/undercover-checkstyle.xml || \
echo "Running undercover-checkstyle and ignoring exit status ..."
- name: Archive coverage results
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage
retention-days: 10

- name: Archive undercover results
uses: actions/upload-artifact@v2
with:
name: undercover
path: tmp/undercover.txt
retention-days: 10

- name: Archive undercover-checkstyle results
uses: actions/upload-artifact@v2
with:
name: undercover-checkstyle
path: tmp/undercover-checkstyle.xml
retention-days: 10

run-linter:
name: Run linter
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: ruby/setup-ruby@v1

- name: rubocop
uses: reviewdog/action-rubocop@v2
with:
rubocop_version: gemfile
rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile
github_token: ${{ secrets.github_token }}

report-diff-coverage:
name: Report diff coverage
needs: test
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v2
with:
name: undercover-checkstyle

- uses: reviewdog/action-setup@v1

- name: Comment on PR
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cat undercover-checkstyle.xml | \
reviewdog -reporter=github-check -name="Diff coverage" -f=checkstyle
7 changes: 5 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require: rubocop-rspec

AllCops:
NewCops: disable
DisplayCopNames: true
Include:
- '**/*.rb'
Expand All @@ -18,8 +19,6 @@ AllCops:
- 'todos/bin/*'
- 'todos/node_modules/**/*'
- 'spec/rails_helper.rb'
Rails:
Enabled: true
Documentation:
Enabled: false
Metrics/BlockLength:
Expand All @@ -38,3 +37,7 @@ Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
RSpec/MultipleMemoizedHelpers:
Enabled: false
RSpec/FilePath:
Enabled: false
Loading

0 comments on commit f2d2c91

Please sign in to comment.