From 59e2ebe4e9aed918440661b47bf27183c8cb7573 Mon Sep 17 00:00:00 2001 From: laaraujo Date: Sat, 13 Jul 2024 12:51:15 -0300 Subject: [PATCH] add automated tests gh actions workflow --- .github/workflows/tests.yml | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..bfa7280 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,57 @@ +name: Automated testing + +on: + push: + branches: + - main + workflow_dispatch: + +env: + WORKERS: 3 + SECRET_KEY: "Insecure secret key" + DEBUG: "TRUE" + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + env: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run migrations + run: python src/manage.py migrate + + - name: Run tests + run: pytest -n $WORKERS --cov=src/ --import-mode=importlib