Skip to content

Commit 9538fc5

Browse files
authored
⚒ switch CI to Azure Pipelines (#26)
1 parent 71a516e commit 9538fc5

File tree

9 files changed

+204
-40
lines changed

9 files changed

+204
-40
lines changed

.azure-pipelines/lint-job.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
jobs:
2+
- job: lint
3+
displayName: Lint
4+
pool:
5+
vmImage: Ubuntu-16.04
6+
steps:
7+
- task: NodeTool@0
8+
displayName: Install Node.js
9+
inputs:
10+
versionSpec: 12.x
11+
12+
- script: npm install
13+
displayName: Install Packages
14+
15+
- script: npm run -s lint
16+
displayName: Lint

.azure-pipelines/test-job.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
parameters:
2+
name: ""
3+
displayName: ""
4+
vmImage: ""
5+
nodeVersion: ""
6+
eslintVersion: ""
7+
8+
jobs:
9+
- job: ${{parameters.name}}
10+
displayName: ${{parameters.displayName}}
11+
pool:
12+
vmImage: ${{parameters.vmImage}}
13+
steps:
14+
- task: NodeTool@0
15+
displayName: Install Node.js
16+
inputs:
17+
versionSpec: ${{parameters.nodeVersion}}
18+
19+
- script: npm install
20+
displayName: Install Packages
21+
22+
- script: npm install --no-save eslint@${{parameters.eslintVersion}}
23+
displayName: Install Specific ESLint
24+
condition: ne('${{parameters.eslintVersion}}', '')
25+
26+
- script: npm run -s test:ci
27+
displayName: Test
28+
29+
- script: npm run -s codecov -- -t $(CODECOV_TOKEN)
30+
displayName: Send Coverage

.azure-pipelines/website-job.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
jobs:
2+
- job: website
3+
displayName: Build Website
4+
pool:
5+
vmImage: Ubuntu-16.04
6+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
7+
steps:
8+
- task: NodeTool@0
9+
displayName: Install Node.js
10+
inputs:
11+
versionSpec: 12.x
12+
13+
- script: npm install
14+
displayName: Install Packages
15+
16+
- script: npm run -s docs:build
17+
displayName: Build Website
18+
19+
- script: npm run -s docs:deploy -- $(GH_TOKEN)
20+
displayName: Deploy
21+
condition: succeeded()

.codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comment: off

.travis.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![npm version](https://img.shields.io/npm/v/eslint-plugin-eslint-comments.svg)](https://www.npmjs.com/package/eslint-plugin-eslint-comments)
44
[![Downloads/month](https://img.shields.io/npm/dm/eslint-plugin-eslint-comments.svg)](http://www.npmtrends.com/eslint-plugin-eslint-comments)
5-
[![Build Status](https://travis-ci.org/mysticatea/eslint-plugin-eslint-comments.svg?branch=master)](https://travis-ci.org/mysticatea/eslint-plugin-eslint-comments)
5+
[![Build Status](https://dev.azure.com/mysticatea/eslint-plugin-eslint-comments/_apis/build/status/continuous-integration?branchName=master)](https://dev.azure.com/mysticatea/eslint-plugin-eslint-comments/_build/latest?definitionId=2&branchName=master)
66
[![codecov](https://codecov.io/gh/mysticatea/eslint-plugin-eslint-comments/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/eslint-plugin-eslint-comments)
77
[![Dependency Status](https://david-dm.org/mysticatea/eslint-plugin-eslint-comments.svg)](https://david-dm.org/mysticatea/eslint-plugin-eslint-comments)
88

azure-pipelines.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
trigger:
2+
- master
3+
4+
jobs:
5+
- template: .azure-pipelines/lint-job.yml
6+
7+
- template: .azure-pipelines/test-job.yml
8+
parameters:
9+
name: test_on_linux_node12_eslint5
10+
displayName: Test on Node 12, ESLint 5, Linux
11+
vmImage: Ubuntu-16.04
12+
nodeVersion: 12.x
13+
14+
- template: .azure-pipelines/test-job.yml
15+
parameters:
16+
name: test_on_linux_node10_eslint5
17+
displayName: Test on Node 10, ESLint 5, Linux
18+
vmImage: Ubuntu-16.04
19+
nodeVersion: 10.x
20+
21+
- template: .azure-pipelines/test-job.yml
22+
parameters:
23+
name: test_on_linux_node8_eslint5
24+
displayName: Test on Node 8, ESLint 5, Linux
25+
vmImage: Ubuntu-16.04
26+
nodeVersion: 8.x
27+
28+
- template: .azure-pipelines/test-job.yml
29+
parameters:
30+
name: test_on_linux_node6_eslint5
31+
displayName: Test on Node 6, ESLint 5, Linux
32+
vmImage: Ubuntu-16.04
33+
nodeVersion: 6.x
34+
35+
- template: .azure-pipelines/test-job.yml
36+
parameters:
37+
name: test_on_linux_node12_eslint4
38+
displayName: Test on Node 12, ESLint 4, Linux
39+
vmImage: Ubuntu-16.04
40+
nodeVersion: 12.x
41+
eslintVersion: 4.x
42+
43+
- template: .azure-pipelines/test-job.yml
44+
parameters:
45+
name: test_on_windows_node12_eslint5
46+
displayName: Test on Node 12, ESLint 5, Windows
47+
vmImage: Windows-2019
48+
nodeVersion: 12.x
49+
50+
- template: .azure-pipelines/test-job.yml
51+
parameters:
52+
name: test_on_macos_node12_eslint5
53+
displayName: Test on Node 12, ESLint 5, macOS
54+
vmImage: macOS-10.14
55+
nodeVersion: 12.x
56+
57+
- template: .azure-pipelines/website-job.yml

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"cross-spawn": "^6.0.5",
2828
"eslint": "^5.12.0",
2929
"eslint4b": "^5.12.0",
30+
"fs-extra": "^8.0.1",
3031
"mocha": "^5.1.1",
3132
"nyc": "^13.2.0",
3233
"opener": "^1.4.3",
@@ -37,19 +38,20 @@
3738
},
3839
"scripts": {
3940
"preversion": "npm test",
40-
"version": "node scripts/update.js && git add .",
41+
"version": "node scripts/update && git add .",
4142
"postversion": "git push && git push --tags",
4243
"clean": "rimraf .nyc_output coverage docs/.vuepress/dist",
4344
"docs:build": "vuepress build docs",
4445
"docs:watch": "vuepress dev docs",
46+
"docs:deploy": "node scripts/deploy",
4547
"lint": "eslint lib scripts tests",
4648
"pretest": "npm run -s lint",
4749
"test": "nyc npm run -s test:mocha",
4850
"test:ci": "nyc npm run -s test:mocha",
4951
"test:mocha": "mocha \"tests/lib/**/*.js\" --reporter dot --timeout 4000",
5052
"watch": "npm run -s test:mocha -- --watch --growl",
5153
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
52-
"codecov": "nyc report --reporter lcovonly && codecov"
54+
"codecov": "nyc report --reporter lcovonly && codecov --disable=gcov"
5355
},
5456
"repository": {
5557
"type": "git",

scripts/deploy.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"use strict"
2+
3+
const { spawn } = require("child_process")
4+
const path = require("path")
5+
const fs = require("fs-extra")
6+
const GH_TOKEN = process.argv[2]
7+
const BUILD_ROOT = path.resolve(__dirname, "../docs/.vuepress/dist")
8+
const DEPLOY_ROOT = path.resolve(__dirname, "..")
9+
10+
/**
11+
* Execute a command.
12+
* @param {string} command The command to execute.
13+
* @returns {void}
14+
*/
15+
function exec(command) {
16+
console.log(`> ${command.replace(GH_TOKEN, "****")}`)
17+
return new Promise((resolve, reject) => {
18+
const cp = spawn(command, [], { shell: true, stdio: "inherit" })
19+
20+
cp.on("close", code => {
21+
if (code) {
22+
reject(new Error(`Exited with ${code}.`))
23+
} else {
24+
resolve()
25+
}
26+
})
27+
})
28+
}
29+
30+
//eslint-disable-next-line @mysticatea/node/no-unsupported-features/es-syntax
31+
;(async () => {
32+
// Checkout.
33+
await exec("git checkout gh-pages")
34+
35+
// Clean.
36+
for (const filename of await fs.readdir(DEPLOY_ROOT)) {
37+
const stat = await fs.stat(filename)
38+
if (!stat.isFile() || filename.startsWith(".")) {
39+
continue
40+
}
41+
42+
console.log(`> rm ${filename}`)
43+
await fs.unlink(filename)
44+
}
45+
46+
// Move.
47+
for (const filename of await fs.readdir(BUILD_ROOT)) {
48+
console.log(`> mv docs/.vuepress/dist/${filename} ${filename}`)
49+
await fs.rename(
50+
path.join(BUILD_ROOT, filename),
51+
path.join(DEPLOY_ROOT, filename)
52+
)
53+
}
54+
55+
// Commit.
56+
await exec("git add -A")
57+
let updated = false
58+
try {
59+
await exec('git commit -m "Update: website"')
60+
updated = true
61+
} catch (_error) {
62+
console.log("NO UPDATE")
63+
}
64+
65+
// Push.
66+
if (updated) {
67+
await exec(
68+
`git push https://mysticatea:${GH_TOKEN}@github.com/mysticatea/eslint-plugin-eslint-comments.git gh-pages:gh-pages`
69+
)
70+
}
71+
})().catch(error => {
72+
console.error(error.stack)
73+
process.exitCode = 1
74+
})

0 commit comments

Comments
 (0)