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

Isolated Demo Tests #234

Merged
merged 36 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2df467a
wip: isolated tests
stevensJourney Jul 21, 2024
a3d374e
isolated tests
stevensJourney Jul 22, 2024
9cdd436
update lockfile
stevensJourney Jul 22, 2024
64cbb2e
test
stevensJourney Jul 22, 2024
6f8740b
login
stevensJourney Jul 22, 2024
c6a5dd3
lowercase username
stevensJourney Jul 22, 2024
73db499
another test
stevensJourney Jul 22, 2024
4f69e19
allow all packages proxied
stevensJourney Jul 22, 2024
b987698
fix folder
stevensJourney Jul 22, 2024
22b6828
order
stevensJourney Jul 22, 2024
2d3b094
build:packages
stevensJourney Jul 22, 2024
aea4bd0
temp test
stevensJourney Jul 22, 2024
063ef04
registry cleanup
stevensJourney Jul 22, 2024
ba5bbaf
use pnpm version fetching
stevensJourney Jul 22, 2024
b4f5a9c
revert test
stevensJourney Jul 22, 2024
7afc7c2
add p-defer as dev dependency
stevensJourney Jul 22, 2024
3a0db91
update lockfile
stevensJourney Jul 22, 2024
fa122c3
update
stevensJourney Jul 22, 2024
c41da43
Merge branch 'main' into feat/isolated-tests
stevensJourney Jul 24, 2024
78359d3
angular demo: improve environment setup
stevensJourney Jul 24, 2024
63042d4
django app: add tsc build step
stevensJourney Jul 24, 2024
3692611
test build script
stevensJourney Jul 24, 2024
d1ec14c
update from master
stevensJourney Jul 25, 2024
3168f26
pnpm version
stevensJourney Jul 25, 2024
9161b23
limit test demos. Remove npmjs proxy
stevensJourney Jul 29, 2024
79396d8
Merge branch 'main' into feat/isolated-tests
stevensJourney Jul 29, 2024
3edabe9
only run if present
stevensJourney Jul 29, 2024
ff35ec0
remove capacitor demo
stevensJourney Jul 29, 2024
16f5553
remove more demos from tests
stevensJourney Jul 29, 2024
c979f70
add annotations
stevensJourney Jul 29, 2024
5497103
add summary
stevensJourney Jul 29, 2024
8ce973f
remove annotations
stevensJourney Jul 29, 2024
c5cc6b5
update from main
stevensJourney Jul 29, 2024
771ffb7
cleanup
stevensJourney Jul 29, 2024
0b33c63
cleanup
stevensJourney Jul 29, 2024
d1dffad
update lockfile
stevensJourney Jul 29, 2024
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
69 changes: 69 additions & 0 deletions .github/workflows/test-isolated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Ensures packages and demos test correctly
name: Test Isolated Demos

on:
push:

jobs:
test:
name: Test Isolated Demos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
# Pnpm 9.4 introduces this https://github.com/pnpm/pnpm/pull/7633
# which causes workspace:^1.2.0 to be converted to 1.2.0^1.2.0
version: 9.3
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install
run: pnpm install

- name: Build Packages
run: pnpm build:packages

- name: Start Verdaccio
run: |
npm install -g verdaccio
nohup verdaccio -c verdaccio-config.yaml &
sleep 10 # Give Verdaccio some time to start

- name: Prepare For Test Publish
run: npx tsx scripts/test-publish-helper.ts

- name: Registry login
run: npx npm-cli-login -u test -p test -e [email protected] -r http://localhost:4873

- name: Config Temporary Registry
run: echo "@powersync:registry=http://localhost:4873" >> ~/.npmrc

# No actual auth is ever supplied to this action.
# It should never be able to publish to NPMJS
- name: Test publish
run: pnpm -r publish --no-git-checks

- name: Test Demos
run: npx tsx scripts/isolated-demo-test.ts
4 changes: 4 additions & 0 deletions demos/angular-supabase-todolist/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See the local demo at https://github.com/powersync-ja/self-host-demo/tree/main/demos/supabase
WEBPACK_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
WEBPACK_PUBLIC_SUPABASE_ANON_KEY=
WEBPACK_PUBLIC_POWERSYNC_URL=http://localhost:8080
2 changes: 0 additions & 2 deletions demos/angular-supabase-todolist/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,3 @@ testem.log
# System files
.DS_Store
Thumbs.db

environment.ts
8 changes: 5 additions & 3 deletions demos/angular-supabase-todolist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ A step-by-step guide on Supabase<>PowerSync integration is available [here](http
## Quick Start

1. Run `pnpm install`
2. Run `pnpm watch` to build application and check for code changes
3. In a new terminal run `pnpm start` to start the server
4. Go to <http://localhost:8080>
2. Create a `.env` file by copying the template `cp .env.template .env`
3. Populate the `.env` file with PowerSync and Supabase details
4. Run `pnpm watch` to build application and check for code changes
5. In a new terminal run `pnpm start` to start the server
6. Go to <http://localhost:8080>

**Note:** The Angular development server (`pnpm serve`) doesn't support service worker applications

Expand Down
15 changes: 13 additions & 2 deletions demos/angular-supabase-todolist/extra-webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const webpack = require('webpack');
const pkg = require('./package.json');
const { inspect } = require('util');
const path = require('path');

const dotenv = require('dotenv');

dotenv.config();

module.exports = (config, options, targetOptions) => {
delete config.optimization;
return {
Expand All @@ -11,7 +14,15 @@ module.exports = (config, options, targetOptions) => {
rules: config.module.rules
},
resolve: config.resolve,
plugins: config.plugins,
plugins: [
...config.plugins,
new webpack.DefinePlugin({
// Embed environment variables starting with `WEBPACK_PUBLIC_`
'process.env': JSON.stringify(
Object.fromEntries(Object.entries(process.env).filter(([key]) => key.startsWith('WEBPACK_PUBLIC_')))
)
})
],
output: {
filename: config.filename,
path: config.path,
Expand Down
4 changes: 3 additions & 1 deletion demos/angular-supabase-todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "http-server -p 8080 -c-1 dist/",
"build": "ng build",
"format": "prettier --write .",
"test:build": "pnpm build",
"watch": "ng build --watch --configuration development"
},
"private": true,
Expand All @@ -20,8 +21,8 @@
"@angular/platform-browser-dynamic": "^18.1.1",
"@angular/router": "^18.1.1",
"@angular/service-worker": "^18.1.1",
"@powersync/web": "workspace:*",
"@journeyapps/wa-sqlite": "^0.2.0",
"@powersync/web": "workspace:*",
"@supabase/supabase-js": "^2.44.4",
"rxjs": "~7.8.1",
"tslib": "^2.6.3",
Expand All @@ -32,6 +33,7 @@
"@angular-devkit/build-angular": "^18.1.1",
"@angular/cli": "^18.1.1",
"@angular/compiler-cli": "^18.1.1",
"dotenv": "^16.4.5",
"http-server": "^14.1.1",
"typescript": "~5.5.3"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type SupabaseClient,
type User
} from '@supabase/supabase-js';
import { environment } from '../../environment';
import { environment } from '../environment';
import { type AbstractPowerSyncDatabase, type CrudEntry, UpdateType, PowerSyncBackendConnector } from '@powersync/web';

/// Postgres Response codes that we cannot recover from by retrying.
Expand Down
8 changes: 8 additions & 0 deletions demos/angular-supabase-todolist/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare namespace NodeJS {
// These are injected in the Webpack config
interface ProcessEnv {
WEBPACK_PUBLIC_SUPABASE_URL: string;
WEBPACK_PUBLIC_SUPABASE_ANON_KEY: string;
WEBPACK_PUBLIC_POWERSYNC_URL: string;
}
}
5 changes: 5 additions & 0 deletions demos/angular-supabase-todolist/src/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const environment = {
supabaseUrl: process.env.WEBPACK_PUBLIC_SUPABASE_URL,
supabaseKey: process.env.WEBPACK_PUBLIC_SUPABASE_ANON_KEY,
powersyncUrl: process.env.WEBPACK_PUBLIC_POWERSYNC_URL
};
3 changes: 3 additions & 0 deletions demos/django-react-native-todolist/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Replace the credentials below with your Supabase, PowerSync and Expo project details.
EXPO_PUBLIC_DJANGO_URL=http://localhost:6061
EXPO_PUBLIC_POWERSYNC_URL=http://localhost:8080
3 changes: 0 additions & 3 deletions demos/django-react-native-todolist/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# idea
.idea

# Credentials
library/django/AppConfig.ts

# dependencies
node_modules/

Expand Down
2 changes: 2 additions & 0 deletions demos/django-react-native-todolist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Install the dependencies, including the React Native SDK:
pnpm install
```

Update the `.env` file with PowerSync and Django details

Run on iOS

```sh
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const AppConfig = {
djangoUrl: process.env.EXPO_PUBLIC_DJANGO_URL, // This is base url to the Django project
powersyncUrl: process.env.EXPO_PUBLIC_POWERSYNC_URL // This is the PowerSync instance url provided in the PowerSync dashboard
};
11 changes: 7 additions & 4 deletions demos/django-react-native-todolist/library/widgets/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { createDrawerNavigator, DrawerNavigationOptions } from '@react-navigatio

import { withLayoutContext } from 'expo-router';
import { HeaderWidget } from './HeaderWidget';
import { EventMapBase, NavigationState } from '@react-navigation/native';

const DrawerNavigator = createDrawerNavigator().Navigator as React.ComponentType<any>;

export const Drawer = withLayoutContext<DrawerNavigationOptions, typeof DrawerNavigator>(DrawerNavigator, (options) =>
_.chain(options)
.map((o) => ({ ...o, options: { ...o.options, header: () => <HeaderWidget title={o.options?.title || ''} /> } }))
.value()
export const Drawer = withLayoutContext<DrawerNavigationOptions, typeof DrawerNavigator, NavigationState, EventMapBase>(
DrawerNavigator,
(options) =>
_.chain(options)
.map((o) => ({ ...o, options: { ...o.options, header: () => <HeaderWidget title={o.options?.title || ''} /> } }))
.value()
);

export default Drawer;
11 changes: 11 additions & 0 deletions demos/django-react-native-todolist/process-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export {};

declare global {
namespace NodeJS {
interface ProcessEnv {
[key: string]: string | undefined;
EXPO_PUBLIC_DJANGO_URL: string;
EXPO_PUBLIC_POWERSYNC_URL: string;
}
}
}
7 changes: 7 additions & 0 deletions demos/django-react-native-todolist/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./node_modules/expo/tsconfig.base.json",
"compilerOptions": {
"strict": true,
"composite": true
}
}
3 changes: 2 additions & 1 deletion demos/example-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"clean": "rm -rf .next",
"watch": "next dev",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"test:build": "pnpm build"
},
"dependencies": {
"@emotion/react": "^11.11.4",
Expand Down
3 changes: 2 additions & 1 deletion demos/example-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"start": "pnpm build && pnpm preview"
"start": "pnpm build && pnpm preview",
"test:build": "pnpm build"
},
"dependencies": {
"@powersync/web": "workspace:*"
Expand Down
3 changes: 2 additions & 1 deletion demos/example-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"build": "webpack",
"serve": "serve ./dist",
"start": "pnpm build && pnpm serve"
"start": "pnpm build && pnpm serve",
"test:build": "pnpm build"
},
"dependencies": {
"@powersync/web": "workspace:*"
Expand Down
3 changes: 2 additions & 1 deletion demos/react-multi-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview",
"start": "pnpm build && pnpm preview"
"start": "pnpm build && pnpm preview",
"test:build": "pnpm build"
},
"dependencies": {
"@journeyapps/wa-sqlite": "~0.2.0",
Expand Down
3 changes: 2 additions & 1 deletion demos/vue-supabase-todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vue-tsc --noEmit --watch & vite dev",
"build": "vue-tsc && vite build",
"preview": "vite preview",
"type-check": "vue-tsc --noEmit"
"type-check": "vue-tsc --noEmit",
"test:build": "pnpm build"
},
"dependencies": {
"@powersync/web": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"node": ">=20.9.0"
},
"devDependencies": {
"@actions/core": "^1.10.1",
"@changesets/cli": "2.27.2",
"@pnpm/workspace.find-packages": "^4.0.2",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5"
Expand Down
Loading
Loading