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
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Live smoke-test credentials (copy to .env - gitignored - and fill in).
# `make smoke` sources .env when present. Never point this at a production
# organization or project.

# Personal access token (Supabase dashboard -> Account -> Access Tokens).
# The same variable the Supabase CLI and the Terraform provider read.
SUPABASE_ACCESS_TOKEN=sbp_...

# The standing free-tier dev project's reference (dashboard -> Settings ->
# General -> Project ID; 20 lowercase letters). Resolves the `ref` server
# variable so project-scoped queries need no WHERE ref clause; the smoke
# suite runs against this project.
SUPABASE_PROJECT_ID=abcdefghijklmnopqrst
166 changes: 166 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: build-and-test

# Build the supabase provider from the pinned spec and run every
# credential-free test layer on each push / PR; the live smoke suite runs
# only where the Supabase secrets are configured (never the project
# lifecycle - that is `make smoke-project-lifecycle`, run deliberately); a
# scheduled spec-drift job diffs the served spec against the pin (Supabase
# ships fast - drift is expected and must be reviewed, never silent).

on:
push:
branches: [main, 'feature/**']
paths-ignore: ['website/**']
pull_request:
branches: [main]
paths-ignore: ['website/**']
schedule:
- cron: '23 3 * * 1' # weekly spec-drift check (Monday 03:23 UTC)
workflow_dispatch:

jobs:
build-and-test:
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v7
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

# puts the latest stackql on PATH; bin/start-server.sh and the test
# runners resolve it from there
- name: Install stackql
uses: stackql/setup-stackql@v2

- name: stackql version
run: stackql --version

# Drift is reported, not fatal, here: the committed pin is what gets
# built and tested. The spec-drift job below opens the review issue.
- name: Verify the pinned spec against upstream (warns on drift)
run: |
if ! make fetch-spec; then
echo "::warning title=Supabase Management API spec drift::The served spec no longer matches provider-dev/config/spec_pin.json - run 'make refresh-spec && make build && make test' and review the diff. Building from the committed pin."
fi

- name: Build provider from the pinned spec
run: make inventory split mappings pre-normalize normalize generate

- name: Fail on uncommitted generation drift
run: |
git add -N .
if ! git diff --quiet -- provider-dev/openapi provider-dev/config provider-dev/source; then
echo "Generated output differs from the committed artifacts - run 'make build' and commit."
git diff --stat -- provider-dev/openapi provider-dev/config provider-dev/source
exit 1
fi

- name: Offline validation
run: make test-offline

- name: Integration tests (mock Management API)
run: make test-integration

- name: Meta-route tests
run: make test-meta

- name: Generate docs (sanity - the site build runs on the web workflows)
run: make docs

smoke:
# secret-gated live smoke suite against the standing dev project;
# skipped with a notice when the secrets are not configured (forks, PRs
# from outside). Serial pacing under the rate limit is built into the
# harness. The project create/pause/delete lifecycle is NOT run here -
# trigger it deliberately with `make smoke-project-lifecycle`.
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name != 'pull_request' && github.event_name != 'schedule'
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v7
with:
node-version: 20
cache: npm

- uses: actions/setup-python@v7
with:
python-version: '3.12'

- name: Install dependencies
run: npm ci

- name: Live smoke suite (reads + cheap write lifecycles + query round trip)
if: env.SUPABASE_ACCESS_TOKEN != ''
run: make smoke

- name: Live smoke skipped (no credentials)
if: env.SUPABASE_ACCESS_TOKEN == ''
run: |
echo "::notice title=Live smoke suite skipped::SUPABASE_ACCESS_TOKEN / SUPABASE_PROJECT_ID secrets are not configured - the live smoke suite did not run. Credential-free coverage still ran via the mock-server integration suite."

spec-drift:
# Diff the served spec against the pin on a schedule and on demand, and
# open an issue when it moves. Supabase serves a single unversioned spec
# and ships fast - this job is the review trigger.
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v7
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Fetch and compare against the pin
id: drift
run: |
set +e
make fetch-spec > fetch.log 2>&1
rc=$?
set -e
cat fetch.log
if [ "$rc" -eq 0 ]; then
echo "drift=false" >> "$GITHUB_OUTPUT"
else
echo "drift=true" >> "$GITHUB_OUTPUT"
# materialise the diff for the issue body (refresh into the working tree only)
npm run fetch-spec -- --update > /dev/null 2>&1 || true
git diff --stat -- provider-dev/downloaded provider-dev/config/spec_pin.json > drift.txt || true
cat drift.txt
fi

- name: Report drift
if: steps.drift.outputs.drift == 'true'
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
const stat = fs.existsSync('drift.txt') ? fs.readFileSync('drift.txt', 'utf8') : '(diff unavailable)';
const title = 'Supabase Management API spec drift detected';
const body = 'The spec served at https://api.supabase.com/api/v1-json no longer matches the pin in provider-dev/config/spec_pin.json.\n\n```\n' + stat + '\n```\nRun `make refresh-spec && make build && make test`, review the generated diff (new operations, changed schemas, beta labelling, new fix classes in record_spec_pin.mjs), update NOTES.md, and commit.';
await core.summary.addHeading(title).addCodeBlock(stat).write();
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner, repo: context.repo.repo, state: 'open', labels: 'spec-drift'
});
if (issues.some(i => i.title === title)) return;
await github.rest.issues.create({
owner: context.repo.owner, repo: context.repo.repo, title, body, labels: ['spec-drift']
});
58 changes: 58 additions & 0 deletions .github/workflows/prod-web-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main
paths:
- 'website/**'

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- uses: actions/setup-node@v7
with:
node-version: 20
cache: yarn
cache-dependency-path: website/yarn.lock

- name: Install dependencies
run: yarn install --frozen-lockfile
working-directory: website

- name: Build website
run: yarn build
working-directory: website

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v5
with:
path: website/build # Ensure the path is correctly set to the Docusaurus build output

deploy:
name: Deploy to GitHub Pages
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
with:
working-directory: website/build # Ensures the correct directory is used for deployment
31 changes: 31 additions & 0 deletions .github/workflows/test-web-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test deployment

on:
pull_request:
branches:
- main
paths:
- 'website/**'

jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- uses: actions/setup-node@v7
with:
node-version: 20
cache: yarn
cache-dependency-path: website/yarn.lock

- name: Install dependencies
run: yarn install --frozen-lockfile
working-directory: website

- name: Test build website
run: yarn build
working-directory: website
Loading
Loading