Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0461a9

Browse files
committed
chore: add regression testing against old TS and ESLint versions
1 parent 121f4c0 commit f0461a9

File tree

7 files changed

+165
-285
lines changed

7 files changed

+165
-285
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
'./tsconfig.eslint.json',
2727
'./packages/*/tsconfig.json',
2828
'./tests/integration/tsconfig.json',
29+
'./tools/tsconfig.json',
2930
/**
3031
* We are currently in the process of transitioning to nx's out of the box structure and
3132
* so need to manually specify converted packages' tsconfig.build.json and tsconfig.spec.json

.github/workflows/ci.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ on:
99
- '**'
1010

1111
env:
12+
PRIMARY_ESLINT_VERSION: '^8.0.0'
1213
PRIMARY_NODE_VERSION: 18
14+
PRIMARY_TYPESCRIPT_VERSION: '~4.8.0'
1315

1416
defaults:
1517
run:
@@ -117,6 +119,7 @@ jobs:
117119
strategy:
118120
matrix:
119121
# just run on the oldest and latest supported versions and assume the intermediate versions are good
122+
# unfortunately you can't reference environment variables in an array :(
120123
node-version: [14, 18]
121124
package:
122125
[
@@ -172,6 +175,102 @@ jobs:
172175
# Sadly 1 day is the minimum
173176
retention-days: 1
174177

178+
unit_tests_ts_regression:
179+
name: Run Unit Tests (TypeScript Version Regression Checks)
180+
needs: [build]
181+
runs-on: ubuntu-latest
182+
strategy:
183+
matrix:
184+
package:
185+
# note that we don't regression test all packages here on purpose because most don't depend on TS directly.
186+
['eslint-plugin', 'scope-manager', 'type-utils', 'typescript-estree']
187+
188+
ts-version:
189+
# unfortunately you can't reference environment variables in an array :(
190+
[
191+
# lowest possible version
192+
'3.3.1',
193+
# somewhere in the middle for sanity check
194+
'~4.0.8',
195+
# highest possible version
196+
'~4.8.2',
197+
]
198+
env:
199+
# Added the - at the end to function as a separator to improve readability in the PR comment from the Nx cloud app
200+
NX_CLOUD_ENV_NAME: 'Node ${{ matrix.node-version }} -'
201+
COLLECT_COVERAGE: false
202+
steps:
203+
- name: Checkout
204+
uses: actions/checkout@v3
205+
with:
206+
fetch-depth: 2
207+
- name: Install
208+
uses: ./.github/actions/prepare-install
209+
with:
210+
node-version: ${{ env.PRIMARY_NODE_VERSION }}
211+
- name: Build
212+
uses: ./.github/actions/prepare-build
213+
214+
- name: Install Specific TS Version
215+
run: |
216+
yarn ts-node ./tools/change-ts-version.ts ${{ matrix.ts-version }}
217+
yarn --ignore-engines --ignore-scripts
218+
219+
- name: Patch Packages
220+
if: matrix.ts-version == env.PRIMARY_TYPESCRIPT_VERSION
221+
run: |
222+
yarn patch-package
223+
224+
# we don't collect coverage for these tests on purpose
225+
- name: Run unit tests for ${{ matrix.package }}
226+
run: npx nx test @typescript-eslint/${{ matrix.package }} --coverage=false
227+
env:
228+
CI: true
229+
230+
unit_tests_eslint_regression:
231+
name: Run Unit Tests (ESLint Version Regression Checks)
232+
needs: [build]
233+
runs-on: ubuntu-latest
234+
strategy:
235+
matrix:
236+
package:
237+
# note that we don't regression test all packages here on purpose because most don't depend on ESLint directly.
238+
['eslint-plugin', 'utils']
239+
eslint-version:
240+
# unfortunately you can't reference environment variables in an array :(
241+
[
242+
# lowest possible version
243+
'6.0.0',
244+
# somewhere in the middle for sanity check
245+
'~7.32.0',
246+
# highest possible version
247+
'^8.0.0',
248+
]
249+
env:
250+
# Added the - at the end to function as a separator to improve readability in the PR comment from the Nx cloud app
251+
NX_CLOUD_ENV_NAME: 'Node ${{ matrix.node-version }} -'
252+
COLLECT_COVERAGE: false
253+
steps:
254+
- name: Checkout
255+
uses: actions/checkout@v3
256+
with:
257+
fetch-depth: 2
258+
- name: Install
259+
uses: ./.github/actions/prepare-install
260+
with:
261+
node-version: ${{ env.PRIMARY_NODE_VERSION }}
262+
- name: Build
263+
uses: ./.github/actions/prepare-build
264+
265+
- name: Install Specific ESLint Version
266+
run: yarn add -DW --ignore-engines --ignore-scripts eslint@${{ matrix.eslint-version }}
267+
268+
# we don't collect coverage for these tests on purpose
269+
- name: Run unit tests for ${{ matrix.package }}
270+
run: npx nx test @typescript-eslint/${{ matrix.package }} --coverage=false
271+
env:
272+
CI: true
273+
175274
website_tests:
176275
permissions:
177276
contents: read # to fetch code (actions/checkout)

packages/website-eslint/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
"eslint": "*",
3333
"rollup": "^2.75.4",
3434
"rollup-plugin-terser": "^7.0.2",
35-
"semver": "^7.3.7"
35+
"semver": "*"
3636
}
3737
}

tools/change-ts-version.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import semver from 'semver';
4+
5+
const packageJson = require('../package.json') as {
6+
resolutions: Record<string, unknown>;
7+
devDependencies: Record<string, unknown>;
8+
};
9+
10+
const newVersion = semver.valid(semver.coerce(process.argv[2]));
11+
if (newVersion == null) {
12+
throw new Error('The first argument passed must be a valid semver');
13+
}
14+
15+
packageJson.resolutions.typescript = newVersion;
16+
packageJson.devDependencies.typescript = newVersion;
17+
18+
fs.writeFileSync(
19+
path.resolve(__dirname, '../package.json'),
20+
JSON.stringify(packageJson, null, 2),
21+
);

tools/generate-contributors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface Contributor {
2121
contributions: number;
2222
type: string;
2323
login?: string;
24-
url?: string;
24+
url: string;
2525
avatar_url?: string;
2626
html_url?: string;
2727
}

tools/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"compilerOptions": {
4+
"esModuleInterop": true,
5+
"resolveJsonModule": true,
6+
"rootDir": ".."
7+
},
8+
"include": ["./*.ts"],
9+
"references": []
10+
}

0 commit comments

Comments
 (0)