From 1bc1f0b1ed7d08c1fa07cf4b79a8444cae49a15d Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 7 Sep 2026 17:05:59 +0200 Subject: [PATCH 1/2] Test the example against the SDK main branch. --- .github/workflows/test-develop.yml | 40 ++++++++++++++++++++++++++++++ scripts/set-sdk-version.sh | 30 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/test-develop.yml create mode 100755 scripts/set-sdk-version.sh diff --git a/.github/workflows/test-develop.yml b/.github/workflows/test-develop.yml new file mode 100644 index 0000000..c4fc3be --- /dev/null +++ b/.github/workflows/test-develop.yml @@ -0,0 +1,40 @@ +name: Test against SDK main + +# Exercises the example app against the unreleased Castle PHP SDK (main +# branch). This is the permanent test/sdk-develop 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-develop] + workflow_dispatch: + schedule: + - cron: "0 6 * * *" + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: curl, json + tools: composer + + - name: Point the app at the SDK main branch + run: ./scripts/set-sdk-version.sh main + + - name: Install dependencies + run: composer update castle/castle-php --no-interaction --no-progress + + - name: Lint sources + run: | + find . -path ./vendor -prune -o -name '*.php' -print | xargs -n1 -P4 php -l + + - name: Run tests + run: composer test diff --git a/scripts/set-sdk-version.sh b/scripts/set-sdk-version.sh new file mode 100755 index 0000000..e9bc369 --- /dev/null +++ b/scripts/set-sdk-version.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Point the example app at a specific Castle PHP SDK source. +# +# set-sdk-version.sh main -> track the SDK's main branch (pre-release testing) +# set-sdk-version.sh 4.1.0 -> pin the released ^4.1 package from Packagist +# +# Rewrites the castle/castle-php constraint in composer.json. +set -euo pipefail + +target="${1:?usage: set-sdk-version.sh }" + +python3 - "$target" <<'PY' +import json +import sys + +target = sys.argv[1] +path = "composer.json" +with open(path) as f: + data = json.load(f) + +if target == "main": + data["require"]["castle/castle-php"] = "dev-main" +else: + major, minor = target.split(".")[:2] + data["require"]["castle/castle-php"] = f"^{major}.{minor}" + +with open(path, "w") as f: + json.dump(data, f, indent=2) + f.write("\n") +PY From 0087245cd8e3e88e1c482562796258ee1b8506e1 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 7 Sep 2026 17:16:49 +0200 Subject: [PATCH 2/2] Rename the SDK-main workflow to test-main. --- .github/workflows/{test-develop.yml => test-main.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{test-develop.yml => test-main.yml} (89%) diff --git a/.github/workflows/test-develop.yml b/.github/workflows/test-main.yml similarity index 89% rename from .github/workflows/test-develop.yml rename to .github/workflows/test-main.yml index c4fc3be..9c1858b 100644 --- a/.github/workflows/test-develop.yml +++ b/.github/workflows/test-main.yml @@ -1,13 +1,13 @@ name: Test against SDK main # Exercises the example app against the unreleased Castle PHP SDK (main -# branch). This is the permanent test/sdk-develop branch: every push to it runs +# 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-develop] + branches: [test/sdk-main] workflow_dispatch: schedule: - cron: "0 6 * * *"