diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a6dd16664..52d1c81c9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,9 +9,15 @@ jobs: env: DEBIAN_FRONTEND: noninteractive + PARALLEL_WORKERS: 8 # number of parallel tests to run + + # 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 }} + DATABASE_URL: postgresql://danbooru:danbooru@postgres/danbooru ARCHIVE_DATABASE_URL: postgresql://danbooru:danbooru@postgres/danbooru - PARALLEL_WORKERS: 8 # number of parallel tests to run DANBOORU_SECRET_KEY_BASE: 1234 DANBOORU_AWS_SQS_ENABLED: false DANBOORU_TWITTER_API_KEY: ${{ secrets.DANBOORU_TWITTER_API_KEY }} @@ -48,12 +54,23 @@ jobs: # - name: Run tests # run: docker-compose --env-file ~/.env -f config/docker/docker-compose.test.yaml -p danbooru up - name: Install OS dependencies - run: apt-get update && apt-get -y install build-essential ruby ruby-dev ruby-bundler git nodejs yarnpkg webpack ffmpeg mkvtoolnix libvips-dev libxml2-dev postgresql-server-dev-all && ln -sf /usr/bin/yarnpkg /usr/bin/yarn + 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 postgresql-server-dev-all wget + ln -sf /usr/bin/yarnpkg /usr/bin/yarn - name: Install Ruby dependencies run: BUNDLE_DEPLOYMENT=true bundle install --jobs 4 - name: Install Javascript dependencies run: yarn install - 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 + run: ./test-reporter-latest-linux-amd64 after-build diff --git a/.gitignore b/.gitignore index 2555e75e9..8f4292733 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ config/database.yml config/danbooru_local_config.rb config/deploy/*.rb config/newrelic.yml +coverage/ node_modules/ log/ tmp/ diff --git a/.simplecov b/.simplecov index 2d7f30f4f..628307e3c 100644 --- a/.simplecov +++ b/.simplecov @@ -1,8 +1,8 @@ SimpleCov.start "rails" do add_group "Libraries", ["app/logical", "lib"] add_group "Presenters", "app/presenters" - enable_coverage :branch - minimum_coverage line: 85, branch: 75 - minimum_coverage_by_file 50 - coverage_dir "tmp/coverage" + #enable_coverage :branch + #minimum_coverage line: 85, branch: 75 + #minimum_coverage_by_file 50 + #coverage_dir "tmp/coverage" end diff --git a/Gemfile b/Gemfile index 355badd8f..ad30bc238 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,7 @@ group :test do gem "factory_bot" gem "mocha", require: "mocha/minitest" gem "ffaker" - gem "simplecov", require: false + gem "simplecov", "~> 0.17.0", require: false gem "webmock", require: "webmock/minitest" gem "minitest-ci" gem "minitest-reporters", require: "minitest/reporters" diff --git a/Gemfile.lock b/Gemfile.lock index 78ea389ba..9d09ede27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -363,10 +363,11 @@ GEM simple_form (5.0.2) actionpack (>= 5.0) activemodel (>= 5.0) - simplecov (0.18.5) + simplecov (0.17.1) docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov-html (0.12.2) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) sinatra (2.0.8.1) mustermann (~> 1.0) rack (~> 2.0) @@ -490,7 +491,7 @@ DEPENDENCIES shoulda-context shoulda-matchers simple_form - simplecov + simplecov (~> 0.17.0) sinatra stackprof streamio-ffmpeg