Skip to content

Commit

Permalink
[Tests] pre-build the tests, only in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 11, 2024
1 parent 7f0a606 commit 0c0d722
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 71 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
".nyc_output/",
"flow-typed/",
"flow",
"__tests-built__/",
],
"overrides": [
{
Expand Down
90 changes: 32 additions & 58 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,54 @@
name: CI
on:
push:
branches:
- main
- "!dependabot/**"
pull_request:
workflow_dispatch:
[push, pull_request, workflow_dispatch]

jobs:
jest:
name: Jest (Node v${{ matrix.node }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [14, 16, 17]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load Node version ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Npm Install
run: npm ci
- name: Run Jest
run: npm run test:ci
- name: Run Coveralls
uses: coverallsapp/github-action@v2
if: matrix.node == '16'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ./reports/lcov.info
tests:
uses: ljharb/actions/.github/workflows/node.yml@a840bfaa7e24d260a9f451baa97ca172fdb327af
with:
range: '>= 0.8'
type: majors
build-command: npm run build:tests
build-output-dir: __tests-built__,lib
command: npm run tests-built

flow:
name: Flow type checking
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load Node
uses: actions/setup-node@v4
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@a840bfaa7e24d260a9f451baa97ca172fdb327af
with:
cache: npm
- name: Npm Install
run: npm ci
use-npm-ci: true
- name: Flow type check
run: npm run flow
run: npx flow

eslint:
name: ESLint (Node v${{ matrix.node }})
name: ESLint
runs-on: ubuntu-latest
strategy:
matrix:
node: [16]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load Node version ${{ matrix.node }}
uses: actions/setup-node@v4
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@a840bfaa7e24d260a9f451baa97ca172fdb327af
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Npm Install
run: npm ci
use-npm-ci: true
- name: Run ESLint
run: npm run lint

diff-breakUpAriaJSON:
name: Compare JSON to src output
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load Node version
uses: actions/setup-node@v4
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@a840bfaa7e24d260a9f451baa97ca172fdb327af
with:
cache: npm
- name: Npm Install
run: npm ci
use-npm-ci: true
- name: Run diff check for the breakUpAriaJSON script
run: node scripts/breakUpAriaJSON.js && git diff --exit-code -- src

finisher:
name: all checks
needs: [tests, flow, eslint, diff-breakUpAriaJSON]
runs-on: ubuntu-latest
steps:
- run: true

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ docs/

coverage/
.nyc_output/
__tests-built__/
4 changes: 3 additions & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"branches": 76.06,
"exclude": [
"coverage",
"test"
"__tests-built__",
"test",
"scripts"
]
}
4 changes: 2 additions & 2 deletions __tests__/src/ariaPropsMaps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import test from 'tape';
import deepEqual from 'deep-equal-json';
import inspect from 'object-inspect';

import ariaPropsMap from '../../src/ariaPropsMap';
import rolesMap from '../../src/rolesMap';
import ariaPropsMap from 'aria-query/src/ariaPropsMap';
import rolesMap from 'aria-query/src/rolesMap';

const entriesList = [
['aria-activedescendant', {'type': 'id'}],
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/domMap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'tape';
import deepEqual from 'deep-equal-json';
import inspect from 'object-inspect';

import domMap from '../../src/domMap';
import domMap from 'aria-query/src/domMap';

const entriesList = [
["a", {"reserved": false}],
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/elementRoleMap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'tape';
import deepEqual from 'deep-equal-json';
import inspect from 'object-inspect';

import elementRoleMap from '../../src/elementRoleMap';
import elementRoleMap from 'aria-query/src/elementRoleMap';

const entriesList = [
[{"name": "article"}, ["article"]],
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/roleElementMap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'tape';
import inspect from 'object-inspect';
import deepEqual from 'deep-equal-json';

import roleElementMap from '../../src/roleElementMap';
import roleElementMap from 'aria-query/src/roleElementMap';

const entriesList = [
["article", [{"name": "article"}]],
Expand Down
4 changes: 2 additions & 2 deletions __tests__/src/rolesMap-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'tape';
import inspect from 'object-inspect';

import rolesMap from '../../src/rolesMap';
import ariaPropsMap from '../../src/ariaPropsMap';
import rolesMap from 'aria-query/src/rolesMap';
import ariaPropsMap from 'aria-query/src/ariaPropsMap';

const entriesList = [
["alert", null],
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
"lint": "eslint --ext=js,mjs .",
"prepublishOnly": "npm run build",
"pretest": "npm run lint && flow",
"build:tests": "npm run build && rimraf __tests-built__ && BABEL_ENV=test babel __tests__ --out-dir __tests-built__",
"tests-built": "nyc tape '__tests-built__/**/*.js'",
"tests-only": "nyc tape -r @babel/register '__tests__/**/*.js'",
"test": "npm run tests-only",
"posttest": "npm audit --production",
"output_as_hack": "babel-node ./scripts/output_as_hack.js"
},
"repository": {
Expand All @@ -36,6 +39,7 @@
"@babel/core": "^7.24.7",
"@babel/eslint-parser": "^7.19.1",
"@babel/node": "^7.22.5",
"@babel/plugin-transform-react-jsx": "^7.20.7",
"@babel/preset-env": "^7.19.4",
"@babel/preset-flow": "^7.18.6",
"@babel/register": "^7.24.6",
Expand All @@ -59,5 +63,8 @@
"not dead",
"not op_mini all",
"ie 11"
]
],
"engines": {
"node": ">= 0.4"
}
}

0 comments on commit 0c0d722

Please sign in to comment.