Skip to content

Commit

Permalink
upload coverage to codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaMulein committed Oct 18, 2024
1 parent b198e7d commit f2d3672
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache: 'yarn'

- run: npm ci --legacy-peer-deps
- run: yarn install --frozen-lockfile
- uses: nrwl/nx-set-shas@v4

# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/test-and-upload-codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test and Upload to Codacy

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-and-upload:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: yarn install

- name: Run tests and upload to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: yarn test:jest:upload-codacy
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
.expo
.devcontainer
.vscode
.nx

# Ignore all node_modules folders
node_modules
3 changes: 3 additions & 0 deletions generate-upload-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
nx test && bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ${SCRIPT_DIR}/coverage/dominion-assistant/lcov.info
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "nx build",
"build:clean": "yarn clean && yarn build",
"test:jest": "nx test",
"test:jest:upload-codacy": "./generate-upload-coverage.sh",
"test:jest:single": "npx nx test dominion-assistant --coverage=false --testPathPattern",
"test:playwright": "npx nx run e2e:e2e",
"test:playwright:report": "yarn playwright show-report --host 0.0.0.0 dist/.playwright/e2e/playwright-report",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ describe('restoreSavedGame', () => {

expect(result.log[0].timestamp).toBeInstanceOf(Date);

// Allow for a 5-millisecond difference tolerance due to floating point precision
// Allow for a 15-millisecond difference tolerance due to floating point precision
const restoredTime = result.log[0].timestamp.getTime();
const originalTime = saveGameTime.getTime();
expect(Math.abs(restoredTime - originalTime)).toBeLessThanOrEqual(5); // Compare with tolerance
expect(Math.abs(restoredTime - originalTime)).toBeLessThanOrEqual(15); // Compare with tolerance
});

it('should throw an error when a log entry has an invalid timestamp', () => {
Expand Down

0 comments on commit f2d3672

Please sign in to comment.