Skip to content

Commit

Permalink
[#17] add CI jobs to detect uncommitted OAS changes (#204)
Browse files Browse the repository at this point in the history
* [#17] add CI jobs to detect uncommitted OAS changes
  • Loading branch information
SonnyBA authored Jul 17, 2024
1 parent a707c4f commit bba6e02
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 10 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ jobs:
with:
node-version: '18'

- name: Install system packages
run: |
sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends
- name: Install dependencies
run: pip install -r requirements/dev.txt codecov
- name: Build frontend
Expand Down
39 changes: 38 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "code scan"
name: Code quality checks

on:
push:
Expand Down Expand Up @@ -74,3 +74,40 @@ jobs:
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

oas-up-to-date:
name: Check for unexepected OAS changes
runs-on: ubuntu-latest
strategy:
matrix:
component: ['contactgegevens', 'klantinteracties']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'requirements/*.txt'
- uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: pip install -r requirements/ci.txt

- name: Generate OAS files
run: ./bin/generate_schema_for_component.sh ${{ matrix.component }} openapi-${{ matrix.component }}.yaml
env:
DJANGO_SETTINGS_MODULE: openklant.conf.ci

- name: Check for OAS changes
run: |
diff openapi-${{ matrix.component }}.yaml src/openklant/components/${{ matrix.component }}/openapi.yaml
- name: Write failure markdown
if: ${{ failure() }}
run: |
echo 'Run the following command locally and commit the changes' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo './bin/generate_schema_for_component.sh ${{ matrix.component }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
6 changes: 4 additions & 2 deletions bin/generate_schema_for_component.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

set -e

if [[ -z "$VIRTUAL_ENV" ]]; then
if [[ -z "$VIRTUAL_ENV" ]] && [[ ! -v GITHUB_ACTIONS ]]; then
echo "You need to activate your virtual env before running this script"
exit 1
fi
Expand All @@ -17,9 +17,11 @@ fi
export SUBPATH=/$1/api
export SCHEMA_PATH=src/openklant/components/$1

OUTPUT_FILE=$2

echo "Generating OAS schema for $1..."
src/manage.py spectacular_for_component \
--file $SCHEMA_PATH/openapi.yaml \
--file ${OUTPUT_FILE:-$SCHEMA_PATH/openapi.yaml} \
--component $1

echo "Done."
6 changes: 6 additions & 0 deletions src/openklant/components/contactgegevens/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ components:
minLength: 4
PaginatedOrganisatieList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -424,6 +427,9 @@ components:
$ref: '#/components/schemas/Organisatie'
PaginatedPersoonList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand Down
51 changes: 48 additions & 3 deletions src/openklant/components/klantinteracties/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3330,13 +3330,11 @@ components:
afgehandeldOp:
type: string
format: date-time
readOnly: true
nullable: true
description: 'Datum en tijdstip wanneer de interne taak was afgehandeld:
EXPERIMENTEEL.'
required:
- aanleidinggevendKlantcontact
- afgehandeldOp
- gevraagdeHandeling
- status
- toegewezenAanActor
Expand Down Expand Up @@ -3560,6 +3558,9 @@ components:
maxLength: 200
PaginatedActorKlantcontactList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3580,6 +3581,9 @@ components:
$ref: '#/components/schemas/ActorKlantcontact'
PaginatedActorList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3600,6 +3604,9 @@ components:
$ref: '#/components/schemas/Actor'
PaginatedBetrokkeneList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3620,6 +3627,9 @@ components:
$ref: '#/components/schemas/Betrokkene'
PaginatedBijlageList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3640,6 +3650,9 @@ components:
$ref: '#/components/schemas/Bijlage'
PaginatedCategorieList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3660,6 +3673,9 @@ components:
$ref: '#/components/schemas/Categorie'
PaginatedCategorieRelatieList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3680,6 +3696,9 @@ components:
$ref: '#/components/schemas/CategorieRelatie'
PaginatedDigitaalAdresList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3700,6 +3719,9 @@ components:
$ref: '#/components/schemas/DigitaalAdres'
PaginatedExpandKlantcontactList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3720,6 +3742,9 @@ components:
$ref: '#/components/schemas/ExpandKlantcontact'
PaginatedExpandPartijList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3740,6 +3765,9 @@ components:
$ref: '#/components/schemas/ExpandPartij'
PaginatedInterneTaakList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3760,6 +3788,9 @@ components:
$ref: '#/components/schemas/InterneTaak'
PaginatedKlantcontactList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3780,6 +3811,9 @@ components:
$ref: '#/components/schemas/Klantcontact'
PaginatedOnderwerpobjectList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3800,6 +3834,9 @@ components:
$ref: '#/components/schemas/Onderwerpobject'
PaginatedPartijIdentificatorList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3820,6 +3857,9 @@ components:
$ref: '#/components/schemas/PartijIdentificator'
PaginatedPartijList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3840,6 +3880,9 @@ components:
$ref: '#/components/schemas/Partij'
PaginatedRekeningnummerList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -3860,6 +3903,9 @@ components:
$ref: '#/components/schemas/Rekeningnummer'
PaginatedVertegenwoordigdenList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand Down Expand Up @@ -4504,7 +4550,6 @@ components:
afgehandeldOp:
type: string
format: date-time
readOnly: true
nullable: true
description: 'Datum en tijdstip wanneer de interne taak was afgehandeld:
EXPERIMENTEEL.'
Expand Down

0 comments on commit bba6e02

Please sign in to comment.