Skip to content
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
73 changes: 31 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
name: CI
on: [pull_request]
jobs:

build:
name: Build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: oven-sh/setup-bun@v2
with:
node-version: 22
bun-version: 1.3.14

- run: sudo apt-get install -y jq
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-

- run: yarn install
- run: yarn build
- run: bun install --frozen-lockfile
- run: bun run build

- name: Upload djangobuilder4 dist directory
uses: actions/upload-artifact@v4
with:
name: djangobuilder4_dist
path: ./packages/djangobuilder4/dist

- name: Upload djangobuilder.io dist directory
uses: actions/upload-artifact@v4
with:
Expand All @@ -45,41 +33,36 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: oven-sh/setup-bun@v2
with:
node-version: 22
bun-version: 1.3.14

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- run: yarn
- run: yarn lint
- run: bun install --frozen-lockfile
- run: bun run lint

smoke_tests:
name: Core - Smoke tests
needs: [build]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: yarn
- run: yarn test_smoke

- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- run: bun install --frozen-lockfile
- run: bun run test_smoke

core_tests:
name: Core - Unit tests
needs: [smoke_tests]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: yarn
- run: yarn test_core
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- run: bun install --frozen-lockfile
- run: bun run test_core

cli_tests:
name: DB.io - CLI Tests
Expand Down Expand Up @@ -121,6 +104,9 @@ jobs:
with:
crate: websocat
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}
Expand All @@ -129,19 +115,22 @@ jobs:
with:
# Install a specific version of uv.
version: "0.5.6"
- run: yarn
- run: bun install --frozen-lockfile
- name: Run Smoke tests
run: make smoke_test_ci
env:
POSTGRES_URL: postgres://postgres:mysecretpassword@localhost:5432/postgres
PYTHON_VERSION: ${{ matrix.version }}
DJANGO_VERSION: ${{ matrix.django_version }}

io_tests:
name: DB.io - Unit Tests
needs: [build]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: yarn
- run: yarn test_io
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- run: bun install --frozen-lockfile
- run: bun run test_io
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ deploy:
ifeq "$(name)" ""
@echo "Specify name e.g. make deploy name=staging" && exit 1
else
firebase use $(name)
yarn run build_$(name)
bunx firebase use $(name)
bun run build_$(name)
rm -rf dist_$(name)
mkdir -p dist_$(name)
cp -r packages/djangobuilder.io/dist/* dist_$(name)/
mkdir -p dist_$(name)/db4/
cp -r packages/djangobuilder4/dist/* dist_$(name)/db4/
firebase deploy --public=dist_$(name)
bunx firebase deploy --public=dist_$(name)
endif

smoke_test:
Expand All @@ -32,7 +32,7 @@ smoke_test_ci:
./script/cli_test.sh /tmp/project-with-channels.json

create:
yarn run cli ${EXAMPLE_PROJECT_POSTGRES_JSON} ${EXAMPLE_TAR_OUTPUT}
bun run cli ${EXAMPLE_PROJECT_POSTGRES_JSON} ${EXAMPLE_TAR_OUTPUT}
echo "Project created at ${PROJECT_NAME}"
tar -xvf ${EXAMPLE_TAR_OUTPUT}

Expand Down Expand Up @@ -62,7 +62,7 @@ run_django_channels: create_channels

create_channels:
jq -s '.[0] * .[1]' ${EXAMPLE_PROJECT_POSTGRES_JSON} ${PARTIAL_WITH_CHANNELS_JSON} > /tmp/project-with-channels.json
yarn run cli /tmp/project-with-channels.json ${EXAMPLE_TAR_OUTPUT}
bun run cli /tmp/project-with-channels.json ${EXAMPLE_TAR_OUTPUT}
echo "Project created at ${PROJECT_NAME_WITH_CHANNELS}"
tar -xvf ${EXAMPLE_TAR_OUTPUT}

Expand Down
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ The original Django Builder v1 is deployed at:
http://mmcardle.github.io/django_builder/

## Project setup

This repo uses [Bun](https://bun.sh) as its package manager and task runner
(Vite remains the bundler/dev-server). Install dependencies with:

```
yarn install
bun install
```

### CLI interface
Expand All @@ -35,9 +39,11 @@ python manage.py runserver
Head to http://127.0.0.1:8000

#### Firebase

`firebase-tools` ships as a dev dependency, so run the Firebase CLI through Bun:

```
npm install -g firebase-tools
firebase login
bunx firebase login
```

## Setup Firebase Environment
Expand All @@ -51,58 +57,53 @@ cp .env.example .env.development.local
Edit this file with your firebase setup and run the development server.

```
yarn serve
bun run dev
```

### Compiles and minifies for different modes
```
yarn build --mode=development
yarn build --mode=production
bun run build_development
bun run build_production
```

### Initial setup

When a fresh checkout is done aliases must be setup for each project, e.g. development

```
firebase use --add
bunx firebase use --add
```

Follow the instructions to link to your Firebase application, choose the alias 'development' and your firebase project

### Deploy development
```
firebase use development
yarn build --mode=development --dest=dist_development
firebase deploy --public=dist_development
bunx firebase use development
bun run build_development
bunx firebase deploy --public=dist_development
```

### Run unit tests
```
yarn test:unit
```

### Run e2e tests
```
yarn test:e2e
bun run test_io
```

### Lints and fixes files
```
yarn lint
bun run lint
```

### Firebase get indexes
Useful after creating an index
```
firebase firestore:indexes
bunx firebase firestore:indexes
```

### Firebase use project
```
firebase use development
firebase use production
bunx firebase use development
bunx firebase use production
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
See [Vite Configuration Reference](https://vite.dev/config/).
8 changes: 5 additions & 3 deletions bin/django-builder
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env node
#!/usr/bin/env bun
// Usage: django-builder <input.json> <output.tar>
// Delegates to the core CLI's `render` command.
import { main } from "../lib/djangobuilder-core/src/cli";

require = require('esm')(module /*, options*/);
require('../lib/djangobuilder-core/src/cli').cli(process.argv);
main(["render", ...process.argv.slice(2)]);
Loading
Loading