Skip to content

Commit

Permalink
[#17] add jobs for checking for changes for OAS files (#167)
Browse files Browse the repository at this point in the history
* [#17] add jobs for checking for changes for OAS files
  • Loading branch information
SonnyBA authored Jul 17, 2024
1 parent 29f010e commit 20732e0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,52 @@ jobs:
run: pip install -r requirements/ci.txt
- name: Run flake8
run: flake8 src

generate-oas-files:
name: Generate and upload OAS files for all components
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions/setup-node@v4
with:
node-version: '16'

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

- name: Generate OAS files
run: ./bin/generate_schema.sh openapi.yaml
env:
DJANGO_SETTINGS_MODULE: nrc.conf.ci

- name: Store generated OAS files
uses: actions/upload-artifact@v4
with:
name: open-notificaties-oas
path: openapi.yaml
retention-days: 1

oas-up-to-date:
name: Check for unexepected OAS changes
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download generated OAS
uses: actions/download-artifact@v4
with:
name: open-notificaties-oas
- name: Check for OAS changes
run: |
diff openapi.yaml src/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' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
6 changes: 4 additions & 2 deletions bin/generate_schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

set -e

if [[ -z "$VIRTUAL_ENV" ]]; then
OUTPUT_FILE=$1

if [[ -z "$VIRTUAL_ENV" ]] && [[ ! -v GITHUB_ACTIONS ]]; then
echo "You need to activate your virtual env before running this script"
exit 1
fi

echo "Generating OAS schema"
src/manage.py spectacular \
--file ./src/openapi.yaml
--file ${OUTPUT_FILE:-./src/openapi.yaml}

0 comments on commit 20732e0

Please sign in to comment.