Skip to content

Commit

Permalink
🐛 ensure backwards compatibility of api server (ITISFoundation#6866)
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis authored Dec 6, 2024
1 parent 1f9c110 commit 35f11df
Show file tree
Hide file tree
Showing 23 changed files with 452 additions and 1,783 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/ci-testing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2655,6 +2655,8 @@ jobs:
system-test-environment-setup,
system-test-public-api,
system-test-swarm-deploy,
system-api-specs,
system-backwards-compatibility
]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -2719,3 +2721,78 @@ jobs:
env:
TAG_PREFIX: hotfix-staging-github
run: ./ci/deploy/dockerhub-deploy.bash -n

system-api-specs:
needs: [changes]
if: ${{ needs.changes.outputs.anything-py == 'true' || github.event_name == 'push' }}
timeout-minutes: 10
name: "[sys] check api-specs are up to date"
runs-on: ubuntu-latest
steps:
- name: setup python environment
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.4.x"
enable-cache: false
- name: checkout source branch
uses: actions/checkout@v4
- name: Regenerate specs and check
run: |
uv venv .venv && source .venv/bin/activate
make openapi-specs
./ci/github/helpers/openapi-specs-diff.bash diff \
https://raw.githubusercontent.com/${{ github.event.pull_request.head.repo.full_name }}/refs/heads/${{ github.event.pull_request.head.ref }} \
.
system-backwards-compatibility:
needs: [changes, system-api-specs]
if: ${{ needs.changes.outputs.anything-py == 'true' || github.event_name == 'push' }}
timeout-minutes: 10
name: "[sys] api-server backwards compatibility"
runs-on: ubuntu-latest
steps:
- name: setup python environment
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.4.x"
enable-cache: false
- name: checkout
uses: actions/checkout@v4
- name: check api-server backwards compatibility
run: |
./scripts/openapi-diff.bash breaking --fail-on ERR\
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 \
/specs/services/api-server/openapi.json
api-spec-backwards-compatibility:
needs: [changes, system-api-specs]
if: ${{ needs.changes.outputs.anything-py == 'true' || github.event_name == 'push' }}
continue-on-error: true
timeout-minutes: 10
name: "api-specs-backwards-compatibility"
runs-on: ubuntu-latest
steps:
- name: setup python environment
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.4.x"
enable-cache: false
- name: checkout
uses: actions/checkout@v4
- name: Check openapi-specs backwards compatibility
run: |
./ci/github/helpers/openapi-specs-diff.bash breaking \
https://raw.githubusercontent.com/${{ github.event.pull_request.base.repo.full_name }}/refs/heads/${{ github.event.pull_request.base.ref }} \
.
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.DEFAULT_GOAL := help

SHELL := /bin/bash

.SHELLFLAGS := -o errexit -o pipefail -c
MAKE_C := $(MAKE) --no-print-directory --directory

# Operating system
Expand Down Expand Up @@ -84,7 +84,7 @@ export SWARM_STACK_NAME_NO_HYPHEN = $(subst -,_,$(SWARM_STACK_NAME))
export DOCKER_IMAGE_TAG ?= latest
export DOCKER_REGISTRY ?= itisfoundation


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

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

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


.PHONY: _check_venv_active
_check_venv_active:
# Checking whether virtual environment was activated
@python3 -c "import sys; assert sys.base_prefix!=sys.prefix"


## DOCKER BUILD -------------------------------
#
# - all builds are immediatly tagged as 'local/{service}:${BUILD_TARGET}' where BUILD_TARGET='development', 'production', 'cache'
Expand Down Expand Up @@ -573,9 +579,13 @@ new-service: .venv ## Bakes a new project from cookiecutter-simcore-pyservice an


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


.PHONY: settings-schema.json
Expand Down
Loading

0 comments on commit 35f11df

Please sign in to comment.