Skip to content

Commit

Permalink
ci, update tests, pass with bash 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 27, 2022
1 parent 965f939 commit bd836b7
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 50 deletions.
3 changes: 0 additions & 3 deletions .github/.github/FUNDING.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x]
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: bash
- os: windows-latest
shell: powershell
fail-fast: false

runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}

steps:
- name: Checkout Repository
uses: actions/[email protected]

- name: Use Nodejs ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Run Tests
run: npm test -- -c -t0
13 changes: 13 additions & 0 deletions .github/workflows/commit-if-modified.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
git config --global user.email "$1"
shift
git config --global user.name "$1"
shift
message="$1"
shift
if [ $(git status --porcelain "$@" | egrep '^ M' | wc -l) -gt 0 ]; then
git add "$@"
git commit -m "$message"
git push || git pull --rebase
git push
fi
15 changes: 15 additions & 0 deletions .github/workflows/copyright-year.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
dir=${1:-$PWD}
dates=($(git log --date=format:%Y --pretty=format:'%ad' --reverse | sort | uniq))
if [ "${#dates[@]}" -eq 1 ]; then
datestr="${dates}"
else
datestr="${dates}-${dates[${#dates[@]}-1]}"
fi

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'
addDate='s/^.*Copyright(?:\s*\(c\))? /Copyright \(c\) '$datestr' /g'
for l in $dir/LICENSE*; do
perl -pi -e "$stripDate" $l
perl -pi -e "$addDate" $l
done
37 changes: 37 additions & 0 deletions .github/workflows/isaacs-makework.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "various tidying up tasks to silence nagging"

on:
push:
branches:
- main
workflow_dispatch:

jobs:
makework:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 16.x
- name: put repo in package.json
run: node .github/workflows/package-json-repo.js
- name: check in package.json if modified
run: |
bash -x .github/workflows/commit-if-modified.sh \
"[email protected]" \
"package.json Repo Bot" \
"chore: add repo to package.json" \
package.json package-lock.json
- name: put all dates in license copyright line
run: bash .github/workflows/copyright-year.sh
- name: check in licenses if modified
run: |
bash .github/workflows/commit-if-modified.sh \
"[email protected]" \
"License Year Bot" \
"chore: add copyright year to license" \
LICENSE*
16 changes: 16 additions & 0 deletions .github/workflows/package-json-repo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node

const pf = require.resolve(`${process.cwd()}/package.json`)
const pj = require(pf)

if (!pj.repository && process.env.GITHUB_REPOSITORY) {
const fs = require('fs')
const server = process.env.GITHUB_SERVER_URL || 'https://github.com'
const repo = `${server}/${process.env.GITHUB_REPOSITORY}`
pj.repository = repo
const json = fs.readFileSync(pf, 'utf8')
const match = json.match(/^\s*\{[\r\n]+([ \t]*)"/)
const indent = match[1]
const output = JSON.stringify(pj, null, indent || 2) + '\n'
fs.writeFileSync(pf, output)
}
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"tap": {
"before": "test/00-setup.js",
"after": "test/zz-cleanup.js",
"statements": 90,
"branches": 90,
"functions": 90,
"lines": 90,
"jobs": 1
},
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions test/00-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ var globs =
,"a/**/[cg]/../[cg]"
,"a/{b,c,d,e,f}/**/g"
,"a/b/**"
,"**/g"
,"./**/g"
,"a/abc{fed,def}/g/h"
,"a/abc{fed/g,def}/**/"
,"a/abc{fed/g,def}/**///**/"
,"**/a/**/"
,"./**/a/**/"
,"+(a|b|c)/a{/,bc*}/**"
,"*/*/*/f"
,"**/f"
,"./**/f"
,"a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**"
,"{./*/*,/tmp/glob-test/*}"
,"{/tmp/glob-test/*,*}" // evil owl face! how you taunt me!
Expand Down
60 changes: 30 additions & 30 deletions test/bash-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"a/b/c",
"a/b/c/d"
],
"**/g": [
"a/abcdef/g",
"a/abcfed/g"
"./**/g": [
"./a/abcdef/g",
"./a/abcfed/g"
],
"a/abc{fed,def}/g/h": [
"a/abcdef/g/h",
Expand All @@ -34,30 +34,30 @@
"a/abcdef/g",
"a/abcfed/g"
],
"**/a/**/": [
"a",
"a/abcdef",
"a/abcdef/g",
"a/abcfed",
"a/abcfed/g",
"a/b",
"a/b/c",
"a/bc",
"a/bc/e",
"a/c",
"a/c/d",
"a/c/d/c",
"a/cb",
"a/cb/e",
"a/symlink",
"a/symlink/a",
"a/symlink/a/b",
"a/symlink/a/b/c",
"a/symlink/a/b/c/a",
"a/symlink/a/b/c/a/b",
"a/symlink/a/b/c/a/b/c",
"a/x",
"a/z"
"./**/a/**/": [
"./a",
"./a/abcdef",
"./a/abcdef/g",
"./a/abcfed",
"./a/abcfed/g",
"./a/b",
"./a/b/c",
"./a/bc",
"./a/bc/e",
"./a/c",
"./a/c/d",
"./a/c/d/c",
"./a/cb",
"./a/cb/e",
"./a/symlink",
"./a/symlink/a",
"./a/symlink/a/b",
"./a/symlink/a/b/c",
"./a/symlink/a/b/c/a",
"./a/symlink/a/b/c/a/b",
"./a/symlink/a/b/c/a/b/c",
"./a/x",
"./a/z"
],
"+(a|b|c)/a{/,bc*}/**": [
"a/abcdef",
Expand All @@ -71,9 +71,9 @@
"a/bc/e/f",
"a/cb/e/f"
],
"**/f": [
"a/bc/e/f",
"a/cb/e/f"
"./**/f": [
"./a/bc/e/f",
"./a/cb/e/f"
],
"a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**": [
"a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
Expand Down

0 comments on commit bd836b7

Please sign in to comment.