Skip to content

Commit

Permalink
[#17] add jobs for checking for changes for OAS files
Browse files Browse the repository at this point in the history
  • Loading branch information
SonnyBA committed Jun 28, 2024
1 parent 2253c12 commit 6b4017d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,66 @@ jobs:
- name: Publish coverage report
uses: codecov/codecov-action@v3

generate-oas-files:
name: Generate and upload OAS files for all versions
needs: tests
runs-on: ubuntu-latest
strategy:
matrix:
version: ['v1', 'v2']
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- 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 codecov

- name: Generate OAS files
run: ./bin/generate_schema.sh ${{ matrix.version }} openapi-${{ matrix.version }}.yaml

- name: Store generated OAS files
uses: actions/upload-artifact@4
with:
name: objects-api-${{ matrix.version }}-oas
path: openapi-${{ matrix.component }}.yaml
retention-days: 1

oas-up-to-date:
name: Check for unexepected OAS changes
needs: generate-oas-files
runs-on: ubuntu-latest
strategy:
matrix:
component: ['v1', 'v2']
steps:
- uses: actions/checkout@v4
- name: Download generated OAS
uses: actions/download-artifact@v4
with:
name: objects-api-${{ matrix.version }}-oas
- name: Check for OAS changes
run: |
diff openapi-${{ matrix.component }}.yaml src/objects/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
docker:
needs: tests

Expand Down
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/objects/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

0 comments on commit 6b4017d

Please sign in to comment.