buttons are good! #50
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
name: Django Tests | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Create credentials.py | |
run: | | |
cp credentials_example.py credentials.py | |
- name: Run Django Tests | |
run: | | |
coverage run manage.py test | |
coverage report | |
generate_data: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Create credentials.py | |
run: | | |
cp credentials_example.py credentials.py | |
- name: Run Migrations and Generate Blog Posts | |
run: | | |
python manage.py migrate | |
python manage.py generate_blog_posts 100 | |
performance_tests: | |
runs-on: ubuntu-latest | |
needs: generate_data | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Create credentials.py | |
run: | | |
cp credentials_example.py credentials.py | |
- name: Migrate | |
run: | | |
python manage.py migrate | |
- name: Start Gunicorn | |
run: | | |
gunicorn core.wsgi:application --bind 0.0.0.0:8000 --workers 5 --log-level debug & | |
- name: Run Locust Performance Tests (Easy) | |
run: | | |
locust -f locust_tests.py --headless --host=http://localhost:8000 -u 50 -r 4 --run-time 20s --processes -1 | |
- name: Run Locust Performance Tests (Medium) | |
run: | | |
locust -f locust_tests.py --headless --host=http://localhost:8000 -u 100 -r 8 --run-time 20s --processes -1 | |
- name: Run Locust Performance Tests (Hard) | |
run: | | |
locust -f locust_tests.py --headless --host=http://localhost:8000 -u 200 -r 16 --run-time 20s --processes -1 | |
- name: Run Locust Performance Tests (Impossible) | |
run: | | |
locust -f locust_tests.py --headless --host=http://localhost:8000 -u 1000 -r 64 --run-time 20s --processes -1 |