Skip to content

Commit e96e2dd

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-full-replication-id
2 parents 731c8bc + cbf2683 commit e96e2dd

File tree

167 files changed

+5149
-3860
lines changed

Some content is hidden

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

167 files changed

+5149
-3860
lines changed

.changeset/fuzzy-knives-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/lib-services-framework': minor
3+
---
4+
5+
Initial release for service utillities

.changeset/shaggy-parents-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/service-core': minor
3+
---
4+
5+
Removed dependency for restricted packages

.env.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Connections for tests
2+
MONGO_TEST_UR="mongodb://localhost:27017/powersync_test"
3+
PG_TEST_URL="postgres://postgres:postgres@localhost:5432/powersync_test"

.github/workflows/development_image_release.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ jobs:
4141
version: 9
4242
run_install: false
4343

44-
- name: Add NPM auth
45-
run: |
46-
echo //npm.pkg.github.com/:_authToken=\${{secrets.RESTRICTED_PACKAGES_TOKEN}} >> ~/.npmrc
47-
echo "//npm.pkg.github.com/journeyapps-platform/:_authToken=${{secrets.RESTRICTED_PACKAGES_TOKEN}}" >> ~/.npmrc
48-
echo "@journeyapps-platform:registry=https://npm.pkg.github.com/journeyapps-platform/" >> ~/.npmrc
49-
5044
- name: Get pnpm store directory
5145
shell: bash
5246
run: |
@@ -86,6 +80,3 @@ jobs:
8680
tags: ${{vars.DOCKER_REGISTRY}}:${{steps.get_version.outputs.SERVICE_VERSION}}
8781
push: true
8882
file: ./service/Dockerfile
89-
# TODO remove this when removing Journey Micro
90-
build-args: |
91-
GITHUB_TOKEN=${{secrets.RESTRICTED_PACKAGES_TOKEN}}

.github/workflows/development_packages_release.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ jobs:
2727
version: 9
2828
run_install: false
2929

30-
- name: Add NPM auth
31-
run: |
32-
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc
33-
echo //npm.pkg.github.com/:_authToken=\${{secrets.RESTRICTED_PACKAGES_TOKEN}} >> ~/.npmrc
34-
echo "//npm.pkg.github.com/journeyapps-platform/:_authToken=${{secrets.RESTRICTED_PACKAGES_TOKEN}}" >> ~/.npmrc
35-
echo "@journeyapps-platform:registry=https://npm.pkg.github.com/journeyapps-platform/" >> ~/.npmrc
36-
3730
- name: Get pnpm store directory
3831
shell: bash
3932
run: |
@@ -47,6 +40,10 @@ jobs:
4740
restore-keys: |
4841
${{ runner.os }}-pnpm-store-
4942
43+
- name: Add NPM auth
44+
run: |
45+
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc
46+
5047
- name: Install dependencies
5148
run: pnpm install
5249

.github/workflows/image_release.yaml

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,57 @@
22
name: Docker Image Release
33

44
on: workflow_dispatch
5-
5+
66
concurrency: ${{ github.workflow }}-${{ github.ref }}
77

88
jobs:
9-
release-docker-image:
10-
name: Build and Release powersync-service Docker Image
11-
runs-on: ubuntu-latest
12-
if: github.ref == 'refs/heads/main'
13-
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v4
16-
with:
17-
# check out full history
18-
# Temporarily needed for changesets
19-
fetch-depth: 0
20-
21-
- name: Set up QEMU
22-
uses: docker/setup-qemu-action@v3
23-
24-
- name: Set up Docker Buildx
25-
uses: docker/setup-buildx-action@v3
26-
27-
- name: Login to Docker Hub
28-
uses: docker/login-action@v3
29-
with:
30-
username: ${{ secrets.DOCKERHUB_USERNAME }}
31-
password: ${{ secrets.DOCKERHUB_TOKEN }}
32-
33-
# This uses the service's package.json version for the Docker Image tag
34-
- name: Get Service Version from package.json
35-
id: get_version
36-
run: echo "SERVICE_VERSION=$(node -p "require('./service/package.json').version")" >> $GITHUB_OUTPUT
37-
38-
- name: Build Image and Push
39-
uses: docker/build-push-action@v5
40-
with:
41-
platforms: linux/arm64,linux/amd64
42-
cache-from: type=registry,ref=${{vars.DOCKER_REGISTRY}}:latest
43-
context: .
44-
tags: ${{vars.DOCKER_REGISTRY}}:latest,${{vars.DOCKER_REGISTRY}}:${{steps.get_version.outputs.SERVICE_VERSION}}
45-
push: true
46-
file: ./service/Dockerfile
47-
# TODO remove this when removing Journey Micro
48-
build-args: |
49-
GITHUB_TOKEN=${{secrets.RESTRICTED_PACKAGES_TOKEN}}
50-
51-
# # Updates the README section on the DockerHub page
52-
- name: Update repo description
53-
# Note that this 3rd party extention is recommended in the DockerHub docs:
54-
# https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/
55-
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0
56-
with:
57-
username: ${{ secrets.DOCKERHUB_USERNAME }}
58-
password: ${{ secrets.DOCKERHUB_TOKEN }}
59-
repository: ${{vars.DOCKER_REGISTRY}}
60-
# This is the contents of what will be shown on DockerHub
61-
readme-filepath: ./service/README.md
9+
release-docker-image:
10+
name: Build and Release powersync-service Docker Image
11+
runs-on: ubuntu-latest
12+
if: github.ref == 'refs/heads/main'
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
# check out full history
18+
# Temporarily needed for changesets
19+
fetch-depth: 0
20+
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v3
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Login to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKERHUB_USERNAME }}
31+
password: ${{ secrets.DOCKERHUB_TOKEN }}
32+
33+
# This uses the service's package.json version for the Docker Image tag
34+
- name: Get Service Version from package.json
35+
id: get_version
36+
run: echo "SERVICE_VERSION=$(node -p "require('./service/package.json').version")" >> $GITHUB_OUTPUT
37+
38+
- name: Build Image and Push
39+
uses: docker/build-push-action@v5
40+
with:
41+
platforms: linux/arm64,linux/amd64
42+
cache-from: type=registry,ref=${{vars.DOCKER_REGISTRY}}:latest
43+
context: .
44+
tags: ${{vars.DOCKER_REGISTRY}}:latest,${{vars.DOCKER_REGISTRY}}:${{steps.get_version.outputs.SERVICE_VERSION}}
45+
push: true
46+
file: ./service/Dockerfile
47+
48+
# # Updates the README section on the DockerHub page
49+
- name: Update repo description
50+
# Note that this 3rd party extention is recommended in the DockerHub docs:
51+
# https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/
52+
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0
53+
with:
54+
username: ${{ secrets.DOCKERHUB_USERNAME }}
55+
password: ${{ secrets.DOCKERHUB_TOKEN }}
56+
repository: ${{vars.DOCKER_REGISTRY}}
57+
# This is the contents of what will be shown on DockerHub
58+
readme-filepath: ./service/README.md

.github/workflows/packages_release.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ jobs:
3939
restore-keys: |
4040
${{ runner.os }}-pnpm-store-
4141
42-
# TODO remove this when no longer needed
43-
- name: Temporary Package Credentials
42+
- name: Add NPM auth
4443
run: |
45-
echo //npm.pkg.github.com/:_authToken=\${{secrets.RESTRICTED_PACKAGES_TOKEN}} >> ~/.npmrc
46-
echo "//npm.pkg.github.com/journeyapps-platform/:_authToken=${{secrets.RESTRICTED_PACKAGES_TOKEN}}" >> ~/.npmrc
47-
echo "@journeyapps-platform:registry=https://npm.pkg.github.com/journeyapps-platform/" >> ~/.npmrc
44+
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc
4845
4946
- name: Install dependencies
5047
run: pnpm install

.github/workflows/test.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ jobs:
7070
with:
7171
node-version-file: '.nvmrc'
7272

73-
# TODO remove this when no longer needed
74-
- name: Temporary Package Credentials
75-
run: |
76-
echo //npm.pkg.github.com/:_authToken=\${{secrets.RESTRICTED_PACKAGES_TOKEN}} >> ~/.npmrc
77-
echo "//npm.pkg.github.com/journeyapps-platform/:_authToken=${{secrets.RESTRICTED_PACKAGES_TOKEN}}" >> ~/.npmrc
78-
echo "@journeyapps-platform:registry=https://npm.pkg.github.com/journeyapps-platform/" >> ~/.npmrc
79-
8073
- uses: pnpm/action-setup@v2
8174
name: Install pnpm
8275
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ npm-error.log
1515
.pnpm-debug.log
1616
.local-dev
1717
.probes
18+
powersync.yaml
19+
sync-rules.yaml
1820

1921

2022
packages/*/manifest.json

DEVELOP.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,69 @@ The project uses TypeScript. Build packages with
1414
pnpm build
1515
```
1616

17+
# Running Service
18+
19+
## Dependent Services
20+
21+
The PowerSync service requires Postgres and MongoDB server connections. These configuration details can be specified in a `powersync.yaml` (or JSON) configuration file.
22+
23+
See the [Self hosting demo](https://github.com/powersync-ja/self-host-demo) for examples of starting these services.
24+
25+
A quick method for running all required services with a handy backend and frontend is to run the following in a checked-out `self-host-demo` folder.
26+
27+
```bash
28+
docker compose up --scale powersync=0
29+
```
30+
31+
Note: The `mongo` hostname specified in the MongoDB replica set needs to be accessible by your host machine if using the Mongo service above.
32+
33+
This will start all the services defined in the Self hosting demo except for the PowerSync service - which will be started from this repository.
34+
35+
## Local Configuration
36+
37+
The `./service` folder contains a NodeJS project which starts all PowerSync service operations.
38+
39+
Copy the template configuration files and configure any changes to your local needs.
40+
41+
```bash
42+
cd ./service
43+
cp local-dev/powersync-template.yaml powersync.yaml
44+
cp local-dev/sync-rules-template.yaml sync-rules.yaml
45+
```
46+
47+
## Starting Service
48+
49+
The service can be started with watching changes to any consumed source files by running the `pnpm watch:service` command in the repository root.
50+
51+
# Running Tests
52+
53+
Most packages should contain a `test` script which can be executed with `pnpm test`. Some packages may require additional setup to run tests.
54+
55+
## Service Core
56+
57+
Some tests for these packages require a connection to MongoDB and Postgres. Connection strings for these services should be available as environment variables. See [Running Tests](#running-services) for details on configuring those services.
58+
59+
These can be set in a terminal/shell
60+
61+
```bash
62+
export MONGO_TEST_UR="mongodb://localhost:27017/powersync_test"
63+
export PG_TEST_URL="postgres://postgres:postgres@localhost:5432/powersync_test"
64+
```
65+
66+
or by copying the `.env.template` file and using a loader such as [Direnv](https://direnv.net/)
67+
68+
```bash
69+
cp .env.template .env
70+
```
71+
72+
## Postgres Configuration
73+
74+
The default `PG_TEST_URL` points to a `powersync_test` database. Ensure this is created by executing the following SQL on your connection.
75+
76+
```SQL
77+
CREATE DATABASE powersync_test;
78+
```
79+
1780
# Releases
1881

1982
This repository uses Changesets. Add changesets to changed packages before merging PRs.
@@ -22,4 +85,6 @@ This repository uses Changesets. Add changesets to changed packages before mergi
2285
changeset add
2386
```
2487

25-
Merging a PR with changeset files will automatically create a release PR. Merging the release PR will bump versions, tag and publish packages and the Docker image. The Docker image version is extracted from the `./service/package.json` `version` field.
88+
Merging a PR with changeset files will automatically create a release PR. Merging the release PR will bump versions, tag and publish packages.
89+
90+
The Docker image is published by manually triggering the `Docker Image Release` Github Action. The Docker image version is extracted from the `./service/package.json` `version` field.

0 commit comments

Comments
 (0)