Skip to content

Commit

Permalink
chore: improve coverage and good practices for tests (#2472)
Browse files Browse the repository at this point in the history
* ci: revisit every CI

* ci: review Bun CI

* ci: remove old version from Bun

* ci: move Bun tests to Linux CI

* ci: improve MySQL CI name

* ci: fix coverage CI

* ci: refactor tests

* chore: fix common import on tools

* ci: fix CI errors

* ci: fix promise regression CI

* ci: use `test:bun` to test Bun

* ci: use best practices for type check tests

* ci: change from builtin-runner to esm

* ci: ensure ".test." extesions in test files

* ci: add lint rules for Tests and Typings
  • Loading branch information
wellwelwel authored Mar 6, 2024
1 parent 68cc335 commit 7ae15a5
Show file tree
Hide file tree
Showing 237 changed files with 2,667 additions and 2,396 deletions.
13 changes: 12 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"consistent-this": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"arrow-parens": ["error", "as-needed"],
"arrow-body-style": ["error", "as-needed"],
"no-var": "error",
"no-use-before-define": "error",
Expand Down Expand Up @@ -70,6 +69,18 @@
"parserOptions": {
"sourceType": "module"
}
},
{
"files": ["**/**/*.test.*"],
"rules": {
"arrow-parens": ["error", "always"]
}
},
{
"files": ["**/*.mjs"],
"parserOptions": {
"sourceType": "module"
}
}
]
}
18 changes: 9 additions & 9 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: [20.x]
mysql-version: ["mysql:8.0.18"]
use-compression: [0]
use-tls: [0]

name: Performance regression check

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# - name: Set up MySQL
# run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_ROOT_PASSWORD=${{ env.MYSQL_PASSWORD }} -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/test/fixtures/custom-conf:/etc/mysql/conf.d -v $PWD/test/fixtures/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }}
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
key: npm-linux-${{ hashFiles('package-lock.json') }}
restore-keys: npm-linux-

- name: Install npm dependencies
run: npm ci

Expand All @@ -68,4 +68,4 @@ jobs:
alert-threshold: '150%'
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-on-alert: true
alert-comment-cc-users: '@sidorares'
alert-comment-cc-users: '@sidorares'
80 changes: 0 additions & 80 deletions .github/workflows/ci-bun.yml

This file was deleted.

86 changes: 86 additions & 0 deletions .github/workflows/ci-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: CI - Coverage

on:
pull_request:
push:
branches: [ main ]

workflow_dispatch:

env:
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_DATABASE: test

jobs:
coverage:
permissions: write-all
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20.x]
mysql-version: ["mysql:8.0.33"]
use-compression: [0]
use-tls: [0]
mysql_connection_url_key: [""]
env:
MYSQL_CONNECTION_URL: ${{ secrets[matrix.mysql_connection_url_key] }}

name: Coverage ${{ matrix.node-version }} - DB ${{ matrix.mysql-version }}${{ matrix.mysql_connection_url_key }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}}

steps:
- uses: actions/checkout@v4

- name: Delete artifacts
uses: jimschubert/delete-artifacts-action@v1
with:
log_level: 'debug'
min_bytes: '0'
pattern: '\.xml'

- name: Set up MySQL
if: ${{ matrix.mysql-version }}
run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/test/fixtures/custom-conf:/etc/mysql/conf.d -v $PWD/test/fixtures/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }}

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-linux-${{ hashFiles('package-lock.json') }}
restore-keys: npm-linux-

- name: Install npm dependencies
run: npm ci

- name: Wait mysql server is ready
if: ${{ matrix.mysql-version }}
run: node tools/wait-up.js

- name: Run tests
run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm run coverage-test

- name: get list of coverage files
run: echo "coverage-files=`find coverage | grep xml | paste -s -d\; -`" >> $GITHUB_ENV

- name: ReportGenerator
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.2
with:
reports: "${{ env.coverage-files }}"
targetdir: '.'
reporttypes: 'Cobertura'

- name: Debug
run: cat Cobertura.xml

- name: Display coverage
uses: ewjoachim/coverage-comment-action@v1
continue-on-error: true
with:
COVERAGE_FILE: "Cobertura.xml"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 7ae15a5

Please sign in to comment.