Skip to content

Commit

Permalink
Run test coverage just on the master branch
Browse files Browse the repository at this point in the history
Since we changed the way we integrate coveralls in commit 8ed8cc8,
we're getting 6 additional checks displayed in our pull requests.

We don't need these checks, and they only add noise. The only reason we
use coveralls is to know the test coverage in our master branch.

So we're changing the code so coveralls only runs on the master branch.

There's also a chance that the test suite will be faster because it
doesn't need to keep track of the coverage, although I haven't noticed any
significant differences during my tests.

I haven't found a more elegant way to say that a certain step should
only be run on push on master, so I'm setting the environment variable
we were already using.
  • Loading branch information
javierm committed Mar 1, 2023
1 parent aaeb274 commit 9faf5dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
permissions:
contents: read

env:
TEST_COVERAGE: ${{ github.event_name == 'push' && github.ref == 'master' && 1 || '' }}

jobs:
tests:
runs-on: ubuntu-latest
Expand All @@ -23,7 +26,6 @@ jobs:
POSTGRES_USER: consul
POSTGRES_PASSWORD: ""
env:
TEST_COVERAGE: 1
PGUSER: consul
POSTGRES_HOST: postgres
RAILS_ENV: test
Expand Down Expand Up @@ -54,6 +56,7 @@ jobs:
KNAPSACK_PRO_LOG_LEVEL: info
run: bin/knapsack_pro_rspec
- name: Coveralls Parallel
if: ${{ env.TEST_COVERAGE == 1 }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -66,6 +69,7 @@ jobs:
name: screenshots
path: tmp/screenshots
coveralls:
if: ${{ env.TEST_COVERAGE == 1 }}
permissions:
contents: none
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ENV["RAILS_ENV"] ||= "test"
if ENV["TEST_COVERAGE"]
if ENV["TEST_COVERAGE"] && !ENV["TEST_COVERAGE"].empty?
require "simplecov"
require "simplecov-lcov"
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
Expand Down

0 comments on commit 9faf5dd

Please sign in to comment.