Skip to content

Commit

Permalink
Swagger GitHub Action (#860)
Browse files Browse the repository at this point in the history
* added github action for checking if Swagger is up

* new action

* try another

* tried implementing check for container

* added curl to docker image

* added check if swagger is up

* test if swagger does not get status code 200

* added ?format=openai to trigger error

* checking that the request is working

* updated CHANGELOG.md
  • Loading branch information
MadsNyl authored Sep 21, 2024
1 parent a17c46d commit 496d536
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,40 @@ jobs:
- name: Check for unstaged migrations
run: docker compose run --rm web python manage.py makemigrations --check --no-input

- name: Tear down the Stack
run: docker compose down

swagger:
runs-on: ubuntu-latest
steps:

- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Build the Stack
run: docker compose build

- name: Run the Stack
run: docker compose up -d

- name: Wait for Docker container to be up
run: |
retries=10
until docker compose exec web curl -f http://localhost:8000/ || [ $retries -eq 0 ]; do
echo "Waiting for container to be up..."
retries=$((retries - 1))
sleep 5
done
- name: Make HTTP Request to Swagger
run: |
status_code=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:8000/swagger/?format=openapi)
if [ "$status_code" -eq 200 ]; then
echo "Swagger UI is up"
else
echo "Failed to reach Swagger UI, status code: $status_code"
exit 1
fi
- name: Tear down the Stack
run: docker compose down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# CHANGELOG

## Tegnforklaring
Expand All @@ -14,6 +15,8 @@

## Neste versjon

-**Swagger**. La til en GitHub Action for å verifisere at Swagger er oppe og går.
-**Swagger**. API dokumentasjon er nå tilgjengelig med Swagger.
-**Profil**. Endret rekkefølge på tidligere arrangementer slik at nyeste kommer først.

## Versjon 2024.09.14
Expand Down
2 changes: 2 additions & 0 deletions compose/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN apt-get update \
&& apt-get install -y build-essential \
# mysqlclient dependencies
&& apt-get install -y default-libmysqlclient-dev \
# curl for making HTTP requests
&& apt-get install -y curl \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
Expand Down

0 comments on commit 496d536

Please sign in to comment.