diff --git a/.github/workflows/setup_django.yml b/.github/workflows/setup_django.yml new file mode 100644 index 0000000..f54d704 --- /dev/null +++ b/.github/workflows/setup_django.yml @@ -0,0 +1,37 @@ +name: Set up Django server and Postgres for further testing +on: [ workflow_call ] +jobs: + setup_django: + runs-on: ubuntu-latest # operating system your code will run on + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: sadilar + POSTGRES_PASSWORD: sadilar + POSTGRES_DB: test_db_1 + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-test.txt + sudo apt-get install -y gettext + - name: Run linting tools + run: | + cd app/ + ruff format . + - name: Create logging folder + run: | + sudo mkdir -p /logging + sudo chown runner:runner /logging + - name: Compile Translation Messages + run: | + cp .env.testing app/.env + cd app/ + python manage.py makemessages --all + python manage.py compilemessages diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 24ebbca..f010c9e 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -2,39 +2,8 @@ name: Testing Django on: [ pull_request, push ] # activates the workflow when there is a push or pull request in the repo jobs: test_project: - runs-on: ubuntu-latest # operating system your code will run on - services: - postgres: - image: postgres:16 - env: - POSTGRES_USER: sadilar - POSTGRES_PASSWORD: sadilar - POSTGRES_DB: test_db_1 - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + uses: ./.github/workflows/setup_django.yml steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-test.txt - sudo apt-get install -y gettext - - name: Run linting tools - run: | - cd app/ - ruff format . - - name: Create logging folder - run: | - sudo mkdir -p /logging - sudo chown runner:runner /logging - - name: Compile Translation Messages - run: | - cp .env.testing app/.env - cd app/ - python manage.py makemessages --all - python manage.py compilemessages - name: Run validate_templates run: | export DJANGO_TEST_PROCESSES=1