Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): create a CI workflow that generates an OpenAPI schema when a new release is made #2135

Merged
merged 17 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4e72c80
docs: bump API docs version to `2.0.0`
nicomiguelino Nov 18, 2024
d366a1e
chore(workflow): create a workflow for creating an OpenAPI schema
nicomiguelino Nov 19, 2024
1bf8a6e
chore(workflow): temporarily call the OpenAPI workflow during tests
nicomiguelino Nov 19, 2024
dea5e3a
chore(workflows): remove the workflow call to generating the OpenAPI …
nicomiguelino Nov 19, 2024
e06648b
chore(workflow): generate OpenAPI schema as a JSON file instead
nicomiguelino Nov 19, 2024
931ac09
chore(workflow): generate and upload OpenAPI schema when releases are…
nicomiguelino Nov 19, 2024
9dc8052
draft: temporarily comment out stuff
nicomiguelino Nov 19, 2024
1a44651
chore(workflow): fix condition
nicomiguelino Nov 19, 2024
b8c7c5e
draft: debug statements
nicomiguelino Nov 19, 2024
f5a301a
chore(workflow): change trigger from `workflow_call` to `workflow_dis…
nicomiguelino Nov 19, 2024
9e8dcf0
chore(workflow): add workflow permission to create a release
nicomiguelino Nov 19, 2024
402d06b
chore(workflow): set environment of builder to development
nicomiguelino Nov 19, 2024
22eb35f
fix: uncomment steps that were previously commented
nicomiguelino Nov 19, 2024
44a3afb
Merge branch 'master' into bump-api-docs-version
nicomiguelino Nov 22, 2024
c6a9930
Merge branch 'master' into bump-api-docs-version
nicomiguelino Nov 22, 2024
6d72a26
Merge branch 'master' into bump-api-docs-version
nicomiguelino Nov 25, 2024
05fec54
Merge branch 'master' into bump-api-docs-version
nicomiguelino Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build-balena-disk-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ on:
default: 'master'

jobs:
generate-openapi-schema:
uses: ./.github/workflows/generate-openapi-schema.yml
permissions:
contents: write
with:
release: true
tag: ${{ inputs.tag }}
commit: ${{ inputs.commit }}
balena-build-images:
strategy:
matrix:
Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/generate-openapi-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Generate OpenAPI Schema

on:
push:
branches:
- master
paths:
- '**'
- '!webview/**'
- '!website/**'
- '!.github/workflows/deploy-website.yaml'
- '!.github/workflows/build-webview.yaml'
- '!.github/workflows/build-balena-disk-image.yaml'
- '!.github/workflows/python-lint.yaml'
- '!README.md'
- '!docs/**'
- '!bin/install.sh'
- '!bin/upgrade_containers.sh'
- '!tests/**'
pull_request:
branches:
- master
paths:
- '**'
- '!webview/**'
- '!website/**'
- '!.github/workflows/deploy-website.yaml'
- '!.github/workflows/build-webview.yaml'
- '!.github/workflows/build-balena-disk-image.yaml'
- '!.github/workflows/python-lint.yaml'
- '!README.md'
- '!docs/**'
- '!bin/install.sh'
- '!bin/upgrade_containers.sh'
- '!tests/**'
workflow_call:
inputs:
release:
description: 'Upload the OpenAPI schema as a release artifact'
required: true
type: boolean
default: false
tag:
description: 'Tag to be used for the release'
required: true
type: string
commit:
description: 'Commit or branch name'
required: false
type: string
default: 'master'

jobs:
generate-openapi-schema:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-path: ~/.venv
installer-parallel: true

- name: Install dependencies
run: |
poetry install --only=docker-image-builder

- name: Cache Docker layers
uses: actions/cache@v3
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-x86
restore-keys: |
${{ runner.os }}-x86

- name: Build Images
run: |
poetry run python tools/image_builder \
--dockerfiles-only \
--disable-cache-mounts \
--environment=development
docker compose -f docker-compose.dev.yml build

- name: Start the Containers
run: |
docker compose -f docker-compose.dev.yml up -d

- name: Generate OpenAPI Schema
run: |
docker compose -f docker-compose.dev.yml exec anthias-server \
./manage.py spectacular \
--format openapi-json \
--file anthias-api-schema.json

- name: Upload the OpenAPI Schema
uses: actions/upload-artifact@v3
with:
name: anthias-api-schema
path: anthias-api-schema.json

- name: Upload the OpenAPI Schema as a release artifact
if: github.event_name == 'workflow_dispatch' && inputs.release == true
uses: ncipollo/[email protected]
with:
allowUpdates: true
prerelease: true
artifacts: anthias-api-schema.json
tag: ${{ inputs.tag }}
commit: ${{ inputs.commit }}

2 changes: 1 addition & 1 deletion anthias_django/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@

SPECTACULAR_SETTINGS = {
'TITLE': 'Anthias API',
'VERSION': '1.2.0',
'VERSION': '2.0.0',
}

# `django-dbbackup` settings
Expand Down
Loading