chore: setup openapi contract gate [AC-INIT]
PR Check (SDD Contract Gate) / contract-level-check (pull_request) Failing after 2s Details

This commit is contained in:
MerCry 2026-02-23 23:03:31 +08:00
parent 6eb0dd2754
commit 465c049d0f
1 changed files with 30 additions and 7 deletions

View File

@ -4,26 +4,49 @@ on:
pull_request: pull_request:
branches: [ main ] branches: [ main ]
paths: paths:
- 'spec/**/openapi.provider.yaml' - '.gitea/workflows/**'
- 'spec/**/openapi.deps.yaml' - 'scripts/**'
- 'spec/**'
- 'src/**' - 'src/**'
jobs: jobs:
contract-level-check: contract-level-check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code (no GitHub dependency)
uses: actions/checkout@v3 shell: sh
run: |
set -eu
# Expect Gitea-provided env vars in the runner
: "${GITEA_SERVER_URL:?GITEA_SERVER_URL is required}"
: "${GITEA_REPOSITORY:?GITEA_REPOSITORY is required}"
: "${GITEA_SHA:?GITEA_SHA is required}"
echo "GITEA_SERVER_URL=$GITEA_SERVER_URL"
echo "GITEA_REPOSITORY=$GITEA_REPOSITORY"
echo "GITEA_SHA=$GITEA_SHA"
git clone "$GITEA_SERVER_URL/$GITEA_REPOSITORY.git" .
git checkout "$GITEA_SHA"
- name: Run OpenAPI Contract Level Check - name: Run OpenAPI Contract Level Check
env: env:
# For PRs targeting main, enforce provider >= L2 # For PRs targeting main, enforce provider >= L2
REQUIRE_PROVIDER_L2: "1" REQUIRE_PROVIDER_L2: "1"
shell: sh
run: | run: |
set -eu
chmod +x scripts/check-openapi-level.sh chmod +x scripts/check-openapi-level.sh
./scripts/check-openapi-level.sh ./scripts/check-openapi-level.sh
- name: YAML Lint (Optional) - name: YAML Parse Check (Optional)
shell: sh
run: | run: |
# Simple check if yq or other linter is not available set -eu
find spec -name "*.yaml" -o -name "*.yml" | xargs -I {} python3 -c "import yaml, sys; yaml.safe_load(open('{}'))" || echo "YAML check skipped or failed" if command -v python3 >/dev/null 2>&1; then
python3 -c "import sys; print('python3:', sys.version.split()[0])"
find spec -name "*.yaml" -o -name "*.yml" | xargs -I {} python3 -c "import yaml; yaml.safe_load(open('{}'))"
else
echo "python3 not available; skip YAML parse check"
fi