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
60 changes: 47 additions & 13 deletions .github/workflows/sync-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ jobs:
echo "kind=breaking" >> "$GITHUB_OUTPUT"
fi

# Public repos cloned outside the workspace, so nothing here can end up in the bot's commit.
- name: List what the integrations lack
if: steps.sync.outputs.changed == 'true'
continue-on-error: true
timeout-minutes: 5
env:
GIT_TERMINAL_PROMPT: "0"
run: |
dir="$RUNNER_TEMP/integrations"
mkdir -p "$dir"
for repo in integration-n8n integration-make integration-zapier; do
git clone --quiet --depth 1 "https://github.com/geonodecom/$repo.git" "$dir/$repo" \
|| echo "::warning::Could not clone geonodecom/$repo"
done
python scripts/integration_gaps.py --before "$RUNNER_TEMP/openapi.before.json" --after openapi.json \
--sources "$dir" --out "$RUNNER_TEMP/integrations.md"

- name: Get an integrations bot token
id: app-token
if: steps.sync.outputs.changed == 'true'
Expand Down Expand Up @@ -117,18 +134,6 @@ jobs:
fi
fi

bot_id=$(gh api "/users/${BOT_LOGIN}" --jq .id)
git config user.name "$BOT_LOGIN"
git config user.email "${bot_id}+${BOT_LOGIN}@users.noreply.github.com"
git checkout -B "$SYNC_BRANCH"
git add -A
git commit --quiet -m "Sync API spec with production"
if [ -n "$pr" ] && [ -n "$remote_sha" ] && git diff --quiet "$remote_sha" HEAD; then
echo "Pull request #$pr already has these changes." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
git push --quiet --force-with-lease="$SYNC_BRANCH:$remote_sha" origin "$SYNC_BRANCH"

{
cat "$RUNNER_TEMP/summary.md"
if [ -s "$RUNNER_TEMP/sync-notes.md" ]; then
Expand All @@ -137,6 +142,16 @@ jobs:
head -c 10000 "$RUNNER_TEMP/sync-notes.md"
echo
fi
# Before the oasdiff blocks, so the 60,000-byte cut below reaches them first.
if [ -s "$RUNNER_TEMP/integrations.md" ]; then
cat "$RUNNER_TEMP/integrations.md"
echo
else
echo "## Integrations: n8n, Make, Zapier"
echo
echo "The integration check did not run; see [the workflow log]($RUN_URL)."
echo
fi
echo "## oasdiff: $KIND"
echo
echo '```text'
Expand All @@ -152,7 +167,26 @@ jobs:
echo "</details>"
echo
echo "Opened by the nightly [Sync API spec]($RUN_URL) workflow."
} | head -c 60000 > "$RUNNER_TEMP/body.md"
} > "$RUNNER_TEMP/body.full.md"
# Cut from a file: piping into head would end the writer with SIGPIPE, which fails this step.
head -c 60000 "$RUNNER_TEMP/body.full.md" > "$RUNNER_TEMP/body.md"

bot_id=$(gh api "/users/${BOT_LOGIN}" --jq .id)
git config user.name "$BOT_LOGIN"
git config user.email "${bot_id}+${BOT_LOGIN}@users.noreply.github.com"
git checkout -B "$SYNC_BRANCH"
git add -A
git commit --quiet -m "Sync API spec with production"
if [ -n "$pr" ] && [ -n "$remote_sha" ] && git diff --quiet "$remote_sha" HEAD; then
# The code is the same, but the integrations section may have changed since.
if gh pr edit "$pr" --body-file "$RUNNER_TEMP/body.md"; then
echo "Pull request #$pr already has these changes; its description was refreshed." >> "$GITHUB_STEP_SUMMARY"
else
echo "::warning::Could not refresh the description of pull request #$pr"
fi
exit 0
fi
git push --quiet --force-with-lease="$SYNC_BRANCH:$remote_sha" origin "$SYNC_BRANCH"

existing=$(gh label list --limit 500 --json name --jq '.[].name')
for spec in "api-sync:1d76db" "breaking:d73a4a" "additive:0e8a16"; do
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The tests use local fixtures and mocks; they do not require an API key. Never in

The runtime client is generated from `openapi.json`. Update the contract and generation/postprocessing scripts when changing generated behavior, and add a focused regression test. To regenerate, run `bash scripts/generate.sh`. It uses the included contract and the generator version recorded in `.openapi-generator/VERSION`. Install `uv` (recommended) or the matching `openapi-generator-cli` and a Java runtime first, plus Python 3 for filtering and postprocessing.

Every night the `Sync API spec` workflow compares `openapi.json` with production (`scripts/sync_openapi.py`, kept in step with the one in [geonodecom/sdk-typescript](https://github.com/geonodecom/sdk-typescript)), regenerates the client and keeps one pull request from the integrations bot up to date, on the `bot/openapi-sync` branch. It is labelled `breaking` or `additive` by oasdiff and adds a changelog entry under `[Unreleased]`. Review it like any other pull request; its "Needs attention" section lists what postprocessing could not do on its own, such as a hand edit whose generated code changed. When a breaking change fails the tests, push the fixes to that branch: the workflow leaves a branch with commits from people alone until its pull request is merged or closed. Merging publishes nothing. To run the same comparison locally, use `python3 scripts/sync_openapi.py` and then `bash scripts/generate.sh`.
Every night the `Sync API spec` workflow compares `openapi.json` with production (`scripts/sync_openapi.py`, kept in step with the one in [geonodecom/sdk-typescript](https://github.com/geonodecom/sdk-typescript)), regenerates the client and keeps one pull request from the integrations bot up to date, on the `bot/openapi-sync` branch. It is labelled `breaking` or `additive` by oasdiff and adds a changelog entry under `[Unreleased]`. Review it like any other pull request; its "Needs attention" section lists what postprocessing could not do on its own, such as a hand edit whose generated code changed. Its "Integrations" section lists what the change removes that the hand-written n8n, Make and Zapier integrations still use, and what it adds that they lack (`scripts/integration_gaps.py`, kept in step with the one in [geonodecom/sdk-typescript](https://github.com/geonodecom/sdk-typescript); read from their source, so a pointer rather than a verdict). With clones of the three repositories in one directory, `python3 scripts/integration_gaps.py --after openapi.json --sources <dir>` prints today's coverage. The bot rewrites the pull request description each night, so leave notes as comments. When a breaking change fails the tests, push the fixes to that branch: the workflow leaves a branch with commits from people alone until its pull request is merged or closed. Merging publishes nothing. To run the same comparison locally, use `python3 scripts/sync_openapi.py` and then `bash scripts/generate.sh`.

## Reports and releases

Expand Down
Loading
Loading