Skip to content

Commit

Permalink
add test coverage and codecov action to workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ak5cel committed Nov 25, 2023
1 parent 457d9bd commit 7202e6f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Code Coverage
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

jobs:
code-cov:
runs-on: ubuntu-latest
steps:
- name: Checkout and clone repo
uses: actions/checkout@v4.1.1
- name: Install dependencies
run: npm install
- name: Setup PostgreSQL
uses: Harmon758/postgresql-action@v1.0.0
with:
postgresql db: nc_news_test
postgresql user: test_user
postgresql password: password
- name: Run complete test suite
run: PGDATABASE=nc_news_test PGUSER=test_user PGPASSWORD=password npm run test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env.*
.env.*
/coverage
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"setup-dbs": "psql -f ./db/setup.sql",
"seed": "node ./db/seeds/run-seed.js",
"test": "TZ=UTC jest",
"test": "TZ=UTC jest --coverage",
"dev": "TZ=UTC node listen.js",
"prepare": "husky install",
"start": "node listen.js",
Expand Down

0 comments on commit 7202e6f

Please sign in to comment.