2024-01-04 20:07:57 +00:00
|
|
|
name: Django CI Pipeline
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- release
|
|
|
|
- testing-pipeline
|
|
|
|
|
|
|
|
jobs:
|
2024-01-14 16:33:35 +00:00
|
|
|
test:
|
2024-01-04 20:07:57 +00:00
|
|
|
|
2024-01-09 08:58:00 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2024-01-04 20:07:57 +00:00
|
|
|
|
2024-01-14 16:33:35 +00:00
|
|
|
env:
|
|
|
|
SECRET_KEY: "t3st_dummy_s3cr3t_k3y"
|
|
|
|
|
2024-01-04 20:07:57 +00:00
|
|
|
steps:
|
2024-01-04 20:20:32 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-04 20:07:57 +00:00
|
|
|
|
2024-01-12 08:49:08 +00:00
|
|
|
- name: Install python3-venv
|
2024-01-12 09:00:13 +00:00
|
|
|
id: install
|
2024-01-12 08:49:08 +00:00
|
|
|
run: |
|
2024-01-12 09:18:14 +00:00
|
|
|
apt-get update
|
2024-01-12 09:22:18 +00:00
|
|
|
apt-get install python3 python3-venv python3-pip -y
|
2024-01-12 09:18:14 +00:00
|
|
|
|
|
|
|
- name: Check Python version
|
|
|
|
run: |
|
|
|
|
python3 --version
|
2024-01-12 08:49:08 +00:00
|
|
|
|
2024-01-12 08:47:44 +00:00
|
|
|
- name: Create virtual environment
|
|
|
|
run: |
|
|
|
|
python3 -m venv venv
|
|
|
|
source venv/bin/activate
|
2024-01-12 09:25:00 +00:00
|
|
|
echo "Virtual environment created successfully"
|
2024-01-12 09:00:13 +00:00
|
|
|
# https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context
|
|
|
|
if: steps.install.outcome == 'success'
|
2024-01-12 08:47:44 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
2024-01-12 09:25:00 +00:00
|
|
|
source venv/bin/activate
|
2024-01-12 08:47:44 +00:00
|
|
|
pip install --upgrade pip
|
|
|
|
pip install -r requirements.txt
|
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
|
|
|
source venv/bin/activate
|
2024-01-14 18:38:22 +00:00
|
|
|
# https://stackoverflow.com/questions/61747698/django-error-when-running-server-locally-attributeerror-list-object-has-no
|
|
|
|
pip uninstall subprocess.run
|
2024-01-14 18:33:31 +00:00
|
|
|
python3 manage.py test
|
2024-01-04 20:07:57 +00:00
|
|
|
|