Skip to content

Commit

Permalink
chore: add regression testing against old TS and ESLint versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Aug 30, 2022
1 parent 60b6c11 commit 25fb41d
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'./tsconfig.eslint.json',
'./packages/*/tsconfig.json',
'./tests/integration/tsconfig.json',
'./tools/tsconfig.json',
/**
* We are currently in the process of transitioning to nx's out of the box structure and
* so need to manually specify converted packages' tsconfig.build.json and tsconfig.spec.json
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:
- '**'

env:
PRIMARY_ESLINT_VERSION: '^8.0.0'
PRIMARY_NODE_VERSION: 18
PRIMARY_TYPESCRIPT_VERSION: '~4.8.0'

defaults:
run:
Expand Down Expand Up @@ -114,6 +116,7 @@ jobs:
strategy:
matrix:
# just run on the oldest and latest supported versions and assume the intermediate versions are good
# unfortunately you can't reference environment variables in an array :(
node-version: [14, 18]
package:
[
Expand Down Expand Up @@ -169,6 +172,88 @@ jobs:
# Sadly 1 day is the minimum
retention-days: 1

unit_tests_ts_regression:
name: Run Unit Tests (TypeScript Version Regression Checks)
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
package:
# note that we don't regression test all packages here on purpose because most don't depend on TS directly.
['eslint-plugin', 'scope-manager', 'type-utils', 'typescript-estree']

ts-version:
# unfortunately you can't reference environment variables in an array :(
['3.3.1', '~4.0.0', '~4.8.0']
env:
# Added the - at the end to function as a separator to improve readability in the PR comment from the Nx cloud app
NX_CLOUD_ENV_NAME: 'Node ${{ matrix.node-version }} -'
COLLECT_COVERAGE: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install
uses: ./.github/actions/prepare-install
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}
- name: Build
uses: ./.github/actions/prepare-build

- name: Install Specific TS Version
run: |
yarn ts-node ./tools/change-ts-version.ts ${{ matrix.ts-version }}
yarn --ignore-engines --ignore-scripts
- name: Patch Packages
if: matrix.ts-version == env.PRIMARY_TYPESCRIPT_VERSION
run: |
yarn patch-package
# we don't collect coverage for these tests on purpose
- name: Run unit tests for ${{ matrix.package }}
run: npx nx test @typescript-eslint/${{ matrix.package }} --coverage=false
env:
CI: true

unit_tests_eslint_regression:
name: Run Unit Tests (ESLint Version Regression Checks)
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
package:
# note that we don't regression test all packages here on purpose because most don't depend on ESLint directly.
['eslint-plugin', 'utils']
eslint-version:
# unfortunately you can't reference environment variables in an array :(
['6.0.0', '7.0.0', '^8.0.0']
env:
# Added the - at the end to function as a separator to improve readability in the PR comment from the Nx cloud app
NX_CLOUD_ENV_NAME: 'Node ${{ matrix.node-version }} -'
COLLECT_COVERAGE: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install
uses: ./.github/actions/prepare-install
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}
- name: Build
uses: ./.github/actions/prepare-build

- name: Install Specific ESLint Version
run: yarn add -DW --ignore-engines --ignore-scripts eslint@${{ matrix.eslint-version }}

# we don't collect coverage for these tests on purpose
- name: Run unit tests for ${{ matrix.package }}
run: npx nx test @typescript-eslint/${{ matrix.package }} --coverage=false
env:
CI: true

website_tests:
name: Website tests
needs: [build]
Expand Down
17 changes: 17 additions & 0 deletions tools/change-ts-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import fs from 'fs';
import path from 'path';
import semver from 'semver';
import packageJson = require('../package.json');

const newVersion = semver.valid(semver.coerce(process.argv[2]));
if (newVersion == null) {
throw new Error('The first argument passed must be a valid semver');
}

packageJson.resolutions.typescript = newVersion;
packageJson.devDependencies.typescript = newVersion;

fs.writeFileSync(
path.resolve(__dirname, '../package.json'),
JSON.stringify(packageJson, null, 2),
);
2 changes: 1 addition & 1 deletion tools/generate-contributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Contributor {
contributions: number;
type: string;
login?: string;
url?: string;
url: string;
avatar_url?: string;
html_url?: string;
}
Expand Down
10 changes: 10 additions & 0 deletions tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"esModuleInterop": true,
"resolveJsonModule": true,
"rootDir": ".."
},
"include": ["./*.ts"],
"references": []
}

0 comments on commit 25fb41d

Please sign in to comment.