Skip to content

Commit

Permalink
rationalised .env files (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
gecBurton authored Oct 4, 2024
1 parent 2778792 commit cfcbfef
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 82 deletions.
69 changes: 0 additions & 69 deletions .env.django

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
mkdir -p data/elastic/
chmod 777 data/elastic/
cp .env.test .env
cp tests/.env.test .env
echo AZURE_OPENAI_ENDPOINT=${{ secrets.AZURE_OPENAI_ENDPOINT }} >> .env
echo AZURE_OPENAI_API_KEY=${{ secrets.AZURE_OPENAI_API_KEY }} >> .env
echo AZURE_OPENAI_MODEL=azure/gpt-4 >> .env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
cd integration
mkdir -p data/elastic/
chmod -R 777 data/
cp .env.integration .env
cp tests/.env.integration .env
echo AZURE_OPENAI_ENDPOINT_4O=${{ secrets.AZURE_OPENAI_ENDPOINT }} >> .env
echo AZURE_OPENAI_API_KEY_4O=${{ secrets.AZURE_OPENAI_API_KEY }} >> .env
echo EMBEDDING_AZURE_OPENAI_ENDPOINT=${{ secrets.AZURE_OPENAI_ENDPOINT }} >> .env
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: |
mkdir -p data/elastic/
chmod 777 data/elastic/
cp .env.test .env
cp tests/.env.test .env
docker compose up -d --wait elasticsearch
- name: Test redbox with pytest
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
run: |
mkdir -p data/elastic/
chmod -R 777 data/
cp .env.test .env
cp tests/.env.test .env
sed -i -e "s/^OBJECT_STORE=.*/OBJECT_STORE=minio/" .env
docker compose up -d --wait elasticsearch minio db
docker ps
Expand Down
6 changes: 3 additions & 3 deletions django_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

## running and testing the django app locally

1. copy `.env.test` to `django_app/.env`
1. copy `tests/.env.test` to `django_app/.env`
2. (re)start postgres and minio `docker-compose up -d db minio`
3. open you IDE at `django_app` and run the tests here, or navigate to `cd django_app`
4. the server can be run locally using `poetry run python manage.py runserver`
5. test can be run .locally using `poetry run pytest`

## running admin commands in docker
1. copy `.env.test` to `.env`
1. copy `tests/.env.test` to `.env`
2. (re)start postgres and minio `docker-compose up -d db minio`
3. run `docker-compose run django-app venv/bin/django-admin <your-management-command>`

## running tests in docker
1. copy `.env.test` to `.env`
1. copy `tests/.env.test` to `.env`
2. (re)start postgres and minio `docker-compose up -d db minio`
3. `make test-django`

Expand Down
2 changes: 1 addition & 1 deletion django_app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ testpaths = "tests"
norecursedirs = "tests/test_ai.py"
env_override_existing_values = 1
env_files = [
".env.test",
"tests/.env.test",
".env"
]
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
networks:
- redbox-app-network
env_file:
- path: .env.integration
- path: tests/.env.integration
required: false
- path: .env
required: false
Expand All @@ -36,7 +36,7 @@ services:
db:
image: postgres:13
env_file:
- path: .env.integration
- path: tests/.env.integration
required: false
- path: .env
required: false
Expand Down Expand Up @@ -65,7 +65,7 @@ services:
dockerfile: django_app/Dockerfile
command: "venv/bin/django-admin qcluster"
env_file:
- path: .env.integration
- path: tests/.env.integration
required: false
- path: .env
required: false
Expand Down
2 changes: 1 addition & 1 deletion docs/DEVELOPER_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The tests should then all load separately and use their own env.

## Setting environment variables

We use `.env` files to populate the environment variables for local development. When cloning the repository the files `.env.test`, `.env.integration` and `.env.example` will be populated.
We use `.env` files to populate the environment variables for local development. When cloning the repository the file `.env.example` will be populated.

To run the project, create a new file called `.env` and populate this file with the setting names from `.env.example` and the values these settings need.

Expand Down
2 changes: 1 addition & 1 deletion redbox-core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ build-backend = "poetry.core.masonry.api"
addopts = "--import-mode=importlib"
env_override_existing_values = 1
env_files = [
".env.test",
"tests/.env.test",
".env"
]
markers = [
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit cfcbfef

Please sign in to comment.