Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Separate lint & test jobs (#17440)

Lukasz Ostrowski2ca9448f8ce0
diff --git a/.github/workflows/pytest.yml b/.github/workflows/tests-and-linters.yml
similarity index 76%
rename from .github/workflows/pytest.yml
rename to .github/workflows/tests-and-linters.yml
index 168771af76..b91b4c6927 100644
--- a/.github/workflows/pytest.yml
+++ b/.github/workflows/tests-and-linters.yml
@@ -1,13 +1,13 @@
-name: Pytest
+name: Tests & Linters
on:
pull_request:
- types: [opened, synchronize, reopened]
+ types: [ opened, synchronize, reopened ]
paths:
- "**.py"
- Dockerfile
- "saleor/**"
- - ".github/workflows/pytest.yml"
+ - "tests-and-linters.yml"
- pyproject.toml
- poetry.lock
push:
@@ -18,7 +18,7 @@ on:
- "**.py"
- Dockerfile
- "saleor/**"
- - ".github/workflows/pytest.yml"
+ - "tests-and-linters.yml"
- pyproject.toml
- poetry.lock
@@ -34,10 +34,10 @@ concurrency:
cancel-in-progress: true
jobs:
- units_and_linters:
+ unit_tests:
runs-on: ubuntu-latest
container: python:3.12
- name: Run units & linters
+ name: Run unit tests
services:
postgres:
@@ -82,14 +82,6 @@ jobs:
# Ticket: https://github.com/python-poetry/poetry/issues/7190
echo "$(poetry env info -p)"/bin >> $GITHUB_PATH
- # Run linters and Django related checks
- # `git config` command is a workaround for https://github.com/actions/runner-images/issues/6775
- - name: Run Linters and Checks
- run: |
- git config --global --add safe.directory "$GITHUB_WORKSPACE"
- pre-commit run --all
- if: ${{ always() }}
-
- name: Run unit tests
env:
COVERAGE_CORE: sysmon
@@ -102,13 +94,6 @@ jobs:
--django-db-bench=${{ env.BENCH_PATH }} \
-n logical
- - uses: actions/cache@v4
- with:
- path: ~/.cache/pre-commit
- key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pre-commit-
-
# Publish coverage and test results
- uses: codecov/codecov-action@v4
env:
@@ -135,3 +120,54 @@ jobs:
upload_endpoint: ${{ secrets.QUERIES_UPLOAD_ENDPOINT_URL }}
upload_secret_key: ${{ secrets.QUERIES_UPLOAD_SECRET }}
if: github.event_name == 'push' && github.repository == 'saleor/saleor'
+
+ linters:
+ runs-on: ubuntu-latest
+ container: python:3.12
+ name: Run linters
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install system dependencies
+ run: |
+ apt-get install -y libpq-dev
+
+ - name: Install and configure poetry
+ run: |
+ pip install poetry==2.0.1
+
+ - name: Cache the venv
+ id: cached-poetry-dependencies
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pypoetry/virtualenvs
+ key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
+
+ - name: Install dependencies
+ run: |
+ poetry env use python3.12
+ poetry sync
+ if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
+
+ - name: Add Python Virtual Environment to PATH
+ run: |
+ # Note: requires `poetry env use` to be ran, otherwise poetry
+ # may not be able to find which virtual environment is in use.
+ # Ticket: https://github.com/python-poetry/poetry/issues/7190
+ echo "$(poetry env info -p)"/bin >> $GITHUB_PATH
+
+ # Run linters and Django related checks
+ # `git config` command is a workaround for https://github.com/actions/runner-images/issues/6775
+ - name: Run Linters and Checks
+ run: |
+ git config --global --add safe.directory "$GITHUB_WORKSPACE"
+ pre-commit run --all
+ if: ${{ always() }}
+
+ - uses: actions/cache@v4
+ with:
+ path: ~/.cache/pre-commit
+ key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
+ restore-keys: |
+ ${{ runner.os }}-pre-commit-