Skip to content
Open
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
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
root = true

[*]
ij_html_space_inside_empty_tag = true
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

# quote style
ij_javascript_force_quote_style = true
ij_typescript_force_quote_style = true
ij_javascript_use_double_quotes = false
ij_typescript_use_double_quotes = false

# bracket spacing
ij_javascript_spaces_within_object_literal_braces = true
ij_typescript_spaces_within_object_literal_braces = true
ij_javascript_spaces_within_object_type_braces = true
ij_typescript_spaces_within_object_type_braces = true

# imports
ij_javascript_spaces_within_imports = true
ij_typescript_spaces_within_imports = true
ij_javascript_import_merge_members = true
ij_typescript_import_merge_members = true
ij_javascript_import_sort_members = true
ij_typescript_import_sort_members = true
21 changes: 21 additions & 0 deletions .github/actions/node-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
inputs:
node-version:
description: 'Node.js version'
required: false
default: 'lts/*'

runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
shell: bash
run: |
set -euo pipefail
npm ci --prefer-offline --no-audit --no-fund
119 changes: 119 additions & 0 deletions .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build SQLite Wasm

on:
workflow_dispatch:
inputs:
sqlite_ref:
description: 'SQLite reference (tag, branch, or commit, or "latest")'
required: true
default: 'master'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Resolve SQLite reference
id: resolve-ref
run: |
SQLITE_REF="${{ github.event.inputs.sqlite_ref }}"
if [ "$SQLITE_REF" = "latest" ]; then
echo "Fetching latest tag..."
LATEST_TAG=$(git ls-remote --tags --sort="v:refname" https://github.com/sqlite/sqlite.git "refs/tags/version-*" | tail -n 1 | cut -f 2 | sed 's/refs\/tags\///')
echo "Latest tag found: $LATEST_TAG"
SQLITE_REF="$LATEST_TAG"
fi

# Get the full commit SHA
SQLITE_SHA=$(git ls-remote https://github.com/sqlite/sqlite.git "$SQLITE_REF" | head -n 1 | cut -f 1)
if [ -z "$SQLITE_SHA" ]; then
# If not found, maybe it's a tag that needs refs/tags/ prefix or it's already a SHA
SQLITE_SHA=$(git ls-remote https://github.com/sqlite/sqlite.git "refs/tags/$SQLITE_REF" | head -n 1 | cut -f 1)
fi

if [ -z "$SQLITE_SHA" ]; then
# Fallback: assume it's a SHA if ls-remote didn't find it as a ref
SQLITE_SHA="$SQLITE_REF"
fi

echo "sqlite_ref=$SQLITE_REF" >> $GITHUB_OUTPUT
echo "sqlite_sha=$SQLITE_SHA" >> $GITHUB_OUTPUT
echo "branch_name=update-sqlite-wasm-${SQLITE_SHA}" >> $GITHUB_OUTPUT

- name: Check if branch exists
id: check-branch
run: |
BRANCH_NAME="${{ steps.resolve-ref.outputs.branch_name }}"
if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME already exists. Skipping build."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi

- name: Set up Docker Buildx
if: steps.check-branch.outputs.skip != 'true'
uses: docker/setup-buildx-action@v3

- name: Build Docker image
if: steps.check-branch.outputs.skip != 'true'
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: sqlite-wasm-builder:env
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run build
if: steps.check-branch.outputs.skip != 'true'
run: |
mkdir -p out src/bin
docker run --rm \
-e SQLITE_REF="${{ steps.resolve-ref.outputs.sqlite_ref }}" \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-v "$(pwd)/out":/out \
-v "$(pwd)/src/bin":/src/bin \
sqlite-wasm-builder:env build
# Fallback fix for permissions if chown inside docker failed or was incomplete
sudo chown -R $(id -u):$(id -g) out src/bin

- name: Check for changes
if: steps.check-branch.outputs.skip != 'true'
id: git-check
run: |
# Add files that might be newly created or modified
git add src/bin
git status --porcelain
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi

- name: Create Pull Request
if:
steps.check-branch.outputs.skip != 'true' &&
steps.git-check.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message:
'chore: update SQLite Wasm binaries from ${{
steps.resolve-ref.outputs.sqlite_ref }} (${{
steps.resolve-ref.outputs.sqlite_sha }})'
title:
'chore: update SQLite Wasm binaries from ${{
steps.resolve-ref.outputs.sqlite_ref }}'
body: |
This PR updates the SQLite Wasm binaries in `src/bin` by building them from SQLite reference `${{ steps.resolve-ref.outputs.sqlite_ref }}` (commit `${{ steps.resolve-ref.outputs.sqlite_sha }}`).

Triggered by manual workflow dispatch.
branch: ${{ steps.resolve-ref.outputs.branch_name }}
base: main
delete-branch: true
112 changes: 112 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: CI

permissions:
contents: read
pull-requests: read

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
type-check:
name: Type check
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Node.js
uses: ./.github/actions/node-setup

- name: Run type check
run: npm run check-types

format:
name: Format check
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup environment (node + install)
uses: ./.github/actions/node-setup

- name: Run format check
run: npx prettier . --check

test-browser:
name: Run browser tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup environment (node + install)
uses: ./.github/actions/node-setup

- name: Get Playwright version
id: playwright-version
run:
echo "PLAYWRIGHT_VERSION=$(node -e
"console.log(require('./package-lock.json').packages['node_modules/playwright'].version)")"
>> $GITHUB_OUTPUT

- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key:
${{ runner.os }}-playwright-${{
steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}
restore-keys: |
${{ runner.os }}-playwright-

- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Install Playwright dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps

- name: Run browser tests
run: npm run test:browser

test-node:
name: Run node tests (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20, 22, 23, 24, 25]
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup environment (node + install)
uses: ./.github/actions/node-setup
with:
node-version: ${{ matrix.node-version }}

- name: Run node tests
run: npm run test:node
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/src/bin
/dist
/node_modules
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# syntax=docker/dockerfile:1
FROM emscripten/emsdk:latest

ARG DEBIAN_FRONTEND=noninteractive

# runtime / build deps
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
git \
build-essential \
autoconf \
automake \
libtool \
m4 \
python3 \
nodejs \
npm \
zip \
unzip \
curl \
wabt \
&& rm -rf /var/lib/apt/lists/*

# create useful dirs
RUN mkdir -p /build /out /src/bin /work

# copy helper script
COPY scripts/build-sqlite3-wasm.sh /usr/local/bin/build-sqlite3-wasm.sh
RUN chmod +x /usr/local/bin/build-sqlite3-wasm.sh

WORKDIR /work

ENTRYPOINT ["/usr/local/bin/build-sqlite3-wasm.sh"]
CMD ["build"]
Loading