Skip to content
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

Add Windows to test matrix, update action versions #147

Merged
merged 7 commits into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build and Deploy docs

on:
on:
push:
branches:
- main
Expand All @@ -21,9 +21,9 @@ jobs:
TX_TOKEN: ${{ secrets.TX_TOKEN }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.9

Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
touch ./build/html/.nojekyll

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.7
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
branch: gh-pages # The branch the action should deploy to.
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand All @@ -34,9 +35,9 @@ jobs:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Check and restore cache of playwright
Expand All @@ -61,9 +62,9 @@ jobs:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
tag_name: 'v%s'
node-version: '14.x'
Expand Down
329 changes: 136 additions & 193 deletions docs/Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "tsc -p .",
"watch": "tsc -w",
"lint": "eslint --fix .",
"test": "npm run build && mocha -r ts-node/register test/*.ts",
"test": "npm run build && mocha --timeout 5000 -r ts-node/register test/*.ts",
"test:watch": "npm test -- --watch --watch-files src/**/*.ts --watch-files test/**/*.ts",
"test:e2e": "npx playwright test",
"command": "./node_modules/.bin/ts-node ./src/cli.ts"
Expand Down
4 changes: 2 additions & 2 deletions test/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe('Test for the `build.ts`.', () => {

const fixtureStyleJson = path.join(__dirname, 'data/style.json')
assert.equal(
fs.readFileSync(styleJson, 'utf-8'),
fs.readFileSync(fixtureStyleJson, 'utf-8'),
fs.readFileSync(styleJson, 'utf-8').replace(/\r\n/gm, '\n'),
fs.readFileSync(fixtureStyleJson, 'utf-8').replace(/\r\n/gm, '\n'),
)
})

Expand Down
16 changes: 8 additions & 8 deletions test/command.serve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe('Test for `charites serve`', () => {
await sleep(500)
await Promise.all([
(async () => {
const res = await axios('http://localhost:8080/style.json', {})
const res = await axios('http://127.0.0.1:8080/style.json', {})
expect(res.data.version).to.equal(8)
})(),
(async () => {
await axios('http://localhost:8080/sprite.json', {
await axios('http://127.0.0.1:8080/sprite.json', {
validateStatus: (status) => status === 404,
})
})(),
Expand Down Expand Up @@ -67,28 +67,28 @@ describe('Test for `charites serve`', () => {
await sleep(500)
await Promise.all([
(async () => {
const res = await axios('http://localhost:8080/style.json', {})
const res = await axios('http://127.0.0.1:8080/style.json', {})
expect(res.status).to.equal(200)
expect(res.data.version).to.equal(8)
expect(res.data.sprite).to.equal('http://localhost:8080/sprite')
expect(res.data.sprite).to.equal('http://127.0.0.1:8080/sprite')
})(),
(async () => {
const res = await axios('http://localhost:8080/sprite.json', {})
const res = await axios('http://127.0.0.1:8080/sprite.json', {})
expect(res.status).to.equal(200)
expect(Object.entries(res.data).length).to.be.greaterThan(0)
})(),
(async () => {
const res = await axios('http://localhost:8080/sprite@2x.json', {})
const res = await axios('http://127.0.0.1:8080/sprite@2x.json', {})
expect(res.status).to.equal(200)
expect(Object.entries(res.data).length).to.be.greaterThan(0)
})(),
(async () => {
const res = await axios('http://localhost:8080/sprite.png', {})
const res = await axios('http://127.0.0.1:8080/sprite.png', {})
expect(res.status).to.equal(200)
expect(res.data.length).to.be.greaterThan(0)
})(),
(async () => {
const res = await axios('http://localhost:8080/sprite@2x.png', {})
const res = await axios('http://127.0.0.1:8080/sprite@2x.png', {})
expect(res.status).to.equal(200)
expect(res.data.length).to.be.greaterThan(0)
})(),
Expand Down
12 changes: 7 additions & 5 deletions test/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ describe('Test for the `init.ts`.', () => {
assert.deepEqual(true, !!fs.statSync(styleYaml))
// the file should be the same with init_tilejson.yml
assert.deepEqual(
fs.readFileSync(styleYaml, 'utf8'),
fs.readFileSync(
path.join(__dirname, 'data/init/tilejson/init_decomposite.yml'),
'utf-8',
),
fs.readFileSync(styleYaml, 'utf8').replace(/\r\n/gm, '\n'),
fs
.readFileSync(
path.join(__dirname, 'data/init/tilejson/init_decomposite.yml'),
'utf-8',
)
.replace(/\r\n/gm, '\n'),
)
assert.deepEqual(
YAML.load(
Expand Down
2 changes: 1 addition & 1 deletion test/util/charitesCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import path from 'path'

export const charitesCliJs = path.join(__dirname, '..', '..', 'dist', 'cli.js')

export default `${process.execPath} ${charitesCliJs}`
export default `"${process.execPath}" "${charitesCliJs}"`
8 changes: 7 additions & 1 deletion test/util/execPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const abortableExecFile = (
new Promise<ExecResult>((resolve, reject) => {
const temp = cwd ? cwd : makeTempDir()

// Because Windows can't catch the SIGINT signal (it doesn't have signals)
// we set a flag in the parent whether the command can die or not.
// If the command exits before we request it to exit, the error will be
// thrown, but if it exits after we request it to exit, it won't be an error.
let noErrorOnDie = false
const process = child_process.execFile(
file,
args,
Expand All @@ -46,13 +51,14 @@ export const abortableExecFile = (
cwd: temp,
},
(error, stdout, stderr) => {
if (error) {
if (error && noErrorOnDie !== true) {
return reject(error)
}
resolve({ stdout, stderr, cwd: temp })
},
)
signal.addEventListener('abort', () => {
noErrorOnDie = true
process.kill('SIGINT')
})
})