Skip to content
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
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
exit 1;
}

- name: Validate SentryMonitor config
- name: 🕮 Validate SentryMonitor config
env:
DOCKER_IMAGE_SERVER: ${{ steps.prep.outputs.tagged_image }}
run: |
Expand All @@ -136,6 +136,23 @@ jobs:
exit 1;
}

- name: Run django migrations
env:
DOCKER_IMAGE_SERVER: ${{ steps.prep.outputs.tagged_image }}
run: docker compose -f ./gh-docker-compose.yml run --rm server ./manage.py test --keepdb -v 2 --pattern="test_fake.py"

# NOTE: Schema generation requires a valid database. Therefore, this step must run after "Run Django migrations."
- name: 🕮 Validate latest openapi schema
env:
DOCKER_IMAGE_SERVER: ${{ steps.prep.outputs.tagged_image }}
run: |
docker compose -f ./gh-docker-compose.yml run --rm server ./manage.py spectacular --file /ci-share/openapi-schema-latest.yaml &&
cmp --silent openapi-schema.yaml ./ci-share/openapi-schema-latest.yaml || {
echo 'The openapi-schema.yaml is not up to date with the latest changes. Please update and push latest';
diff openapi-schema.yaml ./ci-share/openapi-schema-latest.yaml;
exit 1;
}

- name: 🐳 Docker push
if: ${{ inputs.push_docker_image }}
uses: docker/build-push-action@v6
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# GO Risk Module Backend

## Backend Server Setup

```
# Copy sample/development .env
cp .env-sample .env
Expand All @@ -11,7 +13,14 @@ docker compose build
docker compose-up
```

Navigate with server `localhost:9001`

## Run Migrations

`docker compose exec server bash -c python manage.py migrate`

Navigate with server `localhost:9001`
## Update openapi schema (openapi-schema.yaml)

```bash
docker compose run --rm server ./manage.py spectacular --file /ci-share/openapi-schema-latest.yaml
```
13 changes: 13 additions & 0 deletions common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ def logging_response_context(response: requests.Response) -> dict:
},
}
)


def sort_dict_recursively(d):
if isinstance(d, dict):
return {k: sort_dict_recursively(d[k]) for k in sorted(d)}
elif isinstance(d, list):
return [sort_dict_recursively(item) for item in d]
else:
return d


def postprocess_schema(result, **kwargs):
return sort_dict_recursively(result)
5 changes: 1 addition & 4 deletions imminent/sources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

def parse_timestamp(timestamp):
# NOTE: all timestamp are in millisecond and with timezone `utc`
return timezone.make_aware(
# FIXME: Using deprecated function
datetime.datetime.utcfromtimestamp(int(timestamp) / 1000)
)
return timezone.make_aware(datetime.datetime.fromtimestamp(int(timestamp) / 1000, tz=datetime.timezone.utc))


class CountryQuery:
Expand Down
Loading
Loading