Skip to content

Commit

Permalink
[#17] add CI jobs to detect uncommitted OAS changes (#121)
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 8e599c5 commit 1e74635
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
gdal-bin
- name: Install dependencies
run: pip install -r requirements/ci.txt codecov
run: pip install -r requirements/ci.txt
- name: Build frontend
run: |
npm ci
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,45 @@ jobs:
- name: Run black
run: |
black --check src
oas-up-to-date:
name: Check for unexepected OAS changes
runs-on: ubuntu-latest
strategy:
matrix:
version: ['v1', 'v2']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install system packages
run: |
sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends \
libgdal-dev \
gdal-bin
- name: Install dependencies
run: pip install -r requirements/ci.txt

- name: Generate OAS files
run: ./bin/generate_schema.sh ${{ matrix.version }} openapi-${{ matrix.version }}.yaml
env:
DJANGO_SETTINGS_MODULE: objecttypes.conf.ci

- name: Check for OAS changes
run: |
diff openapi-${{ matrix.version }}.yaml src/objecttypes/api/${{ matrix.version }}/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.sh ${{ matrix.version }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
4 changes: 3 additions & 1 deletion bin/generate_schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ fi

export SCHEMA_PATH=src/objecttypes/api/$1/openapi.yaml

src/manage.py spectacular --file $SCHEMA_PATH --validate --api-version $1
OUTPUT_FILE=$2

src/manage.py spectacular --file ${OUTPUT_FILE:-$SCHEMA_PATH} --validate --api-version $1
103 changes: 76 additions & 27 deletions src/objecttypes/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ paths:
/objecttypes:
get:

Check warning on line 41 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objecttype_list
description: ''
parameters:
- in: query
name: dataClassification
Expand All @@ -51,7 +50,13 @@ paths:
- intern
- open
- strictly_confidential
description: Confidential level of the object type
description: |-
Confidential level of the object type
* `open` - Open
* `intern` - Intern
* `confidential` - Confidential
* `strictly_confidential` - Strictly confidential
tags:
- Objecttypes
security:
Expand All @@ -67,7 +72,6 @@ paths:
description: OK
post:

Check warning on line 73 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objecttype_create
description: ''
parameters:
- in: header
name: Content-Type
Expand Down Expand Up @@ -97,7 +101,6 @@ paths:
/objecttypes/{objecttype_uuid}/versions:
get:

Check warning on line 102 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objectversion_list
description: ''
parameters:
- in: path
name: objecttype_uuid
Expand All @@ -121,7 +124,6 @@ paths:
description: OK
post:

Check warning on line 125 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objectversion_create
description: ''
parameters:
- in: header
name: Content-Type
Expand Down Expand Up @@ -157,7 +159,6 @@ paths:
/objecttypes/{objecttype_uuid}/versions/{version}:
get:

Check warning on line 160 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objectversion_read
description: ''
parameters:
- in: path
name: objecttype_uuid
Expand All @@ -171,6 +172,7 @@ paths:
schema:
type: integer
maximum: 32767
minimum: 0
description: Integer version of the OBJECTTYPE
required: true
tags:
Expand All @@ -186,7 +188,6 @@ paths:
description: OK
put:

Check warning on line 189 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objectversion_update
description: ''
parameters:
- in: header
name: Content-Type
Expand All @@ -208,6 +209,7 @@ paths:
schema:
type: integer
maximum: 32767
minimum: 0
description: Integer version of the OBJECTTYPE
required: true
tags:
Expand All @@ -228,7 +230,6 @@ paths:
description: OK
patch:

Check warning on line 231 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objectversion_partial_update
description: ''
parameters:
- in: header
name: Content-Type
Expand All @@ -250,6 +251,7 @@ paths:
schema:
type: integer
maximum: 32767
minimum: 0
description: Integer version of the OBJECTTYPE
required: true
tags:
Expand All @@ -270,7 +272,6 @@ paths:
description: OK
delete:

Check warning on line 273 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objectversion_delete
description: ''
parameters:
- in: path
name: objecttype_uuid
Expand All @@ -284,6 +285,7 @@ paths:
schema:
type: integer
maximum: 32767
minimum: 0
description: Integer version of the OBJECTTYPE
required: true
tags:
Expand All @@ -296,7 +298,6 @@ paths:
/objecttypes/{uuid}:
get:

Check warning on line 299 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objecttype_read
description: ''
parameters:
- in: path
name: uuid
Expand All @@ -318,7 +319,6 @@ paths:
description: OK
put:

Check warning on line 320 in src/objecttypes/api/v1/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with version v1

operation-description Operation `description` must be present and non-empty string.
operationId: objecttype_update
description: ''
parameters:
- in: header
name: Content-Type
Expand Down Expand Up @@ -354,7 +354,6 @@ paths:
description: OK
patch:
operationId: objecttype_partial_update
description: ''
parameters:
- in: header
name: Content-Type
Expand Down Expand Up @@ -389,7 +388,6 @@ paths:
description: OK
delete:
operationId: objecttype_delete
description: ''
parameters:
- in: path
name: uuid
Expand All @@ -414,6 +412,11 @@ components:
- confidential
- strictly_confidential
type: string
description: |-
* `open` - Open
* `intern` - Intern
* `confidential` - Confidential
* `strictly_confidential` - Strictly confidential
ObjectType:
type: object
properties:
Expand Down Expand Up @@ -444,7 +447,13 @@ components:
dataClassification:
allOf:
- $ref: '#/components/schemas/DataClassificationEnum'
description: Confidential level of the object type
description: |-
Confidential level of the object type
* `open` - Open
* `intern` - Intern
* `confidential` - Confidential
* `strictly_confidential` - Strictly confidential
maintainerOrganization:
type: string
description: Organization which is responsible for the object type
Expand All @@ -470,7 +479,16 @@ components:
updateFrequency:
allOf:
- $ref: '#/components/schemas/UpdateFrequencyEnum'
description: Indicates how often the object type is updated
description: |-
Indicates how often the object type is updated
* `real_time` - Real-time
* `hourly` - Hourly
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
* `yearly` - Yearly
* `unknown` - Unknown
providerOrganization:
type: string
description: Organization which is responsible for publication of the object
Expand All @@ -482,8 +500,6 @@ components:
description: Link to the documentation for the object type
maxLength: 200
labels:
type: object
additionalProperties: {}
description: Key-value pairs of keywords related for the object type
createdAt:
type: string
Expand Down Expand Up @@ -537,10 +553,13 @@ components:
status:
allOf:
- $ref: '#/components/schemas/StatusEnum'
description: Status of the object type version
description: |-
Status of the object type version
* `published` - Published
* `draft` - Draft
* `deprecated` - Deprecated
jsonSchema:
type: object
additionalProperties: {}
title: JSON schema
description: JSON schema for Object validation
createdAt:
Expand All @@ -557,6 +576,7 @@ components:
type: string
format: date
readOnly: true
nullable: true
title: Published_at
description: Date when the version was published
PatchedObjectType:
Expand Down Expand Up @@ -589,7 +609,13 @@ components:
dataClassification:
allOf:
- $ref: '#/components/schemas/DataClassificationEnum'
description: Confidential level of the object type
description: |-
Confidential level of the object type
* `open` - Open
* `intern` - Intern
* `confidential` - Confidential
* `strictly_confidential` - Strictly confidential
maintainerOrganization:
type: string
description: Organization which is responsible for the object type
Expand All @@ -615,7 +641,16 @@ components:
updateFrequency:
allOf:
- $ref: '#/components/schemas/UpdateFrequencyEnum'
description: Indicates how often the object type is updated
description: |-
Indicates how often the object type is updated
* `real_time` - Real-time
* `hourly` - Hourly
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
* `yearly` - Yearly
* `unknown` - Unknown
providerOrganization:
type: string
description: Organization which is responsible for publication of the object
Expand All @@ -627,8 +662,6 @@ components:
description: Link to the documentation for the object type
maxLength: 200
labels:
type: object
additionalProperties: {}
description: Key-value pairs of keywords related for the object type
createdAt:
type: string
Expand Down Expand Up @@ -679,10 +712,13 @@ components:
status:
allOf:
- $ref: '#/components/schemas/StatusEnum'
description: Status of the object type version
description: |-
Status of the object type version
* `published` - Published
* `draft` - Draft
* `deprecated` - Deprecated
jsonSchema:
type: object
additionalProperties: {}
title: JSON schema
description: JSON schema for Object validation
createdAt:
Expand All @@ -699,6 +735,7 @@ components:
type: string
format: date
readOnly: true
nullable: true
title: Published_at
description: Date when the version was published
StatusEnum:
Expand All @@ -707,6 +744,10 @@ components:
- draft
- deprecated
type: string
description: |-
* `published` - Published
* `draft` - Draft
* `deprecated` - Deprecated
UpdateFrequencyEnum:
enum:
- real_time
Expand All @@ -717,6 +758,14 @@ components:
- yearly
- unknown
type: string
description: |-
* `real_time` - Real-time
* `hourly` - Hourly
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
* `yearly` - Yearly
* `unknown` - Unknown
securitySchemes:
tokenAuth:
type: apiKey
Expand Down
Loading

0 comments on commit 1e74635

Please sign in to comment.