Skip to content

Commit

Permalink
⚒ update CI and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey authored and mysticatea committed May 13, 2020
1 parent 50bf912 commit 2df66e4
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1,2 +1,2 @@
*.ts eol=lf
* text=auto eol=lf
/test/fixtures/crlf.vue eol=crlf
86 changes: 44 additions & 42 deletions .github/workflows/CI.yml
Expand Up @@ -12,45 +12,57 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Checkout submodules
run: git submodule update --init
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install Packages
run: npm install
- name: Lint
run: npm run -s lint
- name: Checkout
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Packages
run: npm install
- name: Lint
run: npm run -s lint

test:
name: Test

strategy:
matrix:
eslint: [6, 5]
node: [13, 12, 10, 8, "8.10.0"]
exclude:
# Run ESLint 5 on only the LTS.
- node: 13
eslint: 5
- node: 10
eslint: 5
- node: 8
eslint: 5
- node: "8.10.0"
eslint: 5
eslint: [7]
node: [14]
os: [ubuntu-latest]
include:
# On other platforms
- eslint: 7
node: 14
os: windows-latest
- eslint: 7
node: 14
os: macos-latest
# On old Node.js versions
- eslint: 7
node: 12
os: ubuntu-latest
- eslint: 7
node: 10
os: ubuntu-latest
# On old ESLint versions
- eslint: 6
node: 14
os: ubuntu-latest
- eslint: 5
node: 14
os: ubuntu-latest
# On the minimum supported ESLint/Node.js version
- eslint: 5
node: 8.10.0
os: ubuntu-latest

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init
- name: Install Node.js v${{ matrix.node }}
Expand All @@ -60,17 +72,7 @@ jobs:
- name: Install Packages
run: npm install
- name: Install ESLint v${{ matrix.eslint }}
run: |
if [ ${{ matrix.eslint }} -eq 6 ]; then
cd test/fixtures/eslint
npm install
else
npm install --no-save eslint@5.16.0
cd test/fixtures/eslint
git checkout v5.16.0
npm install eslint-utils@1.4.0
npm install
fi
run: node scripts/ci-install-eslint ${{ matrix.eslint }}
- name: Build
run: npm run -s build
- name: Test
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -16,7 +16,7 @@
"debug": "^4.1.1",
"eslint-scope": "^5.0.0",
"eslint-visitor-keys": "^1.1.0",
"espree": "^6.1.2",
"espree": "^7.0.0",
"esquery": "^1.0.1",
"lodash": "^4.17.15"
},
Expand All @@ -27,13 +27,13 @@
"@types/lodash": "^4.14.120",
"@types/mocha": "^5.2.4",
"@types/node": "^10.12.21",
"@typescript-eslint/parser": "^1.2.0",
"@typescript-eslint/parser": "^2.31.0",
"babel-eslint": "^10.0.1",
"chokidar": "^2.0.4",
"codecov": "^3.1.0",
"cross-spawn": "^6.0.5",
"dts-bundle": "^0.7.3",
"eslint": "^6.1.0",
"eslint": "^7.0.0",
"fs-extra": "^7.0.1",
"mocha": "^6.1.4",
"npm-run-all": "^4.1.5",
Expand Down
47 changes: 47 additions & 0 deletions scripts/ci-install-eslint.js
@@ -0,0 +1,47 @@
"use strict"

const { spawn } = require("child_process")

function cd(path) {
console.log("$ cd %s", path)
process.chdir(path)
}

function sh(command) {
console.log("$ %s", command)
return new Promise((resolve, reject) => {
spawn(command, [], { shell: true, stdio: "inherit" })
.on("error", reject)
.on("exit", exitCode => {
if (exitCode) {
reject(new Error(`Exit with non-zero ${exitCode}`))
} else {
resolve()
}
})
})
}

;(async function main() {
const requestedVersion = process.argv[2]
const requestedVersionSpec = /^\d+\.\d+\.\d+$/u.test(requestedVersion)
? requestedVersion
: `^${requestedVersion}`

// Install ESLint of the requested version
await sh(`npm install eslint@${requestedVersionSpec}`)

// Install ESLint submodule of the requested version
const installedVersion = require("eslint").CLIEngine.version
cd("test/fixtures/eslint")
if (!installedVersion.startsWith("7.")) {
await sh(`git checkout v${installedVersion}`)
}
if (installedVersion.startsWith("5.")) {
await sh("npm install eslint-utils@1.4.0")
}
await sh("npm install")
})().catch(error => {
console.error(error)
process.exitCode = 1
})
17 changes: 15 additions & 2 deletions test/core-rules.js
Expand Up @@ -44,6 +44,19 @@ const EXCEPTIONS = new Set([
const originalRun = RuleTester.prototype.run
const processed = new Set()

/**
* Check if the code should be skipped or not.
* The following code should be skipped.
* - includes shebang
* - includes syntax error -- some tests in old ESLint contains syntax error.
* Acorn has fixed to catch the syntax errors in a minor release, so those
* tests go to fail.
* @param {string} code The test code.
*/
function codeShouldBeSkipped(code) {
return code.startsWith("#!") || code.includes("await async")
}

/**
* Wrap the given code with a `<script>` tag.
*
Expand All @@ -69,7 +82,7 @@ function wrapCode(code) {
//eslint-disable-next-line complexity
function modifyPattern(ruleId, pattern) {
if (typeof pattern === "string") {
if (pattern.startsWith("#!")) {
if (codeShouldBeSkipped(pattern)) {
return null
}
return {
Expand All @@ -84,7 +97,7 @@ function modifyPattern(ruleId, pattern) {
if (
pattern.parser != null ||
pattern.filename != null ||
pattern.code.startsWith("#!")
codeShouldBeSkipped(pattern.code)
) {
return null
}
Expand Down

0 comments on commit 2df66e4

Please sign in to comment.