Skip to content

Commit

Permalink
chore: separate 'lint' from 'test'
Browse files Browse the repository at this point in the history
Also test with node v20 instead of v19.
  • Loading branch information
trentm committed Oct 13, 2023
1 parent 2a6ea19 commit fcfd8c8
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 19 deletions.
1 change: 1 addition & 0 deletions .ci/run-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function run_install {
npm --prefix $ROOT/$1 install
}

run_install "utils"
run_install "helpers"
run_install "loggers/winston"
run_install "loggers/morgan"
Expand Down
15 changes: 15 additions & 0 deletions .ci/run-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -euxo pipefail
ROOT=$PWD

function run_lint {
echo "=== Running $1 lint ==="
npm --prefix $ROOT/$1 run lint
}

run_lint "utils"
run_lint "helpers"
run_lint "loggers/winston"
run_lint "loggers/morgan"
run_lint "loggers/pino"
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: .ci/run-install.sh
- run: .ci/run-lint.sh

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [10, 12, 14, 16, 18, 19]
node-version: [10, 12, 14, 16, 18, 20]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@ clean:
(cd loggers/pino && rm -rf node_modules)
(cd utils && rm -rf node_modules)

.PHONY: check
check: check-license-headers
(cd helpers && npx standard)
(cd loggers/winston && npx standard)
(cd loggers/morgan && npx standard)
(cd loggers/pino && npx standard)
(cd utils && npx standard)
.PHONY: lint
lint: check-license-headers
./.ci/run-lint.sh

.PHONY: fmt
fmt:
(cd helpers && npx standard --fix)
(cd loggers/winston && npx standard --fix)
(cd loggers/morgan && npx standard --fix)
(cd loggers/pino && npx standard --fix)
(cd utils && npx standard --fix)
(cd helpers && npm run lint:fix)
(cd loggers/winston && npm run lint:fix)
(cd loggers/morgan && npm run lint:fix)
(cd loggers/pino && npm run lint:fix)
(cd utils && npm run lint:fix)

.PHONY: test
test:
Expand Down
4 changes: 3 additions & 1 deletion helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
},
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/main/helpers/README.md",
"scripts": {
"test": "standard && tap --no-check-coverage --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
"lint": "standard",
"lint:fix": "standard --fix",
"test": "tap --no-check-coverage --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
},
"engines": {
"node": ">=10"
Expand Down
4 changes: 3 additions & 1 deletion loggers/morgan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
},
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/main/loggers/morgan/README.md",
"scripts": {
"test": "standard && tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
"lint": "standard",
"lint:fix": "standard --fix",
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
},
"engines": {
"node": ">=10"
Expand Down
4 changes: 3 additions & 1 deletion loggers/pino/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
},
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/main/loggers/pino/README.md",
"scripts": {
"test": "standard && tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
"lint": "standard",
"lint:fix": "standard --fix",
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
},
"engines": {
"node": ">=10"
Expand Down
4 changes: 3 additions & 1 deletion loggers/winston/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/main/loggers/winston/README.md",
"scripts": {
"bench": "./benchmarks/bench",
"test": "standard && tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
"lint": "standard",
"lint:fix": "standard --fix",
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
},
"engines": {
"node": ">=10"
Expand Down
3 changes: 2 additions & 1 deletion utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"author": "Tomas Della Vedova",
"license": "Apache-2.0",
"scripts": {
"check": "standard"
"lint": "standard",
"lint:fix": "standard --fix"
},
"devDependencies": {
"js-yaml": "^3.13.1",
Expand Down
2 changes: 1 addition & 1 deletion utils/pre-commit-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
set -o errexit
set -o pipefail

make check
make lint

0 comments on commit fcfd8c8

Please sign in to comment.