-
-
Notifications
You must be signed in to change notification settings - Fork 32
ci: add e2e tests to CI #546
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
363ace4
ci: add e2e tests to CI
michaelfaith 4dc292f
add cache to node setup and windows to e2e matrix
michaelfaith 1a37f3f
remove cache option from ci jobs
michaelfaith 0979736
add newlint to npmpackagejsonlintignore
michaelfaith 7be4d22
Make script output more actionable, and add tsdoc
michaelfaith 3661b44
add inline disables
michaelfaith 32a1987
Move e2e test dirs into `fixtures`
michaelfaith 2cb4950
Move e2e test dirs into `fixtures`
michaelfaith de3ae93
Format
michaelfaith 4aafaef
Update e2e/.npmrc
bmish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e2e/ | ||
michaelfaith marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'eslint/config'; | ||
|
||
import eslintPlugin from 'eslint-plugin-eslint-plugin'; | ||
|
||
export default defineConfig([ | ||
{ | ||
extends: [eslintPlugin.configs.all], | ||
files: ['./index.js', './rule.js'], | ||
}, | ||
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import rule from './rule.js'; | ||
|
||
/** @type {import('eslint').ESLint.Plugin} */ | ||
const plugin = { | ||
meta: { | ||
name: '@e2e/all-typed-config', | ||
version: '1.0.0', | ||
}, | ||
rules: { 'e2e-test': rule }, | ||
configs: { | ||
recommended: { | ||
name: '@e2e/all-typed-config/recommended', | ||
plugins: { | ||
get ['@e2e/all-typed-config']() { | ||
return plugin; | ||
}, | ||
}, | ||
rules: { | ||
'@e2e/all-typed-config/e2e-test': 'error', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default plugin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@e2e/all-typed-config", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"lint": "tsc && eslint" | ||
}, | ||
"main": "./index.js", | ||
"devDependencies": { | ||
"eslint": "^9.33.0", | ||
"eslint-plugin-eslint-plugin": "file:../..", | ||
"jiti": "^2.5.1", | ||
"typescript": "^5.9.2" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @type {import('eslint').Rule.RuleModule} */ | ||
const rule = { | ||
meta: { | ||
type: 'suggestion', | ||
docs: { | ||
description: 'enforce a test', | ||
recommended: false, | ||
url: 'https://test.org', | ||
}, | ||
fixable: undefined, // or "code" or "whitespace" | ||
schema: [], | ||
messages: { | ||
missingOutput: 'This is a test', | ||
}, | ||
}, | ||
|
||
create(context) { | ||
return { | ||
Program(ast) { | ||
const sourceCode = context.sourceCode; | ||
if (false) { | ||
context.report({ | ||
node: ast, | ||
messageId: 'missingOutput', | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; | ||
|
||
export default rule; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"module": "nodenext", | ||
"moduleResolution": "nodenext", | ||
"noEmit": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"target": "ES2024", | ||
"verbatimModuleSyntax": true, | ||
"erasableSyntaxOnly": true, | ||
"types": [] | ||
}, | ||
"include": ["eslint.config.ts"] | ||
} |
michaelfaith marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'eslint/config'; | ||
|
||
import eslintPlugin from 'eslint-plugin-eslint-plugin'; | ||
|
||
export default defineConfig([ | ||
{ | ||
extends: [eslintPlugin.configs.all], | ||
files: ['./index.js', './rule.js'], | ||
}, | ||
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import rule from './rule.js'; | ||
|
||
/** @type {import('eslint').ESLint.Plugin} */ | ||
const plugin = { | ||
meta: { | ||
name: '@e2e/all', | ||
version: '1.0.0', | ||
}, | ||
rules: { 'e2e-test': rule }, | ||
configs: { | ||
recommended: { | ||
name: '@e2e/all/recommended', | ||
plugins: { | ||
get ['@e2e/all']() { | ||
return plugin; | ||
}, | ||
}, | ||
rules: { | ||
'@e2e/all/e2e-test': 'error', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default plugin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "@e2e/all", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"lint": "eslint" | ||
}, | ||
"main": "./index.js", | ||
"devDependencies": { | ||
"eslint": "^9.33.0", | ||
"eslint-plugin-eslint-plugin": "file:../.." | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @type {import('eslint').Rule.RuleModule} */ | ||
const rule = { | ||
meta: { | ||
type: 'suggestion', | ||
docs: { | ||
description: 'enforce a test', | ||
recommended: false, | ||
url: 'https://test.org', | ||
}, | ||
fixable: undefined, // or "code" or "whitespace" | ||
schema: [], | ||
messages: { | ||
missingOutput: 'This is a test', | ||
}, | ||
}, | ||
|
||
create(context) { | ||
return { | ||
Program(ast) { | ||
const sourceCode = context.sourceCode; | ||
if (false) { | ||
context.report({ | ||
node: ast, | ||
messageId: 'missingOutput', | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; | ||
|
||
export default rule; |
michaelfaith marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { execSync } from 'node:child_process'; | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import process from 'node:process'; | ||
|
||
const TEST_COMMAND = 'npm run lint'; | ||
|
||
const getRoot = () => { | ||
return execSync('git rev-parse --show-toplevel', { | ||
encoding: 'utf-8', | ||
}).trim(); | ||
}; | ||
|
||
const executeAllE2eTests = async () => { | ||
const e2eDir = path.resolve(getRoot(), './e2e'); | ||
const failedTests = []; | ||
|
||
// Get all directories in the e2e dir | ||
const testDirs = (await fs.readdir(e2eDir, { withFileTypes: true })) | ||
.filter((dirEnt) => dirEnt.isDirectory()) | ||
.map((dirEnt) => path.join(dirEnt.parentPath, dirEnt.name)); | ||
|
||
for (const testDir of testDirs) { | ||
const dirName = path.basename(testDir); | ||
console.log(`🧪 Executing test: ${dirName}`); | ||
|
||
// Run install and the test command | ||
execSync('npm install', { | ||
cwd: testDir, | ||
stdio: ['ignore', 'ignore', 'pipe'], | ||
}); | ||
try { | ||
execSync(TEST_COMMAND, { | ||
cwd: testDir, | ||
stdio: ['ignore', 'ignore', 'pipe'], | ||
}); | ||
console.log(`✅ Test passed\n`); | ||
} catch (error) { | ||
console.log(`❌ Test failed`); | ||
console.error(`${error}\n`); | ||
michaelfaith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
failedTests.push(dirName); | ||
} | ||
} | ||
|
||
if (failedTests.length) { | ||
console.log( | ||
`Testing complete. ${failedTests.length} of ${testDirs.length} tests failed!`, | ||
); | ||
process.exitCode = 1; | ||
} else { | ||
console.log(`Testing complete. All ${testDirs.length} tests passed!`); | ||
} | ||
}; | ||
|
||
executeAllE2eTests(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we may be missing tests on Windows. Should we test that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can add that. Do you want it added to the unit test matrix too?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to the e2e job. If you want me to add it to the test job, I can do that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally would be good to test on both. Hopefully it doesn't hurt perf too much. Also could be done separately.