Skip to content

Commit 4a42e16

Browse files
authored
feat: Updated to Watt 3. (#420)
* feat: Updated to Watt 3. Signed-off-by: Paolo Insogna <paolo@cowtech.it> * chore: Added release flow. Signed-off-by: Paolo Insogna <paolo@cowtech.it> * fixup Signed-off-by: Paolo Insogna <paolo@cowtech.it> * fixup Signed-off-by: Paolo Insogna <paolo@cowtech.it> --------- Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent f3de530 commit 4a42e16

24 files changed

+8041
-10229
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,37 @@
1-
name: ci
2-
3-
on:
4-
push:
5-
paths-ignore:
6-
- 'docs/**'
7-
- '*.md'
8-
pull_request:
9-
paths-ignore:
10-
- 'docs/**'
11-
- '*.md'
12-
1+
---
2+
name: Run Tests
3+
on: [push, pull_request, workflow_dispatch]
134
jobs:
14-
test:
15-
runs-on: ubuntu-latest
16-
5+
ci:
176
strategy:
187
matrix:
19-
node-version: [20.x]
20-
8+
node-version: [22, 24]
9+
os: [ubuntu-latest]
10+
runs-on: ${{matrix.os}}
11+
timeout-minutes: 20
2112
services:
2213
rabbitmq:
2314
image: rabbitmq:latest
2415
ports:
2516
- 5672:5672
2617
- 15672:15672
27-
2818
steps:
29-
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
30-
31-
- name: Use Node.js
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Use supported Node.js Version
3222
uses: actions/setup-node@v4
3323
with:
3424
node-version: ${{ matrix.node-version }}
35-
36-
- name: Install
37-
run: |
38-
npm install
39-
40-
- name: Run tests
41-
run: |
42-
npm run test
25+
- name: Restore cached dependencies
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.pnpm-store
29+
key: node-modules-${{ hashFiles('package.json') }}
30+
- name: Setup pnpm
31+
uses: pnpm/action-setup@v4
32+
with:
33+
version: latest
34+
- name: Install dependencies
35+
run: pnpm install --frozen-lockfile
36+
- name: Run Tests
37+
run: pnpm run ci
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The version number to tag and release'
8+
required: true
9+
type: string
10+
prerelease:
11+
description: 'Release as pre-release'
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
jobs:
17+
release-npm:
18+
runs-on: ubuntu-latest
19+
environment: main
20+
permissions:
21+
contents: write
22+
id-token: write
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
- name: Use supported Node.js Version
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 22
30+
- name: Restore cached dependencies
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.pnpm-store
34+
key: node-modules-${{ hashFiles('package.json') }}
35+
- name: Setup pnpm
36+
uses: pnpm/action-setup@v4
37+
with:
38+
version: latest
39+
- name: Install dependencies
40+
run: pnpm install --frozen-lockfile
41+
- name: Bump version and push commit
42+
run: |
43+
pnpm version ${{ inputs.version }} --no-git-tag-version
44+
git config --global user.name "${{ github.actor }}"
45+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
46+
git commit -a -m "Bumped v${{ inputs.version }}"
47+
git push origin HEAD:${{ github.ref }}
48+
- name: Publish new version
49+
run: |
50+
npm install npm -g
51+
npm publish --access public --tag ${{ inputs.prerelease == true && 'next' || 'latest' }}
52+
- name: Create release notes
53+
run: |
54+
npx @matteo.collina/release-notes -a ${{ secrets.GITHUB_TOKEN }} -t v${{ inputs.version }} -r ${{ github.repository }} ${{ github.event.inputs.prerelease == 'true' && '-p' || '' }} -c ${{ github.ref }}

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@ Then you can:
88
- Publish messages to an exchange from a HTTP endpoint with a `POST` on `/publish` endpoint
99

1010

11-
## Standalone Install & Test
11+
## Getting Started
1212

13-
You can generate a standalone application with:
13+
Create a new Platformatic application with the RabbitMQ Hooks package using [Wattpm](https://platformatic.io/docs/wattpm):
1414

1515
```bash
16-
npx --package @platformatic/rabbitmq-hooks -c create-platformatic-rabbitmq-hooks
17-
cd rabbitmq-hooks-app
16+
npx wattpm@latest create
1817
```
1918

19+
And select `@platformatic/rabbitmq-hooks` from the list of available packages.
20+
2021
This application assumes that you have a RabbitMQ server running at `amqp://localhost`. A `my-exchange` exchange is created if not present.
2122
Now start a RabbitMQ server if not already running, for instance with docker:
2223

2324
```bash
2425
docker run -d --hostname my-rabbit --name plt-rabbit rabbitmq:3
25-
2626
```
2727

28-
Then you can run the application with `npm start`:
28+
Then you can run the application with `wattpm start`:
2929

3030
```bash
31-
➜ npm start
32-
33-
> start
34-
> platformatic start
31+
➜ wattpm start
3532

3633
[14:10:25.128] INFO (main/91344): Starting rabbitmq-hooks plugin
3734
[14:10:25.197] INFO (main/91344): Connected to RabbitMQ
@@ -45,11 +42,11 @@ exchange my-exchange true
4542
To test this, you can add a `out` endpoint to the app, e.g. in `routes/root` add:
4643

4744
```javascript
48-
fastify.post('/out', async (request, reply) => {
49-
const message = await request.body.message
50-
console.log('RECEIVED MESSAGE FROM RABBITMQ')
51-
console.log(message)
52-
})
45+
fastify.post('/out', async (request, reply) => {
46+
const message = await request.body.message
47+
console.log('RECEIVED MESSAGE FROM RABBITMQ')
48+
console.log(message)
49+
})
5350
```
5451

5552
Then change `.env` to use it:

cli/create.js

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

cli/start.js

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

0 commit comments

Comments
 (0)