Skip to content

Commit

Permalink
Merge branch 'main' into fix/update-inline-snapshot-jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 19, 2022
2 parents 23ce2ca + 7d8d01c commit 36b2c4d
Show file tree
Hide file tree
Showing 487 changed files with 32,183 additions and 16,163 deletions.
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ jobs:
node-version: lts/*
- node/install-packages: *install
- run:
command: JEST_JASMINE=1 yarn test-ci-partial --shard=$(expr $CIRCLE_NODE_INDEX + 1)/$CIRCLE_NODE_TOTAL && JEST_JASMINE=1 yarn test-leak
name: Test
command: JEST_JASMINE=1 yarn test-ci-partial --shard=$(expr $CIRCLE_NODE_INDEX + 1)/$CIRCLE_NODE_TOTAL
- run:
name: Leak test
command: JEST_JASMINE=1 yarn test-leak
- store_test_results:
path: reports/junit

Expand All @@ -54,5 +58,5 @@ workflows:
name: test-node-partial-<< matrix.node-version >>
matrix:
parameters:
node-version: ['12', '14', '16', '17', '18']
node-version: ['14', '16', '18']
- test-jest-jasmine
44 changes: 37 additions & 7 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable sort-keys */

const fs = require('fs');
const path = require('path');
const {sync: readPkg} = require('read-pkg');
Expand All @@ -14,7 +16,8 @@ function getPackages() {
const packages = fs
.readdirSync(PACKAGES_DIR)
.map(file => path.resolve(PACKAGES_DIR, file))
.filter(f => fs.lstatSync(path.resolve(f)).isDirectory());
.filter(f => fs.lstatSync(path.resolve(f)).isDirectory())
.filter(f => fs.existsSync(path.join(path.resolve(f), 'package.json')));
return packages.map(packageDir => {
const pkg = readPkg({cwd: packageDir});
return pkg.name;
Expand All @@ -27,6 +30,7 @@ module.exports = {
'jest/globals': true,
},
extends: [
'eslint:recommended',
'plugin:markdown/recommended',
'plugin:import/errors',
'plugin:eslint-comments/recommended',
Expand All @@ -38,6 +42,7 @@ module.exports = {
overrides: [
{
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:import/typescript',
],
Expand All @@ -46,15 +51,20 @@ module.exports = {
rules: {
'@typescript-eslint/array-type': ['error', {default: 'generic'}],
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_'},
],
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/no-var-requires': 'off',
// TS verifies these
'consistent-return': 'off',
'no-dupe-class-members': 'off',
'no-unused-vars': 'off',
// TODO: enable at some point
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
{
Expand Down Expand Up @@ -103,8 +113,6 @@ module.exports = {
'packages/expect-utils/src/utils.ts',
'packages/jest-core/src/collectHandles.ts',
'packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts',
'packages/jest-haste-map/src/index.ts',
'packages/jest-haste-map/src/watchers/FSEventsWatcher.ts',
'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-leak-detector/src/index.ts',
Expand Down Expand Up @@ -145,6 +153,9 @@ module.exports = {
files: ['**/*.md/**'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'arrow-body-style': 'off',
'consistent-return': 'off',
'import/export': 'off',
Expand All @@ -169,7 +180,7 @@ module.exports = {
},
},
{
files: ['website/**/*'],
files: ['docs/**/*', 'website/**/*'],
rules: {
'import/order': 'off',
'import/sort-keys': 'off',
Expand Down Expand Up @@ -202,6 +213,13 @@ module.exports = {
],
},
},
{
files: ['**/__tests__/**', '**/__mocks__/**'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
{
files: [
'**/__tests__/**',
Expand Down Expand Up @@ -249,7 +267,19 @@ module.exports = {
},
},
{
files: ['**/__typetests__/**', '**/*.md/**'],
files: ['**/__typetests__/**'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
},
},
{
files: [
'**/__typetests__/**',
'**/*.md/**',
'e2e/circus-concurrent/__tests__/concurrent-only-each.test.js',
'e2e/jasmine-async/__tests__/concurrent-only-each.test.js',
'e2e/test-failing/__tests__/worksWithOnlyMode.test.js',
],
rules: {
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
Expand Down Expand Up @@ -314,7 +344,6 @@ module.exports = {
'handle-callback-err': 'off',
'id-length': 'off',
'id-match': 'off',
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': [
'error',
{
Expand Down Expand Up @@ -383,7 +412,8 @@ module.exports = {
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'warn',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'error',
'no-else-return': 'off',
'no-empty': 'off',
'no-empty-character-class': 'warn',
Expand Down
135 changes: 39 additions & 96 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,23 @@ concurrency:
cancel-in-progress: true

jobs:
prepare-yarn-cache:
name: Prepare yarn cache
strategy:
fail-fast: false
matrix:
# for some reason the Windows cache doesn't work
os: [ubuntu-latest, macOS-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: yarn

- name: Validate cache
env:
# Use PnP and disable postinstall scripts as this just needs to
# populate the cache for the other jobs
YARN_NODE_LINKER: pnp
YARN_ENABLE_SCRIPTS: false
run: yarn --immutable

typecheck:
name: Running TypeScript compiler
prepare-yarn-cache-ubuntu:
uses: ./.github/workflows/prepare-cache.yml
with:
os: ubuntu-latest
prepare-yarn-cache-macos:
uses: ./.github/workflows/prepare-cache.yml
with:
os: macos-latest
prepare-yarn-cache-windows:
uses: ./.github/workflows/prepare-cache.yml
with:
os: windows-latest

ts-compatibility:
name: TypeScript Compatibility
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu

steps:
- uses: actions/checkout@v3
Expand All @@ -53,15 +41,17 @@ jobs:
run: yarn --immutable
- name: build
run: yarn build
- name: test typings
run: yarn test-types
- name: ts integration
run: yarn test-ts --selectProjects ts-integration
- name: type tests
run: yarn test-ts --selectProjects type-tests
- name: verify TypeScript@4.3 compatibility
run: yarn verify-old-ts

lint:
name: Running Lint
name: Lint
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu

steps:
- uses: actions/checkout@v3
Expand All @@ -85,7 +75,7 @@ jobs:
yarn-validate:
name: Validate Yarn dependencies and constraints
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -97,68 +87,21 @@ jobs:
- name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")'
run: yarn dedupe --check

test:
name: Node v${{ matrix.node-version }} on ${{ matrix.os }} (${{ matrix.shard }})
strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x, 17.x, 18.x]
os: [ubuntu-latest, macOS-latest, windows-latest]
shard: ['1/4', '2/4', '3/4', '4/4']
runs-on: ${{ matrix.os }}
needs: prepare-yarn-cache

steps:
- name: Set git config
shell: bash
run: git config --global core.symlinks true
if: runner.os == 'Windows'
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: install
run: yarn --immutable
- name: build
run: yarn build:js
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}

test-jasmine:
name: Node LTS on ${{ matrix.os }} using jest-jasmine2 (${{ matrix.shard }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
shard: ['1/4', '2/4', '3/4', '4/4']
runs-on: ${{ matrix.os }}
needs: prepare-yarn-cache

steps:
- name: Set git config
shell: bash
run: git config --global core.symlinks true
if: runner.os == 'Windows'
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: yarn
- name: install
run: yarn --immutable
- name: build
run: yarn build:js
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
test-ubuntu:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-ubuntu
with:
os: ubuntu-latest
test-macos:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-macos
with:
os: macos-latest
test-windows:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-windows
with:
os: windows-latest

test-coverage:
name: Node LTS on Ubuntu with coverage (${{ matrix.shard }})
Expand All @@ -167,7 +110,7 @@ jobs:
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
runs-on: ubuntu-latest
needs: prepare-yarn-cache
needs: prepare-yarn-cache-ubuntu

steps:
- uses: actions/checkout@v3
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/prepare-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Prepare CI cache

on:
workflow_call:
inputs:
os:
required: true
type: string

jobs:
prepare-yarn-cache:
name: Prepare yarn cache for ${{ inputs.os }}
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: yarn

- name: Validate cache
env:
# Use PnP and disable postinstall scripts as this just needs to
# populate the cache for the other jobs
YARN_NODE_LINKER: pnp
YARN_ENABLE_SCRIPTS: false
run: yarn --immutable

0 comments on commit 36b2c4d

Please sign in to comment.