Skip to content

Commit a240c28

Browse files
reakaleektrentm
andauthored
Migrate Jenkinsfile to GH Actions Workflow (#132)
* Migrate Jenkinsfile to GH Actions Workflow * Retrigger CI * Fix indent * Fix workflow * Set fail-fast to false * Add cache * hm * Cache does not work without package-lock.json * Add newer versions * Revert "Add newer versions" This reverts commit ccfcc82. * Add newline at EOF * Update .github/workflows/test.yml * fix tests to work with node >=v17 where 'localhost' no longer prefers to resolve to 127.0.0.1 * Fix response headers in Node v19 Since v19 the connection=keep-alive header is set by default. See: https://nodejs.org/en/blog/announcements/v19-release-announce/#http-s-1-1-keepalive-by-default * Remove Jenkins related files * Refactor connection header * Fix formatting Co-authored-by: Trent Mick <[email protected]>
1 parent b7fa87c commit a240c28

File tree

7 files changed

+50
-181
lines changed

7 files changed

+50
-181
lines changed

.ci/Jenkinsfile

Lines changed: 0 additions & 97 deletions
This file was deleted.

.ci/jobs/defaults.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

.ci/jobs/ecs-logging-nodejs-mbp.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Test with multiple node versions.
2+
name: test
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
pull_request:
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
node-version: [10, 12, 14, 16, 18, 19]
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- name: Install dependencies
29+
run: .ci/run-install.sh
30+
- name: Test Node.js v${{ matrix.node-version }}
31+
run: .ci/run-test.sh

helpers/test/basic.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ test('bad ECS json on purpose: message type, ecs.version missing', t => {
100100

101101
test('formatHttpRequest and formatHttpResponse should return a valid ecs object', t => {
102102
const server = http.createServer(handler)
103-
server.listen(0, () => {
103+
server.listen(0, '127.0.0.1', () => {
104104
const body = JSON.stringify({ hello: 'world' })
105105
const req = http.request(
106-
`http://localhost:${server.address().port}/hello/world?foo=bar`,
106+
`http://127.0.0.1:${server.address().port}/hello/world?foo=bar`,
107107
{
108108
method: 'POST',
109109
body,
110110
headers: {
111111
'user-agent': 'cool-agent',
112+
connection: 'close',
112113
'content-type': 'application/json',
113114
'content-length': Buffer.byteLength(body)
114115
}
@@ -158,7 +159,7 @@ test('formatHttpRequest and formatHttpResponse should return a valid ecs object'
158159
t.same(line.url, {
159160
path: '/hello/world',
160161
query: 'foo=bar',
161-
full: `http://localhost:${server.address().port}/hello/world?foo=bar#anchor`,
162+
full: `http://127.0.0.1:${server.address().port}/hello/world?foo=bar#anchor`,
162163
fragment: 'anchor'
163164
})
164165
t.same(line.http, {
@@ -169,7 +170,7 @@ test('formatHttpRequest and formatHttpResponse should return a valid ecs object'
169170
'user-agent': 'cool-agent',
170171
'content-type': 'application/json',
171172
'content-length': '17',
172-
host: `localhost:${server.address().port}`,
173+
host: `127.0.0.1:${server.address().port}`,
173174
connection: 'close'
174175
},
175176
body: { bytes: 17 }
@@ -185,8 +186,7 @@ test('formatHttpRequest and formatHttpResponse should return a valid ecs object'
185186
})
186187
// https://www.elastic.co/guide/en/ecs/current/ecs-client.html fields
187188
t.ok(line.client, 'client fields are set')
188-
t.ok(line.client.address === '127.0.0.1' || line.client.address === '::ffff:127.0.0.1',
189-
'client.address is set')
189+
t.ok(line.client.address === '127.0.0.1', 'client.address is set')
190190
t.ok(line.client.ip === line.client.address,
191191
'client.address duplicated to client.ip')
192192
t.equal(typeof (line.client.port), 'number')

helpers/test/express.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ test('express res/req serialization', t => {
4646
t.same(rec.user_agent, { original: 'cool-agent' })
4747
t.same(rec.url, {
4848
path: '/',
49-
full: `http://localhost:${server.address().port}/`,
50-
domain: 'localhost'
49+
full: `http://127.0.0.1:${server.address().port}/`,
50+
domain: '127.0.0.1'
5151
})
5252
t.same(rec.http, {
5353
version: '1.1',
5454
request: {
5555
method: 'GET',
5656
headers: {
5757
'user-agent': 'cool-agent',
58-
host: `localhost:${server.address().port}`,
58+
host: `127.0.0.1:${server.address().port}`,
5959
connection: 'close'
6060
}
6161
},
@@ -69,19 +69,18 @@ test('express res/req serialization', t => {
6969
})
7070
// https://www.elastic.co/guide/en/ecs/current/ecs-client.html fields
7171
t.ok(rec.client, 'client fields are set')
72-
t.ok(rec.client.address === '127.0.0.1' || rec.client.address === '::ffff:127.0.0.1',
73-
'client.address is set')
72+
t.ok(rec.client.address === '127.0.0.1', 'client.address is set')
7473
t.ok(rec.client.ip === rec.client.address,
7574
'client.address duplicated to client.ip')
7675
t.equal(typeof (rec.client.port), 'number')
7776
})
7877

79-
app.listen(0, function () {
78+
app.listen(0, '127.0.0.1', function () {
8079
server = this
8180
const req = http.get(
82-
`http://localhost:${server.address().port}/`,
81+
`http://127.0.0.1:${server.address().port}/`,
8382
{
84-
headers: { 'user-agent': 'cool-agent' }
83+
headers: { 'user-agent': 'cool-agent', connection: 'close' }
8584
},
8685
function (res) {
8786
res.on('data', function () {})

helpers/test/hapi.test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const testOpts = {
3535

3636
test('hapi res/req serialization', testOpts, t => {
3737
const Hapi = require('@hapi/hapi')
38-
const server = Hapi.server({ host: 'localhost' })
38+
const server = Hapi.server({ host: '127.0.0.1' })
3939

4040
server.route({
4141
method: 'GET',
@@ -56,15 +56,15 @@ test('hapi res/req serialization', testOpts, t => {
5656
t.same(rec.user_agent, { original: 'cool-agent' })
5757
t.same(rec.url, {
5858
path: '/',
59-
full: `http://localhost:${server.info.port}/`
59+
full: `http://127.0.0.1:${server.info.port}/`
6060
})
6161
t.same(rec.http, {
6262
version: '1.1',
6363
request: {
6464
method: 'GET',
6565
headers: {
6666
'user-agent': 'cool-agent',
67-
host: `localhost:${server.info.port}`,
67+
host: `127.0.0.1:${server.info.port}`,
6868
connection: 'close'
6969
}
7070
},
@@ -84,8 +84,7 @@ test('hapi res/req serialization', testOpts, t => {
8484
})
8585
// https://www.elastic.co/guide/en/ecs/current/ecs-client.html fields
8686
t.ok(rec.client, 'client fields are set')
87-
t.ok(rec.client.address === '127.0.0.1' || rec.client.address === '::ffff:127.0.0.1',
88-
'client.address is set')
87+
t.ok(rec.client.address === '127.0.0.1', 'client.address is set')
8988
t.ok(rec.client.ip === rec.client.address,
9089
'client.address duplicated to client.ip')
9190
t.equal(typeof (rec.client.port), 'number')
@@ -99,8 +98,8 @@ test('hapi res/req serialization', testOpts, t => {
9998
t.comment('hapi server running on %s', server.info.uri)
10099

101100
// Make a request so we trigger a 'response' event above.
102-
const req = http.get(`http://localhost:${server.info.port}/`,
103-
{ headers: { 'user-agent': 'cool-agent' } })
101+
const req = http.get(`http://127.0.0.1:${server.info.port}/`,
102+
{ headers: { 'user-agent': 'cool-agent', connection: 'close' } })
104103
req.on('error', t.ifErr)
105104
})
106105
})

0 commit comments

Comments
 (0)