diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..932beff --- /dev/null +++ b/.github/workflows/codecov.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index cfa8718..b8d9617 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -.env.* \ No newline at end of file +.env.* +/coverage \ No newline at end of file diff --git a/package.json b/package.json index 4613dad..fe33fa5 100644 --- a/package.json +++ b/package.json @@ -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",