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

test: setup testing #11

Merged
merged 1 commit into from
Feb 27, 2024
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
11 changes: 9 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,21 @@ module.exports = {
*/
// Overrides
'import/no-extraneous-dependencies': ['error', {
devDependencies: ['*.config.ts'],
devDependencies: [
'.eslintrc.js',
'**/*.test.ts',
'**/*.spec.ts',
'__tests__/**/*.ts',
'*.config.ts',
'**/vite.config.ts',
],
}],
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
'func-names': 'error', // Changed from 'warn' to 'error'.
'import/no-absolute-path': 'off', // Turned off because we use absolute paths instead of '../'.
'implicit-arrow-linebreak': 'off', // Turned of because of bullshit
'no-alert': 'error', // Changed from 'warn' to 'error'.
'no-console': 'off', // Changed from 'warn' to 'error'.
'no-console': 'error', // Changed from 'warn' to 'error'.
'no-constant-condition': 'error', // Changed from 'warn' to 'error'.
'no-underscore-dangle': ['error', { // Make some exceptions for often used fields
allow: [
Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Checks

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
preflight:
if: ${{ github.event.pull_request.head.ref != 'main' && github.event.pull_request.head.ref != 'development' }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Load node modules cache
id: modules-cache
uses: actions/cache@v4
timeout-minutes: 5
continue-on-error: true
with:
path: |
**/node_modules
key: ${{ runner.OS }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-modules-${{ matrix.node-version }}-
- name: install modules
run: |
npm install --no-audit --force --loglevel=error --no-update-notifier

linting:
needs: preflight
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
- name: Load node modules cache
id: modules-cache
uses: actions/cache/restore@v4
timeout-minutes: 5
continue-on-error: false
with:
fail-on-cache-miss: true
path: |
**/node_modules
key: ${{ runner.OS }}-modules-20.x-${{ hashFiles('**/package-lock.json') }}
- name: linting
run: |
npm run build
npm run lint

typecheck:
needs: preflight
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
- name: Load node modules cache
id: modules-cache
uses: actions/cache/restore@v4
timeout-minutes: 5
continue-on-error: false
with:
fail-on-cache-miss: true
path: |
**/node_modules
key: ${{ runner.OS }}-modules-20.x-${{ hashFiles('**/package-lock.json') }}
- name: typecheck
run: |
npm run build
npm run type-check

unit-tests:
needs: preflight
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Load node modules cache
id: modules-cache
uses: actions/cache/restore@v4
timeout-minutes: 5
continue-on-error: false
with:
fail-on-cache-miss: true
path: |
**/node_modules
key: ${{ runner.OS }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: unit testing
run: |
npm run build
npm test -- --coverage run
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build:
needs: preflight
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Load node modules cache
id: modules-cache
uses: actions/cache/restore@v4
timeout-minutes: 5
continue-on-error: false
with:
fail-on-cache-miss: true
path: |
**/node_modules
key: ${{ runner.OS }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: build package
run: |
npm run build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/tmp
dist
node_modules
coverage
Loading