Skip to content

Commit 53cb3d2

Browse files
authored
Merge pull request #138 from supabase/pnpm-workspaces
refactor: monorepo - standalone sync-engine lib
2 parents 012a2d5 + 6f752a6 commit 53cb3d2

File tree

186 files changed

+5587
-10253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+5587
-10253
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,66 @@ on:
99

1010
jobs:
1111
test:
12-
name: Test / OS ${{ matrix.platform }} / Node ${{ matrix.node }}
13-
strategy:
14-
fail-fast: false
15-
matrix:
16-
platform: [ubuntu-24.04]
17-
node: ['22']
12+
name: Test
13+
runs-on: ubuntu-24.04
1814

19-
runs-on: ${{ matrix.platform }}
15+
services:
16+
postgres:
17+
image: postgres:15
18+
ports:
19+
- 55432:5432
20+
env:
21+
POSTGRES_DB: postgres
22+
POSTGRES_USER: postgres
23+
POSTGRES_PASSWORD: postgres
2024

2125
steps:
2226
- uses: actions/checkout@v4
23-
- uses: actions/cache@v4
24-
with:
25-
path: ~/.npm
26-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
27-
restore-keys: |
28-
${{ runner.os }}-node-
27+
28+
- name: Install pnpm
29+
uses: pnpm/action-setup@v4
30+
2931
- name: Set up Node
3032
uses: actions/setup-node@v4
3133
with:
32-
node-version: ${{ matrix.node }}
34+
node-version-file: ./.nvmrc
35+
cache: pnpm
3336

3437
- name: Set up .env file
3538
run: |
36-
touch .env
37-
echo DATABASE_URL='postgres://postgres:postgres@127.0.0.1:55432/postgres?sslmode=disable&search_path=stripe' >> .env
38-
echo NODE_ENV=dev >> .env
39-
echo STRIPE_SECRET_KEY=sk_test_ >> .env
40-
echo STRIPE_WEBHOOK_SECRET=whsec_ >> .env
41-
echo SCHEMA=stripe >> .env
42-
echo PORT=8080 >> .env
43-
echo API_KEY=api_key_test >> .env
39+
touch packages/fastify-app/.env
40+
echo DATABASE_URL='postgres://postgres:postgres@localhost:55432/postgres?sslmode=disable&search_path=stripe' >> packages/fastify-app/.env
41+
echo NODE_ENV=dev >> packages/fastify-app/.env
42+
echo STRIPE_SECRET_KEY=sk_test_ >> packages/fastify-app/.env
43+
echo STRIPE_WEBHOOK_SECRET=whsec_ >> packages/fastify-app/.env
44+
echo SCHEMA=stripe >> packages/fastify-app/.env
45+
echo PORT=8080 >> packages/fastify-app/.env
46+
echo API_KEY=api_key_test >> packages/fastify-app/.env
4447
4548
- name: Install dependencies
4649
run: |
47-
npm ci
50+
pnpm install --frozen-lockfile
4851
4952
- name: Formatting checks
5053
run: |
51-
npm run format:check
54+
pnpm format:check
5255
5356
- name: Lint
5457
run: |
55-
npm run lint
58+
pnpm lint
5659
5760
- name: Builds successfully
5861
run: |
59-
npm run build
62+
pnpm build
63+
64+
- name: Initialize DB schema
65+
run: |
66+
docker run --rm \
67+
--network="host" \
68+
-e PGPASSWORD=postgres \
69+
postgres:15 \
70+
psql -h localhost -p 55432 -U postgres -d postgres -c 'create schema if not exists "stripe";'
6071
6172
- name: Tests
6273
run: |
63-
docker compose -f ./docker/compose.yml up -d
6474
npm run test

.github/workflows/release.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
name: release
22

33
on:
4-
push:
5-
branches:
6-
- 'main'
4+
#push:
5+
# branches:
6+
# - 'main'
77
workflow_dispatch:
88

99
jobs:
1010
release:
11-
name: Release / Node ${{ matrix.node }}
12-
strategy:
13-
matrix:
14-
node:
15-
- '22'
11+
name: Release
1612

1713
runs-on: ubuntu-24.04
1814

@@ -23,14 +19,17 @@ jobs:
2319
steps:
2420
- uses: actions/checkout@v4
2521

22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v4
24+
2625
- name: Set up Node
2726
uses: actions/setup-node@v4
2827
with:
29-
node-version: ${{ matrix.node }}
28+
node-version-file: ./.nvmrc
29+
cache: pnpm
3030

3131
- run: |
32-
npm clean-install
33-
npm run build
32+
pnpm install --frozen-lockfile
3433
3534
- name: Run semantic-release
3635
id: semantic-release
@@ -69,9 +68,33 @@ jobs:
6968
id: docker_build
7069
uses: docker/build-push-action@v6
7170
with:
71+
context: packages/fastify-app
7272
push: true
7373
tags: supabase/stripe-sync-engine:latest,supabase/stripe-sync-engine:v${{ needs.release.outputs.new-release-version }}
7474
platforms: linux/amd64,linux/arm64
7575

7676
- name: Image digest
7777
run: echo ${{ steps.docker_build.outputs.digest }}
78+
79+
npm:
80+
name: Release on NPM
81+
82+
needs:
83+
- release
84+
85+
if: needs.release.outputs.new-release-published == 'true'
86+
87+
runs-on: ubuntu-24.04
88+
89+
steps:
90+
- name: Set new version in sync-engine
91+
run: |
92+
cd packages/sync-engine
93+
pnpm version ${{ needs.release.outputs.new-release-version }} --no-git-tag-version
94+
95+
- name: Publish sync-engine to npm
96+
run: |
97+
cd packages/sync-engine
98+
npm publish --access public
99+
env:
100+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dist/
33
node_modules/
44
.env
55
.env.*
6-
db/migrations/0000_schema.sql
6+
!.env.sample

.prettierignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.expo
22
.next
33
node_modules
4-
package-lock.json
4+
pnpm-lock.yaml
55
docker*
6-
Pulumi.*.yaml
6+
Pulumi.*.yaml
7+
LICENSE.md

.tours/implement-a-webhook.tour

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

.vscode/settings.json

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

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ The entity type is recognized automatically, based on the prefix.
175175

176176
**Develop**
177177

178-
- `npm run dev` to start the local server
179-
- `npm run test` to run tests
178+
- `pnpm dev` to start the local server
179+
- `pnpm t` to run tests
180180

181181
**Building Docker**
182182

RELEASE.md

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

docker/compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ services:
88
- 55432:5432
99
environment:
1010
POSTGRES_PASSWORD: postgres
11-
volumes:
12-
- ./db/migrations/schema.sql:/docker-entrypoint-initdb.d/0000_schema.sql

docker/db/migrations/schema.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)