Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge next into master #125

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 5 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ name: CI

on:
push:
branches:
- main
- master
- next
- 'v*'
paths-ignore:
- 'docs/**'
- '*.md'
Expand All @@ -16,83 +11,11 @@ on:
- '*.md'

jobs:
dependency-review:
name: Dependency Review
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Dependency review
uses: actions/dependency-review-action@v4

linter:
name: Lint Code
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install dependencies
run: npm i --ignore-scripts

- name: Lint code
run: npm run lint

test:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
node-version: [14, 16, 18, 20]
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Start Kafka-instance
run: |
docker-compose up -d

- name: Install dependencies
run: npm i

- name: Run tests
run: npm test

automerge:
name: Automerge Dependabot PRs
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.user.login == 'dependabot[bot]'
needs: test
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- uses: fastify/github-action-merge-dependabot@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
target: major
pull-requests: write
uses: fastify/workflows/.github/workflows/[email protected]
with:
license-check: true
lint: true
3 changes: 1 addition & 2 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
check-coverage: false

disable-coverage: true
files:
- test/**/*.test.js
21 changes: 0 additions & 21 deletions docker-compose.yml

This file was deleted.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"node-rdkafka": "3.0.1"
},
"devDependencies": {
"@types/node": "^20.1.4",
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^20.14.9",
"abstract-logging": "2.0.1",
"fastify": "^5.0.0-alpha.3",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.31.0"
"standard": "^17.1.0",
"tap": "^20.0.3",
"tsd": "^0.31.1"
},
"tsd": {
"directory": "test"
Expand Down
6 changes: 4 additions & 2 deletions test/communication.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ test('communication', t => {
const producerFastify = Fastify({ logger: true })
const consumerFastify = Fastify({ logger: true })

t.teardown(() => producerFastify.close())
t.teardown(() => consumerFastify.close())
t.after(() => {
producerFastify.close()
consumerFastify.close()
})

consumerFastify
.register(fastifyKafka, { ...options, producer: undefined })
Expand Down
6 changes: 4 additions & 2 deletions test/consume-callback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ test('consume callback', t => {
const producerFastify = Fastify()
const consumerFastify = Fastify()

t.teardown(() => producerFastify.close())
t.teardown(() => consumerFastify.close())
t.after(() => {
producerFastify.close()
consumerFastify.close()
})

consumerFastify
.register(fastifyKafka, { ...options, producer: undefined })
Expand Down
20 changes: 15 additions & 5 deletions test/consumer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ test('unreachable brokers', t => {
const consumer = new Consumer(options, log, (err) => {
t.ok(err)
}, {}, { timeout: 200 })
consumer.on('ready', t.error)
consumer.on('ready', (e) => {
t.error(e)
})
})

test('error event before connection', t => {
Expand All @@ -35,8 +37,12 @@ test('error event after connection', t => {
t.error(err)
consumer.consumer.emit('event.error', new Error('Test Error'))
})
consumer.on('error', t.ok)
t.teardown(() => consumer.stop())
consumer.on('error', (s) => {
t.ok(s)
})
t.after(() => {
consumer.stop()
})
})

test('empty message with data event', t => {
Expand All @@ -46,6 +52,10 @@ test('empty message with data event', t => {
t.error(err)
t.throws(() => consumer.consumer.emit('data'))
})
consumer.on('error', t.ok)
t.teardown(() => consumer.stop())
consumer.on('error', (s) => {
t.ok(s)
})
t.after(() => {
consumer.stop()
})
})
18 changes: 13 additions & 5 deletions test/multiple-topics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ test('multiple topics', t => {
const producerFastify = Fastify()
const consumerFastify = Fastify()

t.teardown(() => producerFastify.close())
t.teardown(() => consumerFastify.close())

consumerFastify
.register(fastifyKafka, { ...options, producer: undefined })
.after(err => {
t.error(err)

consumerFastify.kafka.consumer.on('error', t.fail)
consumerFastify.kafka.consumer.on('error', () => {
t.fail()
})
consumerFastify.kafka.subscribe([topicName1, topicName2])

consumerFastify.kafka.on(topicName1, (msg, commit) => {
Expand All @@ -48,7 +47,9 @@ test('multiple topics', t => {
.after(err => {
t.error(err)

producerFastify.kafka.producer.on('error', t.fail)
producerFastify.kafka.producer.on('error', () => {
t.fail()
})
producerFastify.kafka.push({
topic: topicName1,
payload: 'topic1',
Expand All @@ -70,4 +71,11 @@ test('multiple topics', t => {
t.error(err)
})
})

t.after(() => {
producerFastify.kafka.producer.stop()
consumerFastify.kafka.consumer.stop()
producerFastify.close()
consumerFastify.close()
})
})
15 changes: 10 additions & 5 deletions test/producer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const options = {
}

test('unreachable brokers', t => {
t.plan(2)
t.plan(1)
const producer = new Producer(options, log, (err) => {
t.ok(err)
producer.on('error', t.ok)
producer.push()
}, {}, { timeout: 200 })
producer.on('ready', (e) => {
t.error(e)
})
})

test('error event before connection', t => {
Expand All @@ -35,11 +36,15 @@ test('error event after connection', t => {
t.error(err)
producer.producer.emit('event.error', new Error('Test Error'))
})
producer.on('error', t.ok)
producer.on('error', (e) => {
t.ok(e)
})
producer.push({
topic: 'test',
payload: 'hello world!',
key: 'testKey'
})
t.teardown(() => producer.stop())
t.after(() => {
producer.stop()
})
})