Skip to content

Commit 35f11df

Browse files
🐛 ensure backwards compatibility of api server (#6866)
1 parent 1f9c110 commit 35f11df

File tree

23 files changed

+452
-1783
lines changed

23 files changed

+452
-1783
lines changed

.github/workflows/ci-testing-deploy.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,6 +2655,8 @@ jobs:
26552655
system-test-environment-setup,
26562656
system-test-public-api,
26572657
system-test-swarm-deploy,
2658+
system-api-specs,
2659+
system-backwards-compatibility
26582660
]
26592661
runs-on: ubuntu-latest
26602662
steps:
@@ -2719,3 +2721,78 @@ jobs:
27192721
env:
27202722
TAG_PREFIX: hotfix-staging-github
27212723
run: ./ci/deploy/dockerhub-deploy.bash -n
2724+
2725+
system-api-specs:
2726+
needs: [changes]
2727+
if: ${{ needs.changes.outputs.anything-py == 'true' || github.event_name == 'push' }}
2728+
timeout-minutes: 10
2729+
name: "[sys] check api-specs are up to date"
2730+
runs-on: ubuntu-latest
2731+
steps:
2732+
- name: setup python environment
2733+
uses: actions/setup-python@v5
2734+
with:
2735+
python-version: "3.11"
2736+
- name: install uv
2737+
uses: astral-sh/setup-uv@v4
2738+
with:
2739+
version: "0.4.x"
2740+
enable-cache: false
2741+
- name: checkout source branch
2742+
uses: actions/checkout@v4
2743+
- name: Regenerate specs and check
2744+
run: |
2745+
uv venv .venv && source .venv/bin/activate
2746+
make openapi-specs
2747+
./ci/github/helpers/openapi-specs-diff.bash diff \
2748+
https://raw.githubusercontent.com/${{ github.event.pull_request.head.repo.full_name }}/refs/heads/${{ github.event.pull_request.head.ref }} \
2749+
.
2750+
2751+
system-backwards-compatibility:
2752+
needs: [changes, system-api-specs]
2753+
if: ${{ needs.changes.outputs.anything-py == 'true' || github.event_name == 'push' }}
2754+
timeout-minutes: 10
2755+
name: "[sys] api-server backwards compatibility"
2756+
runs-on: ubuntu-latest
2757+
steps:
2758+
- name: setup python environment
2759+
uses: actions/setup-python@v5
2760+
with:
2761+
python-version: "3.11"
2762+
- name: install uv
2763+
uses: astral-sh/setup-uv@v4
2764+
with:
2765+
version: "0.4.x"
2766+
enable-cache: false
2767+
- name: checkout
2768+
uses: actions/checkout@v4
2769+
- name: check api-server backwards compatibility
2770+
run: |
2771+
./scripts/openapi-diff.bash breaking --fail-on ERR\
2772+
https://raw.githubusercontent.com/${{ github.event.pull_request.base.repo.full_name }}/refs/heads/${{ github.event.pull_request.base.ref }}/services/api-server/openapi.json \
2773+
/specs/services/api-server/openapi.json
2774+
2775+
api-spec-backwards-compatibility:
2776+
needs: [changes, system-api-specs]
2777+
if: ${{ needs.changes.outputs.anything-py == 'true' || github.event_name == 'push' }}
2778+
continue-on-error: true
2779+
timeout-minutes: 10
2780+
name: "api-specs-backwards-compatibility"
2781+
runs-on: ubuntu-latest
2782+
steps:
2783+
- name: setup python environment
2784+
uses: actions/setup-python@v5
2785+
with:
2786+
python-version: "3.11"
2787+
- name: install uv
2788+
uses: astral-sh/setup-uv@v4
2789+
with:
2790+
version: "0.4.x"
2791+
enable-cache: false
2792+
- name: checkout
2793+
uses: actions/checkout@v4
2794+
- name: Check openapi-specs backwards compatibility
2795+
run: |
2796+
./ci/github/helpers/openapi-specs-diff.bash breaking \
2797+
https://raw.githubusercontent.com/${{ github.event.pull_request.base.repo.full_name }}/refs/heads/${{ github.event.pull_request.base.ref }} \
2798+
.

Makefile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
.DEFAULT_GOAL := help
1111

1212
SHELL := /bin/bash
13-
13+
.SHELLFLAGS := -o errexit -o pipefail -c
1414
MAKE_C := $(MAKE) --no-print-directory --directory
1515

1616
# Operating system
@@ -84,7 +84,7 @@ export SWARM_STACK_NAME_NO_HYPHEN = $(subst -,_,$(SWARM_STACK_NAME))
8484
export DOCKER_IMAGE_TAG ?= latest
8585
export DOCKER_REGISTRY ?= itisfoundation
8686

87-
87+
MAKEFILES_WITH_OPENAPI_SPECS := $(shell find . -mindepth 2 -type f -name 'Makefile' -not -path '*/.*' -exec grep -l '^openapi-specs:' {} \; | xargs realpath)
8888

8989
get_my_ip := $(shell (hostname --all-ip-addresses || hostname -i) 2>/dev/null | cut --delimiter=" " --fields=1)
9090

@@ -131,6 +131,12 @@ test_python_version: ## Check Python version, throw error if compilation would f
131131
@.venv/bin/python ./scripts/test_python_version.py
132132

133133

134+
.PHONY: _check_venv_active
135+
_check_venv_active:
136+
# Checking whether virtual environment was activated
137+
@python3 -c "import sys; assert sys.base_prefix!=sys.prefix"
138+
139+
134140
## DOCKER BUILD -------------------------------
135141
#
136142
# - all builds are immediatly tagged as 'local/{service}:${BUILD_TARGET}' where BUILD_TARGET='development', 'production', 'cache'
@@ -573,9 +579,13 @@ new-service: .venv ## Bakes a new project from cookiecutter-simcore-pyservice an
573579

574580

575581
.PHONY: openapi-specs
576-
openapi-specs: ## bundles and validates openapi specifications and schemas of ALL service's API
577-
@$(MAKE_C) services/web/server $@
578-
@$(MAKE_C) services/storage $@
582+
openapi-specs: .env _check_venv_active ## generates and validates openapi specifications and schemas of ALL service's API
583+
@for makefile in $(MAKEFILES_WITH_OPENAPI_SPECS); do \
584+
echo "Generating openapi-specs using $${makefile}"; \
585+
$(MAKE_C) $$(dirname $${makefile}) install-dev; \
586+
$(MAKE_C) $$(dirname $${makefile}) $@; \
587+
printf "%0.s=" {1..100} && printf "\n"; \
588+
done
579589

580590

581591
.PHONY: settings-schema.json

0 commit comments

Comments
 (0)