From 09dff5b929570c3ba8167c312f60029ba228a2fa Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 27 Jun 2020 11:52:19 -0500 Subject: [PATCH] ci: track coverage with codecov.io instead of codeclimate.com. Comparison: * Codecov has a simpler integration and a better UI. * Codeclimate tracks both linter warnings (Rubocop, ESLint) and code coverage, but its UI for code coverage is worse than Codecov's. * Codeclimate doesn't support Simplecov 0.18 because Codeclimate doesn't support 0.18's new coverage format yet. --- .codecov.yml | 1 + .github/workflows/test.yaml | 25 ++----------------------- .simplecov | 6 ++++++ Gemfile | 1 + Gemfile.lock | 6 ++++++ README.md | 2 +- 6 files changed, 17 insertions(+), 24 deletions(-) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 000000000..69cb76019 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1 @@ +comment: false diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 03a6c2d3f..3790dd084 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -34,10 +34,7 @@ jobs: RUBYOPT: -W0 # silence ruby warnings VIPS_WARNING: 0 # silence libvips warnings - # Code Climate configuration. https://docs.codeclimate.com/docs/finding-your-test-coverage-token - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - GIT_COMMIT_SHA: ${{ github.sha }} - GIT_BRANCH: ${{ github.ref }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} DATABASE_URL: postgresql://danbooru:danbooru@postgres/danbooru ARCHIVE_DATABASE_URL: postgresql://danbooru:danbooru@postgres/danbooru @@ -74,7 +71,7 @@ jobs: - name: Install OS dependencies run: | apt-get update - apt-get -y install --no-install-recommends build-essential ruby ruby-dev ruby-bundler git nodejs yarnpkg webpack ffmpeg mkvtoolnix libvips-dev libxml2-dev libxslt-dev zlib1g-dev postgresql-server-dev-all wget + apt-get -y install --no-install-recommends build-essential ruby ruby-dev ruby-bundler git nodejs yarnpkg webpack ffmpeg mkvtoolnix libvips-dev libxml2-dev libxslt-dev zlib1g-dev postgresql-server-dev-all wget curl ln -sf /usr/bin/yarnpkg /usr/bin/yarn - name: Install Ruby dependencies @@ -86,23 +83,5 @@ jobs: - name: Prepare database run: config/docker/prepare-tests.sh - # https://docs.codeclimate.com/docs/configuring-test-coverage - - name: Prepare test coverage for Code Climate - run: | - wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 - chmod +x test-reporter-latest-linux-amd64 - ./test-reporter-latest-linux-amd64 before-build - - name: Run tests run: bin/rails test - - - name: Upload test coverage to Code Climate - if: ${{ !cancelled() }} - run: GIT_COMMITTED_AT="$(date -u +%s)" ./test-reporter-latest-linux-amd64 after-build --debug - - # https://docs.codecov.io/docs - - name: Upload test coverage to Codecov.io - if: ${{ !cancelled() }} - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.simplecov b/.simplecov index 628307e3c..66536caa3 100644 --- a/.simplecov +++ b/.simplecov @@ -5,4 +5,10 @@ SimpleCov.start "rails" do #minimum_coverage line: 85, branch: 75 #minimum_coverage_by_file 50 #coverage_dir "tmp/coverage" + + # https://github.com/codecov/codecov-ruby#submit-only-in-ci-example + if ENV["CODECOV_TOKEN"] + require "codecov" + SimpleCov.formatter = SimpleCov::Formatter::Codecov + end end diff --git a/Gemfile b/Gemfile index 86bb62c2d..18bd95879 100644 --- a/Gemfile +++ b/Gemfile @@ -86,4 +86,5 @@ group :test do gem "mock_redis" gem "capybara" gem "selenium-webdriver" + gem "codecov", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 9ae511510..e7c754a04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,6 +120,10 @@ GEM xpath (~> 3.2) childprocess (3.0.0) chronic (0.10.2) + codecov (0.1.17) + json + simplecov + url coderay (1.1.3) concurrent-ruby (1.1.6) crass (1.0.6) @@ -367,6 +371,7 @@ GEM unicorn-worker-killer (0.4.4) get_process_mem (~> 0) unicorn (>= 4, < 6) + url (0.3.2) webpacker (5.1.1) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -399,6 +404,7 @@ DEPENDENCIES capistrano-rbenv capistrano3-unicorn capybara + codecov daemons delayed_job delayed_job_active_record diff --git a/README.md b/README.md index 6685ad20b..b6834fdff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Test Coverage](https://api.codeclimate.com/v1/badges/a51f46fb460a35104d82/test_coverage)](https://codeclimate.com/github/danbooru/danbooru/test_coverage) [![Discord](https://img.shields.io/discord/310432830138089472?label=Discord)](https://discord.gg/eSVKkUF) +[![codecov](https://codecov.io/gh/danbooru/danbooru/branch/master/graph/badge.svg)](https://codecov.io/gh/danbooru/danbooru) [![Discord](https://img.shields.io/discord/310432830138089472?label=Discord)](https://discord.gg/eSVKkUF) ## Installation