Skip to content

Commit e9bf169

Browse files
committed
test: add TAV tests for pino and winston supported versions
We support pino@6, pino@7, pino@8, and winston@3. Refs: #131 Refs: #115
1 parent 2a6be30 commit e9bf169

File tree

8 files changed

+72
-5
lines changed

8 files changed

+72
-5
lines changed

.github/workflows/tav.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## TAV (test-all-versions) tests to test with multiple versions of deps.
2+
name: tav
3+
4+
on:
5+
workflow_dispatch: ~
6+
schedule:
7+
# Weekly on Monday, 16:00 UTC, so hopefully near my PST morning.
8+
- cron: '0 16 * * 1'
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
tav:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
node-version: [10, 12, 14, 16, 18, 20]
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
- name: Update npm to at least v7 for workspaces support
26+
if: ${{ matrix.node-version < 16 }} # node@16 comes with npm@8, node@14 with npm@6
27+
run: npm install -g npm@7 # npm@7 supports node >=10
28+
- name: Install dependencies
29+
run: utils/run-install.sh
30+
- name: TAV Node.js v${{ matrix.node-version }}
31+
run: npm --workspaces run --if-present tav

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
push:
66
branches:
77
- main
8-
tags:
98
pull_request:
109
branches:
1110
- main

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ all:
1616
test:
1717
./utils/run-test.sh
1818

19+
.PHONY: tav
20+
tav:
21+
npm --workspaces run --if-present tav # requires npm>=7 (aka node>=16)
22+
1923
.PHONY: lint
2024
lint: check-license-headers
2125
./utils/run-lint.sh

packages/ecs-pino-format/.tav.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ideally we'd test all pino releases, but that is too many to justify the
2+
# compute time -- so we test a subset.
3+
pino:
4+
- versions: '6.0.0 || ^6.14.0'
5+
# versions: '^6.0.0'
6+
node: '>=10 <17'
7+
commands: 'npm test'
8+
- versions: '7.0.0 || ^7.11.0'
9+
# versions: '^7.0.0'
10+
node: '>=12 <18'
11+
commands: 'npm test'
12+
- versions: '8.0.0 || >=8.16.1'
13+
# versions: '>=8.0.0'
14+
node: '>=14'
15+
commands: 'npm test'

packages/ecs-pino-format/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"scripts": {
3333
"lint": "standard",
3434
"lint:fix": "standard --fix",
35-
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
35+
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js",
36+
"tav": "tav --quiet"
3637
},
3738
"engines": {
3839
"node": ">=10"
@@ -48,8 +49,10 @@
4849
"express": "^4.17.1",
4950
"pino": "^6.0.0",
5051
"pino-http": "^5.3.0",
52+
"semver": "^7.5.4",
5153
"split2": "^3.1.1",
5254
"standard": "16.x",
53-
"tap": "^15.0.10"
55+
"tap": "^15.0.10",
56+
"test-all-versions": "^5.0.1"
5457
}
5558
}

packages/ecs-pino-format/test/basic.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const os = require('os')
2525
const addFormats = require('ajv-formats').default
2626
const Ajv = require('ajv').default
2727
const pino = require('pino')
28+
const semver = require('semver')
2829
const split = require('split2')
2930
const test = require('tap').test
3031
const ecsVersion = require('@elastic/ecs-helpers').version
@@ -319,6 +320,12 @@ test('can handle circular refs', t => {
319320

320321
const rec = JSON.parse(lines[0])
321322
t.ok(validate(rec))
322-
t.strictSame(rec.obj, { foo: 'bar', self: '[Circular]' })
323+
if (semver.satisfies(pino.version, '>=7.0.0 <7.1.0')) {
324+
// For some versions pino used json-stringify-safe with a slightly different
325+
// serialization for circular refs.
326+
t.strictSame(rec.obj, { foo: 'bar', self: '[Circular ~]' })
327+
} else {
328+
t.strictSame(rec.obj, { foo: 'bar', self: '[Circular]' })
329+
}
323330
t.end()
324331
})

packages/ecs-winston-format/.tav.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
winston:
2+
- versions: '>=3.0.0 <3.6.0'
3+
node: '>=6.4.0'
4+
commands: 'npm test'
5+
- versions: '>=3.6.0'
6+
node: '>=12'
7+
commands: 'npm test'

packages/ecs-winston-format/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"bench": "./benchmarks/bench",
3434
"lint": "standard",
3535
"lint:fix": "standard --fix",
36-
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
36+
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js",
37+
"tav": "tav --quiet"
3738
},
3839
"engines": {
3940
"node": ">=10"

0 commit comments

Comments
 (0)