-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Feat/build model graph #989
base: main
Are you sure you want to change the base?
Changes from all commits
5a6906e
6d6feb5
27b5b06
3e703fb
266db96
85c49b9
557d498
70e104f
2a6580d
ab139a0
84a404a
d262005
b6244d7
0a5140d
11cba6e
13bc93c
d49643b
df31e8d
6c52f16
5908048
77d1025
784b8ed
15ba619
664cc77
801d5e8
19d1f78
4ac3dba
700bf15
8f60cbb
f5d83ec
240068a
a2dc821
4280f2f
448eae9
023a2c2
8a2b81f
7ad7315
cf24c10
df949e9
f15b224
ed6c4d1
1398fa3
74b3388
2258061
be78e4a
58efa99
cf16d6b
a69e7ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,78 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: Generate Models Graph | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
push: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
paths: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- "backend/apps/**/models/**" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- "pyproject.toml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- "README.md" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
generate-model-graph: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Checkout code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uses: actions/checkout@v3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Set up Python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uses: actions/setup-python@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
python-version: "3.13" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Install Poetry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
python -m pip install poetry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Install system dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sudo apt update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sudo apt install -y graphviz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Create and Populate .env File | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
touch backend/.env # Ensure the file exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_SENTRY_DSN=${{ secrets.DJANGO_SENTRY_DSN }}" >> backend/.env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> backend/.env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> backend/.env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_CONFIGURATION=Test" >> backend/.env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> backend/.env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_DB_PASSWORD=${{ secrets.DJANGO_DB_PASSWORD }}" >> backend/.env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_ALLOWED_HOSTS=*" >> backend/.env # Example of a non-secret variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+34
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consolidate Environment Variable Configuration |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Debug .env file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ls -la backend # Check if the .env file exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cat backend/.env | grep -v DJANGO_DB_PASSWORD | grep -v DJANGO_SECRET_KEY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+34
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Secure the environment variable handling There are several concerns with the current environment variable handling:
Remove the debug step completely and consolidate environment variable handling: - - name: Create and Populate .env File
- run: |
- touch backend/.env # Ensure the file exists
- echo "DJANGO_SENTRY_DSN=${{ secrets.DJANGO_SENTRY_DSN }}" >> backend/.env
- echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> backend/.env
- echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> backend/.env
- echo "DJANGO_CONFIGURATION=Test" >> backend/.env
- echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> backend/.env
- echo "DJANGO_DB_PASSWORD=${{ secrets.DJANGO_DB_PASSWORD }}" >> backend/.env
- echo "DJANGO_ALLOWED_HOSTS=*" >> backend/.env # Example of a non-secret variable
- - name: Debug .env file
- run: |
- ls -la backend # Check if the .env file exists
- cat backend/.env | grep -v DJANGO_DB_PASSWORD | grep -v DJANGO_SECRET_KEY
+ - name: Create environment configuration
+ run: |
+ # Create a single .env file for the workflow
+ touch backend/.env
+ echo "DJANGO_SENTRY_DSN=${{ secrets.DJANGO_SENTRY_DSN }}" >> backend/.env
+ echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> backend/.env
+ echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> backend/.env
+ echo "DJANGO_CONFIGURATION=Test" >> backend/.env
+ echo "DJANGO_SETTINGS_MODULE=settings.test" >> backend/.env
+ echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> backend/.env
+ echo "DJANGO_DB_PASSWORD=${{ secrets.DJANGO_DB_PASSWORD }}" >> backend/.env
+ echo "DJANGO_ALLOWED_HOSTS=*" >> backend/.env 📝 Committable suggestion
Suggested change
Comment on lines
+45
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove Debug Step to Protect Sensitive Information |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Prepare secrets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_SENTRY_DSN=${{ secrets.DJANGO_SENTRY_DSN }}" >> .env.backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> backend/.env.backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_SETTINGS_MODULE=settings.test" >> backend/.env.backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "DJANGO_CONFIGURATION=Test" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> backend/.env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> backend/.env.backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+50
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove Redundant “Prepare Secrets” Step |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Install dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cd backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export $(grep -v '^#' .env.backend | xargs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
poetry install --no-interaction --no-root --with dev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
poetry add pydotplus # Ensure pydotplus is installed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Generate Models Graph | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cd backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
set -a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
source .env.backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
set +a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
poetry run python manage.py graph_models -a -g -o backend_models.png | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+68
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update environment variable sourcing for clarity Since we're consolidating to a single - set -a
- source .env.backend
- set +a
+ # Load environment variables from consolidated .env file
+ set -a
+ source .env
+ set +a 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+66
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use a Consolidated Environment File for Graph Generation |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Upload Artifact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: backend-models-graph | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
path: backend/backend_models.png |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -185,7 +185,7 @@ class Base(Configuration): | |||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" | ||||||
|
||||||
# SECURITY WARNING: keep the secret key used in production secret! | ||||||
SECRET_KEY = values.SecretValue() | ||||||
SECRET_KEY = values.Value() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert SECRET_KEY to SecretValue for security reasons Changing SECRET_KEY from - SECRET_KEY = values.Value()
+ SECRET_KEY = values.SecretValue() This maintains the appropriate security handling for this sensitive configuration value. 📝 Committable suggestion
Suggested change
|
||||||
|
||||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#data-upload-max-number-fields | ||||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 5000 | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ class Test(Base): | |
"""Test configuration.""" | ||
|
||
DEBUG = False | ||
|
||
|
||
INSTALLED_APPS = ("django_extensions",) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right. You shouldn't need the real secrets for building a model relations graph.