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
36 changes: 36 additions & 0 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test against SDK main

# Exercises the example app against the unreleased Castle Python SDK (main
# branch). This is the permanent test/sdk-main branch: every push to it runs
# the suite against the latest main. Nightly/manual runs require this file to
# also live on the default branch (GitHub only honours schedule/workflow_dispatch
# from the default branch).
on:
push:
branches: [test/sdk-main]
workflow_dispatch:
schedule:
- cron: "0 6 * * *"

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'

- name: Point the app at the SDK main branch
run: ./scripts/set-sdk-version.sh main

- run: pip install -r requirements-dev.txt

- name: Byte-compile sources
run: python -m py_compile app.py castle_config.py demo_config.py

- name: Run tests
run: pytest
32 changes: 32 additions & 0 deletions scripts/set-sdk-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Point the example app at a specific Castle Python SDK source.
#
# set-sdk-version.sh main -> track the SDK's main branch (pre-release testing)
# set-sdk-version.sh 7.3.0 -> pin the released >=7.3.0,<8 package from PyPI
#
# Rewrites the castle requirement in requirements.txt.
set -euo pipefail

target="${1:?usage: set-sdk-version.sh <main|X.Y.Z>}"

python3 - "$target" <<'PY'
import re
import sys

target = sys.argv[1]
path = "requirements.txt"
with open(path) as f:
content = f.read()

if target == "main":
line = "castle @ git+https://github.com/castle/castle-python.git@main"
else:
major = int(target.split(".")[0])
line = f"castle>={target},<{major + 1}"

updated, count = re.subn(r"^castle\b.*$", line, content, flags=re.M)
if count == 0:
sys.exit("no castle requirement found in requirements.txt")
with open(path, "w") as f:
f.write(updated)
PY