Skip to content

Commit 1a8fc31

Browse files
authored
Update unit-tests.yml
1 parent 1049d8d commit 1a8fc31

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

.github/workflows/unit-tests.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Set up Python
3939
uses: actions/setup-python@v4
4040
with:
41-
python-version: '3.10' # Используем Python 3.10, так как он совместим с Django 4.2.4
41+
python-version: '3.10'
4242

4343
- name: Install dependencies
4444
run: |
@@ -54,9 +54,17 @@ jobs:
5454
- name: Configure Django settings for testing
5555
run: |
5656
echo "Configuring Django settings for testing..."
57-
cp .env.example .env # Создаем файл окружения (если используется django-environ)
58-
sed -i 's/DATABASE_URL=.*$/DATABASE_URL=postgres:\/\/postgres:postgres@localhost:5432\/testdb/' .env
59-
export $(grep -v '^#' .env | xargs) # Импортируем переменные окружения
57+
# Создаем файл .env, если он не существует
58+
if [ ! -f ".env" ]; then
59+
echo "Creating .env file for testing..."
60+
cat <<-EOF > .env
61+
DEBUG=True
62+
SECRET_KEY=your_secret_key_for_testing
63+
DATABASE_URL=postgres://postgres:postgres@localhost:5432/testdb
64+
EOF
65+
fi
66+
# Импортируем переменные окружения из .env
67+
export $(grep -v '^#' .env | xargs)
6068
6169
- name: Run database migrations
6270
run: |
@@ -71,7 +79,7 @@ jobs:
7179
run: |
7280
if command -v python manage.py &>/dev/null; then
7381
echo "Collecting static files..."
74-
python manage.py collectstatic --noinput
82+
python manage.py collectstatic --noinput --clear
7583
else
7684
echo "manage.py not found. Skipping static collection."
7785
fi

0 commit comments

Comments
 (0)