Repository navigation
Consolidate environment configuration and update test documentation #305
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7c115fd
chore: consolidate environment configuration
tacianosilva 796d7d9
chore: set example database credentials
tacianosilva 76663fc
docs: update test execution commands
tacianosilva 0681371
fix: make environment example sourceable
tacianosilva bd9e382
Merge branch 'main' into agents/test-database-permission-issues
tacianosilva 30237c7
fix: load session settings from environment
tacianosilva 8422ada
chore: remove obsolete plotting code
tacianosilva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| DJANGO_SETTINGS_MODULE=suggestclasses.settings | ||
| ALLOWED_HOSTS='localhost, 127.0.0.1, labens.dct.ufrn.br' | ||
|
|
||
| SECRET_KEY='your-secret-key-here' | ||
| DEBUG=True | ||
|
|
||
| CSRF_COOKIE_SECURE=True | ||
|
|
||
| # CORS | ||
| CORS_ALLOW_ALL_ORIGINS=True | ||
| CORS_ALLOWED_ORIGINS="http://labens.dct.ufrn.br,https://labens.dct.ufrn.br,http://localhost:8003" | ||
| CSRF_TRUSTED_ORIGINS="http://labens.dct.ufrn.br,https://labens.dct.ufrn.br,http://localhost:8003" | ||
| SESSION_COOKIE_AGE=1800 | ||
| SESSION_COOKIE_SECURE=True | ||
| SESSION_EXPIRE_AT_BROWSER_CLOSE=True | ||
| SECURE_CONTENT_TYPE_NOSNIFF=True | ||
| SECURE_BROWSER_XSS_FILTER=True | ||
|
|
||
| SECURE_SSL_REDIRECT=False | ||
| SECURE_HSTS_SECONDS=60 | ||
| SECURE_HSTS_PRELOAD=True | ||
|
|
||
| DATABASE_NAME=scdb_dev | ||
| DATABASE_USER=sc_user | ||
| DATABASE_PASSWORD=sc_pass | ||
|
|
||
| DATABASE_HOST=localhost | ||
| DATABASE_PORT=5432 | ||
|
|
||
| EMAIL_USER=your_email@example.com | ||
| EMAIL_PASS=your_email_password | ||
|
|
||
| PYTHONPATH=${PYTHONPATH}:/code:. | ||
|
|
||
| export DJANGO_SETTINGS_MODULE=suggestclasses.settings | ||
| export PYTHONPATH=${PYTHONPATH}:/data/projetos/suggestclasses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,6 @@ venv.bak/ | |
|
|
||
| dados/*.csv | ||
|
|
||
| path.env | ||
| /static/admin/ | ||
| /static/css/ | ||
| /static/js/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Guide for Coding Agents | ||
|
|
||
| ## Local environment | ||
|
|
||
| - Use the project virtual environment: | ||
|
|
||
| ```bash | ||
| source .venv/bin/activate | ||
| ``` | ||
|
|
||
| - Create local configuration from the tracked template and load it before | ||
| running Django commands or data scripts: | ||
|
|
||
| ```bash | ||
| cp .env.example .env | ||
| # Edit the values required by the local environment. | ||
| source .env | ||
| ``` | ||
|
|
||
| - Do not commit `.env`. It contains local credentials. Keep secrets only in | ||
| local environment files or in CI secrets. | ||
| - `DJANGO_SETTINGS_MODULE=suggestclasses.settings` and `PYTHONPATH` are set by | ||
| `.env`; there is no separate `path.env`. | ||
|
|
||
| ## Database and tests | ||
|
|
||
| - The application reads the default database configuration from | ||
| `DATABASE_NAME`, `DATABASE_USER`, `DATABASE_PASSWORD`, `DATABASE_HOST`, and | ||
| `DATABASE_PORT`. | ||
| - No custom Django test database name is configured. Django uses | ||
| `test_<DATABASE_NAME>`; for example, `DATABASE_NAME=scdb_dev` uses | ||
| `test_scdb_dev`. | ||
| - To let Django create and remove test databases, grant the database role | ||
| `CREATEDB`: | ||
|
|
||
| ```sql | ||
| ALTER ROLE sc_user WITH CREATEDB; | ||
| ``` | ||
|
|
||
| - On PostgreSQL 15+, ensure the role can create objects in the `public` schema | ||
| of the test database. In this environment, the role also needed `INHERIT`: | ||
|
|
||
| ```sql | ||
| ALTER ROLE sc_user INHERIT; | ||
| ``` | ||
|
|
||
| - Run tests with: | ||
|
|
||
| ```bash | ||
| python manage.py test --keepdb | ||
| ``` | ||
|
|
||
| `--keepdb` preserves the test database between executions. | ||
|
|
||
| ## CI | ||
|
|
||
| - The GitHub Actions workflow copies `.env.example` to `.env` and then replaces | ||
| the database credentials with those of its PostgreSQL service | ||
| (`postgres`/`postgres`). | ||
| - Keep `.env.example` free of real credentials and compatible with the | ||
| variables read by `suggestclasses/settings.py`. | ||
|
|
||
| ## Session changes recorded | ||
|
|
||
| - Removed the unused `DATABASE_TEST` variable. It was not read by the Django | ||
| settings, which rely on Django's default test database naming. | ||
| - Added `.env.example` at the repository root with placeholders for sensitive | ||
| values. | ||
| - Updated the README and CI workflow to use `.env.example`. | ||
| - Removed the obsolete `contrib/` directory and all `path.env` documentation. | ||
| - Removed the obsolete `contrib/` entry from `CONTRIBUTING.md` and the obsolete | ||
| `path.env` rule from `.gitignore`. | ||
| - The test database permission issue was reproduced and resolved locally after | ||
| granting `CREATEDB` and `INHERIT` to the database role. | ||
| - The test suite still has one unrelated pre-existing failure: | ||
| `core/tests/test_historico.py` uses removed `assertEquals`; use | ||
| `assertEqual` when addressing that test separately. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.