80 lines
2.7 KiB
YAML
80 lines
2.7 KiB
YAML
name: SDK Codegen Drift
|
|
|
|
# Gitea variant of .github/workflows/sdk-codegen.yml. Re-runs the
|
|
# @toolctrl/api-client-ts generation pipeline on PRs that touch the
|
|
# upstream OpenAPI surface or the SDK package, then verifies the
|
|
# committed src/generated/ tree is in sync with openapi.json.
|
|
#
|
|
# Spec: docs/improvement-plan/08-mobile-cli-storybook-sdk/ts-sdk.md
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "apps/api/src/openapi.ts"
|
|
- "apps/api/src/openapi.test.ts"
|
|
- "packages/api-client-ts/**"
|
|
- "packages/api-types/**"
|
|
- ".gitea/workflows/sdk-codegen.yml"
|
|
|
|
env:
|
|
TOOLCTRL_GITEA_HOST_IP: ${{ vars.TOOLCTRL_GITEA_HOST_IP }}
|
|
|
|
jobs:
|
|
drift-check:
|
|
name: Verify SDK codegen is in sync with OpenAPI spec
|
|
runs-on: toolctrl-ci
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Resolve internal Gitea host
|
|
run: |
|
|
if [ -n "${TOOLCTRL_GITEA_HOST_IP:-}" ]; then
|
|
if ! TOOLCTRL_GITEA_HOST_IP="$TOOLCTRL_GITEA_HOST_IP" node -e 'process.exit(require("node:net").isIP(process.env.TOOLCTRL_GITEA_HOST_IP || "") ? 0 : 1)'; then
|
|
echo "TOOLCTRL_GITEA_HOST_IP must be a single IPv4 or IPv6 token"
|
|
exit 1
|
|
fi
|
|
printf '%s git.tool-ctrl.de\n' "$TOOLCTRL_GITEA_HOST_IP" >> /etc/hosts
|
|
fi
|
|
|
|
- name: Checkout PR head
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable
|
|
|
|
- name: Prepare pnpm 10.33.0
|
|
run: corepack prepare pnpm@10.33.0 --activate
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Regenerate OpenAPI capture
|
|
run: pnpm --filter @toolctrl/api-client-ts generate-spec
|
|
|
|
- name: Regenerate typed client (Hey-API)
|
|
run: pnpm --filter @toolctrl/api-client-ts generate
|
|
|
|
- name: Fail if generated code drifts from committed state
|
|
run: |
|
|
if ! git diff --exit-code --stat \
|
|
packages/api-client-ts/openapi.json \
|
|
packages/api-client-ts/src/generated; then
|
|
echo ""
|
|
echo "SDK codegen drift detected. Run:"
|
|
echo ""
|
|
echo " pnpm --filter @toolctrl/api-client-ts generate:all"
|
|
echo ""
|
|
echo "then commit packages/api-client-ts/openapi.json and packages/api-client-ts/src/generated/."
|
|
exit 1
|
|
fi
|
|
echo "SDK codegen is in sync with the upstream OpenAPI spec."
|
|
|
|
- name: Typecheck SDK packages
|
|
run: |
|
|
pnpm --filter @toolctrl/api-client-ts typecheck
|
|
pnpm --filter @toolctrl/api-types typecheck
|
|
|
|
- name: Run SDK tests
|
|
run: |
|
|
pnpm --filter @toolctrl/api-client-ts test
|
|
pnpm --filter @toolctrl/api-types test
|