Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage #17

Merged
merged 4 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: coverage

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

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v3

- uses: pnpm/action-setup@v2.2.2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: true

- name: Install dependencies
run: pnpm install --ignore-scripts

- name: Coverage
run: pnpm run test:coverage

- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

40 changes: 40 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: linter

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

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v3

- uses: pnpm/action-setup@v2.2.2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: true

- name: Install dependencies
run: pnpm install --ignore-scripts

- name: Linter
run: pnpm run format:ci
13 changes: 4 additions & 9 deletions .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: test

on:
push:
Expand All @@ -14,12 +14,12 @@ concurrency:
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
build:
strategy:
matrix:
node-version: [14, 16, 18]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2.2.2
name: Install pnpm
Expand All @@ -42,10 +42,5 @@ jobs:
- name: Install dependencies
run: pnpm install --ignore-scripts

- name: Linter
run: pnpm run format:ci

- name: Test
run: pnpm test


6 changes: 3 additions & 3 deletions lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ function getAsPrimitive(value) {
// Length check is handled inside encodeString function
return encodeString(value);
} else if (type === "bigint") {
return value + "";
return value.toString();
} else if (type === "boolean") {
return value ? "true" : "false";
} else if (type === "number" && Number.isFinite(value)) {
if (Math.abs(value) < 1e21) return value + "";
return encodeString(value + "");
if (Math.abs(value) < 1e21) return value.toString();
return encodeString(value.toString());
}

return "";
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"format:ci": "rome ci .",
"test": "vitest",
"test:watch": "vitest --watch",
"test:coverage": "vitest --coverage",
"coverage": "vitest run --coverage",
"benchmark:parse": "node benchmark/parse.mjs",
"benchmark:stringify": "node benchmark/stringify.mjs"
Expand All @@ -25,6 +26,7 @@
"@aws-sdk/querystring-builder": "^3.162.0",
"@aws-sdk/querystring-parser": "^3.162.0",
"@types/node": "^18.7.15",
"@vitest/coverage-c8": "^0.23.1",
"cronometro": "^1.1.2",
"http-querystring-stringify": "^2.1.0",
"qs": "^6.11.0",
Expand Down
Loading