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

[#17] add jobs for checking for changes for OAS files #167

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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}
Loading