Skip to content

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

Run pytest as a GitHub action (#5787)

Patryk Zawadzki787f1add5b3c
diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml
new file mode 100644
index 0000000000..6c4c4537d2
--- /dev/null
+++ b/.github/workflows/pytest.yml
@@ -0,0 +1,76 @@
+name: Pytest
+
+on:
+ pull_request:
+ types: [ opened, synchronize, reopened ]
+ push:
+ branches:
+ - master
+ - ci/*
+
+env:
+ BENCH_PATH: ./queries-results.json
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ container: python:3.8
+
+ services:
+ postgres:
+ image: postgres
+ env:
+ POSTGRES_PASSWORD: saleor
+ POSTGRES_USER: saleor
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Setup Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.8"
+
+ - name: Install system dependencies
+ run: apt-get install -y libpq-dev
+
+ - uses: actions/cache@v2
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements_dev.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Install dependencies
+ run: |
+ python -m pip install wheel
+ python -m pip install -r requirements_dev.txt
+
+ - name: Run tests
+ run: |
+ pytest \
+ --cov \
+ --junitxml=junit/test-results.xml \
+ --django-db-bench=${{ env.BENCH_PATH }}
+ env:
+ DATABASE_URL: "postgres://saleor:saleor@postgres:5432/saleor"
+
+ - uses: codecov/codecov-action@v1
+ - uses: actions/upload-artifact@v1
+ with:
+ name: pytest-results
+ path: junit/test-results.xml
+ if: ${{ always() }}
+
+ - uses: NyanKiyoshi/[email protected]
+ with:
+ query_raw_dump_path: ${{ env.BENCH_PATH }}
+ diff_endpoint: "https://dtab784j47g1o.cloudfront.net/default/saleor-db-queries-bot-diff"
+ diff_results_base_url: "https://dtab784j47g1o.cloudfront.net"
+ upload_endpoint: ${{ secrets.QUERIES_UPLOAD_ENDPOINT_URL }}
+ upload_secret_key: ${{ secrets.QUERIES_UPLOAD_SECRET }}