-
Notifications
You must be signed in to change notification settings - Fork 789
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
ci: add matrix node test #4275
Merged
Merged
ci: add matrix node test #4275
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a3f9533
ci: add matrix node test
straker 7bb7528
:robot: Automated formatting fixes
straker 33d4760
use node orb
straker 719431f
Merge branch 'matrix-tests' of https://github.com/dequelabs/axe-core …
straker 28e11f2
full node range
straker a51ed58
fix npm command
straker 9532d6a
Merge branch 'develop' into matrix-tests
straker e02d542
:robot: Automated formatting fixes
straker 44ec51a
fix how jsdom is installed
straker ce33cc3
Merge branch 'matrix-tests' of https://github.com/dequelabs/axe-core …
straker 37bed2f
comments
straker 22dd39b
drop down support to just 6 + LTS
straker 20a6df2
use all-rules.html
straker 386f675
read file
straker 9374efb
move node test to GHA
straker 9355b81
fix gha
straker dc05aa2
fix upload
straker e8264ee
try again?
straker 206a153
pin to v3 for upload/download
straker 8674094
fix prettier action
straker 3f9f321
output ignore file
straker 48b934c
cat not echo
straker 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 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 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 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,45 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run build | ||
# v4 download seems to have some flakiness with the download of artifacts so pinning to v3 for now | ||
# @see https://github.com/actions/download-artifact/issues/249 | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: axe-core | ||
path: axe.js | ||
retention-days: 1 | ||
|
||
test_node: | ||
strategy: | ||
matrix: | ||
node: [6, 18, 20] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node}} | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: axe-core | ||
- run: npm run test:node |
This file contains 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules/ | ||
doc/api | ||
doc/api |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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,93 @@ | ||
// this file is purposefully written without mocha and in es5 syntax in order | ||
// to be compatible with node 4+ | ||
|
||
var axe = require('../../'); | ||
var assert = require('assert'); | ||
var spawn = require('child_process').spawn; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
initJsdom(function (err, window) { | ||
assert.equal(err, null); | ||
|
||
console.log('running axe'); | ||
axe.run( | ||
window.document.documentElement, | ||
{ | ||
preload: false, | ||
rules: { 'color-contrast': { enabled: false } } | ||
}, | ||
function (axeError, results) { | ||
assert.equal(axeError, null); | ||
assert.notEqual(results.violations.length, 0); | ||
console.log('axe ran successfully'); | ||
} | ||
); | ||
}); | ||
|
||
/** | ||
* Install a version of jsdom that is compatible with the currently running node | ||
* version and return the jsdom window object. | ||
* @param {Function} callback - callback function when jsdom is installed. | ||
* Is passed any error object and the jsdom window object. | ||
*/ | ||
function initJsdom(callback) { | ||
try { | ||
var nodeToJsdomMatrix = { | ||
4: '9.12.0', // last jsdom version that supported this node version | ||
6: '11.12.0', | ||
8: '15.2.1', | ||
10: '16.7.0', | ||
12: '19.0.0', | ||
14: '21.1.2', | ||
16: '22.1.0' | ||
}; | ||
|
||
var majorNodeVersion = process.versions.node.split('.')[0]; | ||
var jsdomVersion = nodeToJsdomMatrix[majorNodeVersion] || 'latest'; | ||
|
||
console.log('node version detected as: v' + majorNodeVersion); | ||
console.log('installing jsdom@' + jsdomVersion); | ||
var child = spawn( | ||
'npm', | ||
['install', 'jsdom@' + jsdomVersion, '--no-save'], | ||
{ | ||
cwd: __dirname | ||
} | ||
); | ||
child.stdout.setEncoding('utf8'); | ||
child.stderr.setEncoding('utf8'); | ||
child.stdout.on('data', function (data) { | ||
console.log(data); | ||
}); | ||
child.stderr.on('data', function (data) { | ||
console.error(data); | ||
}); | ||
child.on('close', function () { | ||
console.log('installed'); | ||
var jsdom = require('jsdom'); | ||
var domStr = fs.readFileSync( | ||
path.join('test', 'integration', 'full', 'all-rules', 'all-rules.html'), | ||
'utf8' | ||
); | ||
|
||
// jsdom 9 | ||
if (jsdom.env) { | ||
jsdom.env(domStr, function (jsdomError, window) { | ||
if (jsdomError) { | ||
callback(jsdomError); | ||
} | ||
|
||
callback(null, window); | ||
}); | ||
} | ||
// jsdom 11+ | ||
else { | ||
var dom = new jsdom.JSDOM(domStr); | ||
callback(null, dom.window); | ||
} | ||
}); | ||
} catch (err) { | ||
callback(err); | ||
} | ||
} |
This file contains 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,4 @@ | ||
{ | ||
"description": "This package.json is intentionally left empty so running the node.js test does not install jsdom at the root level node_modules", | ||
"dependencies": {} | ||
} |
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.
This line wasn't working correctly and was failing the build as the
.prettierignore
file didn't have a newline character at the end of the file. So instead of appending a new line item this was appending to the end of the last item. Left this in for easier debugging.