Files
superset2/.github/workflows/check-openapi-spec-drift.yml
T

72 lines
3.0 KiB
YAML

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Check OpenAPI spec drift
on:
push:
branches:
- "master"
- "[0-9].[0-9]*"
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
# No `paths:` filter on purpose, matching enforce-single-migration-head: a
# required check that never runs for a given PR blocks that PR forever. The
# job is ~10s, so it fires on every PR rather than guessing which file edits
# can move the spec.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check-openapi-spec-drift:
runs-on: ubuntu-26.04
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Python
uses: ./.github/actions/setup-backend/
with:
# base.txt pins apispec, which decides the generated output: 6.10.0
# renders marshmallow 4's unknown=RAISE as "additionalProperties":
# false while the pinned 6.6.1 does not. Regenerating off-pin
# produces a spec no CI run can reproduce.
requirements-type: base
- name: Regenerate the spec
env:
# No SUPERSET_CONFIG_PATH: the published spec documents the routes a
# default deployment registers. A config enabling feature flags adds
# paths that would 404 for everyone who has not enabled them.
SUPERSET__SQLALCHEMY_DATABASE_URI: "sqlite:///:memory:"
FLASK_APP: "superset.app:create_app()"
run: superset update-api-docs
- name: Assert the published spec is up to date
run: |
if ! git diff --quiet -- docs/static/resources/openapi.json; then
echo "::error::docs/static/resources/openapi.json is stale."
echo "Regenerate it on the pinned requirements, with no config file:"
echo " SUPERSET__SQLALCHEMY_DATABASE_URI='sqlite:///:memory:' \\"
echo " FLASK_APP='superset.app:create_app()' superset update-api-docs"
git diff --stat -- docs/static/resources/openapi.json
exit 1
fi