Skip to content

Commit bd836b7

Browse files
committed
ci, update tests, pass with bash 5.2
1 parent 965f939 commit bd836b7

10 files changed

+157
-50
lines changed

.github/.github/FUNDING.yml

-3
This file was deleted.

.github/workflows/ci.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
node-version: [12.x, 14.x, 16.x, 17.x]
10+
platform:
11+
- os: ubuntu-latest
12+
shell: bash
13+
- os: macos-latest
14+
shell: bash
15+
- os: windows-latest
16+
shell: bash
17+
- os: windows-latest
18+
shell: powershell
19+
fail-fast: false
20+
21+
runs-on: ${{ matrix.platform.os }}
22+
defaults:
23+
run:
24+
shell: ${{ matrix.platform.shell }}
25+
26+
steps:
27+
- name: Checkout Repository
28+
uses: actions/[email protected]
29+
30+
- name: Use Nodejs ${{ matrix.node-version }}
31+
uses: actions/setup-node@v1
32+
with:
33+
node-version: ${{ matrix.node-version }}
34+
35+
- name: Install dependencies
36+
run: npm install
37+
38+
- name: Run Tests
39+
run: npm test -- -c -t0
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
git config --global user.email "$1"
3+
shift
4+
git config --global user.name "$1"
5+
shift
6+
message="$1"
7+
shift
8+
if [ $(git status --porcelain "$@" | egrep '^ M' | wc -l) -gt 0 ]; then
9+
git add "$@"
10+
git commit -m "$message"
11+
git push || git pull --rebase
12+
git push
13+
fi

.github/workflows/copyright-year.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
dir=${1:-$PWD}
3+
dates=($(git log --date=format:%Y --pretty=format:'%ad' --reverse | sort | uniq))
4+
if [ "${#dates[@]}" -eq 1 ]; then
5+
datestr="${dates}"
6+
else
7+
datestr="${dates}-${dates[${#dates[@]}-1]}"
8+
fi
9+
10+
stripDate='s/^((.*)Copyright\b(.*?))((?:,\s*)?(([0-9]{4}\s*-\s*[0-9]{4})|(([0-9]{4},\s*)*[0-9]{4})))(?:,)?\s*(.*)\n$/$1$9\n/g'
11+
addDate='s/^.*Copyright(?:\s*\(c\))? /Copyright \(c\) '$datestr' /g'
12+
for l in $dir/LICENSE*; do
13+
perl -pi -e "$stripDate" $l
14+
perl -pi -e "$addDate" $l
15+
done

.github/workflows/isaacs-makework.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "various tidying up tasks to silence nagging"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
makework:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: Use Node.js
17+
uses: actions/[email protected]
18+
with:
19+
node-version: 16.x
20+
- name: put repo in package.json
21+
run: node .github/workflows/package-json-repo.js
22+
- name: check in package.json if modified
23+
run: |
24+
bash -x .github/workflows/commit-if-modified.sh \
25+
26+
"package.json Repo Bot" \
27+
"chore: add repo to package.json" \
28+
package.json package-lock.json
29+
- name: put all dates in license copyright line
30+
run: bash .github/workflows/copyright-year.sh
31+
- name: check in licenses if modified
32+
run: |
33+
bash .github/workflows/commit-if-modified.sh \
34+
35+
"License Year Bot" \
36+
"chore: add copyright year to license" \
37+
LICENSE*
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env node
2+
3+
const pf = require.resolve(`${process.cwd()}/package.json`)
4+
const pj = require(pf)
5+
6+
if (!pj.repository && process.env.GITHUB_REPOSITORY) {
7+
const fs = require('fs')
8+
const server = process.env.GITHUB_SERVER_URL || 'https://github.com'
9+
const repo = `${server}/${process.env.GITHUB_REPOSITORY}`
10+
pj.repository = repo
11+
const json = fs.readFileSync(pf, 'utf8')
12+
const match = json.match(/^\s*\{[\r\n]+([ \t]*)"/)
13+
const indent = match[1]
14+
const output = JSON.stringify(pj, null, indent || 2) + '\n'
15+
fs.writeFileSync(pf, output)
16+
}

.travis.yml

-14
This file was deleted.

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
"tap": {
3535
"before": "test/00-setup.js",
3636
"after": "test/zz-cleanup.js",
37+
"statements": 90,
38+
"branches": 90,
39+
"functions": 90,
40+
"lines": 90,
3741
"jobs": 1
3842
},
3943
"scripts": {

test/00-setup.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ var globs =
9292
,"a/**/[cg]/../[cg]"
9393
,"a/{b,c,d,e,f}/**/g"
9494
,"a/b/**"
95-
,"**/g"
95+
,"./**/g"
9696
,"a/abc{fed,def}/g/h"
9797
,"a/abc{fed/g,def}/**/"
9898
,"a/abc{fed/g,def}/**///**/"
99-
,"**/a/**/"
99+
,"./**/a/**/"
100100
,"+(a|b|c)/a{/,bc*}/**"
101101
,"*/*/*/f"
102-
,"**/f"
102+
,"./**/f"
103103
,"a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**"
104104
,"{./*/*,/tmp/glob-test/*}"
105105
,"{/tmp/glob-test/*,*}" // evil owl face! how you taunt me!

test/bash-results.json

+30-30
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"a/b/c",
1717
"a/b/c/d"
1818
],
19-
"**/g": [
20-
"a/abcdef/g",
21-
"a/abcfed/g"
19+
"./**/g": [
20+
"./a/abcdef/g",
21+
"./a/abcfed/g"
2222
],
2323
"a/abc{fed,def}/g/h": [
2424
"a/abcdef/g/h",
@@ -34,30 +34,30 @@
3434
"a/abcdef/g",
3535
"a/abcfed/g"
3636
],
37-
"**/a/**/": [
38-
"a",
39-
"a/abcdef",
40-
"a/abcdef/g",
41-
"a/abcfed",
42-
"a/abcfed/g",
43-
"a/b",
44-
"a/b/c",
45-
"a/bc",
46-
"a/bc/e",
47-
"a/c",
48-
"a/c/d",
49-
"a/c/d/c",
50-
"a/cb",
51-
"a/cb/e",
52-
"a/symlink",
53-
"a/symlink/a",
54-
"a/symlink/a/b",
55-
"a/symlink/a/b/c",
56-
"a/symlink/a/b/c/a",
57-
"a/symlink/a/b/c/a/b",
58-
"a/symlink/a/b/c/a/b/c",
59-
"a/x",
60-
"a/z"
37+
"./**/a/**/": [
38+
"./a",
39+
"./a/abcdef",
40+
"./a/abcdef/g",
41+
"./a/abcfed",
42+
"./a/abcfed/g",
43+
"./a/b",
44+
"./a/b/c",
45+
"./a/bc",
46+
"./a/bc/e",
47+
"./a/c",
48+
"./a/c/d",
49+
"./a/c/d/c",
50+
"./a/cb",
51+
"./a/cb/e",
52+
"./a/symlink",
53+
"./a/symlink/a",
54+
"./a/symlink/a/b",
55+
"./a/symlink/a/b/c",
56+
"./a/symlink/a/b/c/a",
57+
"./a/symlink/a/b/c/a/b",
58+
"./a/symlink/a/b/c/a/b/c",
59+
"./a/x",
60+
"./a/z"
6161
],
6262
"+(a|b|c)/a{/,bc*}/**": [
6363
"a/abcdef",
@@ -71,9 +71,9 @@
7171
"a/bc/e/f",
7272
"a/cb/e/f"
7373
],
74-
"**/f": [
75-
"a/bc/e/f",
76-
"a/cb/e/f"
74+
"./**/f": [
75+
"./a/bc/e/f",
76+
"./a/cb/e/f"
7777
],
7878
"a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**": [
7979
"a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",

0 commit comments

Comments
 (0)