add verify frontend api client
Some checks failed
Test / test-frontend (pull_request) Successful in 21s
Test / frontend-build (pull_request) Failing after 20s
Test / test (pull_request) Has been skipped
Test / lint (pull_request) Has been skipped
Verify / verify-openapi-spec (pull_request) Has been cancelled
Verify / verify-frontend-api-client (pull_request) Has been cancelled
Verify / verify-generated-code (pull_request) Has been cancelled
Some checks failed
Test / test-frontend (pull_request) Successful in 21s
Test / frontend-build (pull_request) Failing after 20s
Test / test (pull_request) Has been skipped
Test / lint (pull_request) Has been skipped
Verify / verify-openapi-spec (pull_request) Has been cancelled
Verify / verify-frontend-api-client (pull_request) Has been cancelled
Verify / verify-generated-code (pull_request) Has been cancelled
This commit is contained in:
83
.github/workflows/verify.yml
vendored
83
.github/workflows/verify.yml
vendored
@@ -110,3 +110,86 @@ jobs:
|
|||||||
- name: Skip OpenAPI generation (no relevant changes)
|
- name: Skip OpenAPI generation (no relevant changes)
|
||||||
if: steps.check_changes.outputs.changed == 'false'
|
if: steps.check_changes.outputs.changed == 'false'
|
||||||
run: echo "No changes in apps/api/src/routes/ nor apps/api/swagger.json, skipping OpenAPI generation verification."
|
run: echo "No changes in apps/api/src/routes/ nor apps/api/swagger.json, skipping OpenAPI generation verification."
|
||||||
|
|
||||||
|
verify-frontend-api-client:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: verify-openapi-spec
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check whether apps/api/swagger.json or apps/frontend/app/generated/api-client changed
|
||||||
|
id: check_swagger_changes
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||||
|
BASE_SHA=${{ github.event.pull_request.base.sha }}
|
||||||
|
HEAD_SHA=${{ github.event.pull_request.head.sha }}
|
||||||
|
else
|
||||||
|
BASE_SHA=${{ github.event.before }}
|
||||||
|
HEAD_SHA=${{ github.sha }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Provide safe fallbacks when GitHub context values are empty (e.g. when using act)
|
||||||
|
if [ -z "$HEAD_SHA" ]; then
|
||||||
|
HEAD_SHA=$(git rev-parse --verify HEAD 2>/dev/null || echo "")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$BASE_SHA" ]; then
|
||||||
|
# Try the parent of HEAD, fall back to HEAD if unavailable
|
||||||
|
PREV=$(git rev-parse --verify "${HEAD_SHA}^" 2>/dev/null || true)
|
||||||
|
if [ -n "$PREV" ]; then
|
||||||
|
BASE_SHA=$PREV
|
||||||
|
else
|
||||||
|
BASE_SHA=$HEAD_SHA
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Comparing $BASE_SHA..$HEAD_SHA"
|
||||||
|
CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" || true)
|
||||||
|
echo "$CHANGED_FILES"
|
||||||
|
|
||||||
|
echo "$CHANGED_FILES" | grep -E '^(apps/api/swagger.json|apps/frontend/app/generated/api-client)' >/dev/null 2>&1 && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Setup PNPM
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
if: steps.check_swagger_changes.outputs.changed == 'true'
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
if: steps.check_swagger_changes.outputs.changed == 'true'
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
cache: 'pnpm'
|
||||||
|
cache-dependency-path: apps/frontend/pnpm-lock.yaml
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
if: steps.check_swagger_changes.outputs.changed == 'true'
|
||||||
|
run: |
|
||||||
|
cd apps/frontend
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Generate frontend API client
|
||||||
|
if: steps.check_swagger_changes.outputs.changed == 'true'
|
||||||
|
run: |
|
||||||
|
cd apps/frontend
|
||||||
|
pnpm generate:openapi
|
||||||
|
|
||||||
|
- name: Check for uncommitted changes in frontend API client
|
||||||
|
if: steps.check_swagger_changes.outputs.changed == 'true'
|
||||||
|
run: |
|
||||||
|
if [[ -n $(git status --porcelain | grep '^ M apps/frontend/app/generated/api-client') ]]; then
|
||||||
|
echo "Frontend API client is not up to date. Please run the API client generation locally and commit the changes."
|
||||||
|
git status --porcelain | grep '^ M apps/frontend/app/generated/api-client'
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Frontend API client is up to date."
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Skip frontend API client generation (no relevant changes)
|
||||||
|
if: steps.check_swagger_changes.outputs.changed == 'false'
|
||||||
|
run: echo "No changes in apps/api/swagger.json nor apps/frontend/app/generated/api-client, skipping frontend API client generation verification."
|
||||||
Reference in New Issue
Block a user