-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (111 loc) · 3.76 KB
/
pytest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Pytest
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**.py"
- Dockerfile
- "saleor/**"
- ".github/workflows/pytest.yml"
- pyproject.toml
- poetry.lock
push:
branches:
- main
- ci/*
paths:
- "**.py"
- Dockerfile
- "saleor/**"
- ".github/workflows/pytest.yml"
- pyproject.toml
- poetry.lock
env:
BENCH_PATH: ./queries-results.json
DATABASE_URL: "postgres://saleor:saleor@postgres:5432/saleor"
SECRET_KEY: ci-test
jobs:
build:
runs-on: ubuntu-latest
container: python:3.9
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@v4
- name: Install system dependencies
run: |
apt-get install -y libpq-dev
- name: Install and configure poetry
run: |
pip install poetry==1.7.0
- name: Cache the venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ~/.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry env use python3.9
poetry install --no-root
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() }}
- name: Run unit tests
run: |
pytest \
-m "not e2e" \
--cov \
--cov-report= \
--junitxml=junit/test-results.xml \
--django-db-bench=${{ env.BENCH_PATH }}
- uses: actions/cache@v3
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@v3
- uses: actions/upload-artifact@v3
with:
name: pytest-results
path: junit/test-results.xml
if: ${{ always() }}
# Publish detected differences as comment
- uses: NyanKiyoshi/pytest-django-queries-ci-tools@v1
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"
if: github.event_name == 'pull_request' && github.repository == 'saleor/saleor'
# Save results for future comparison against pull requests
- uses: NyanKiyoshi/pytest-django-queries-ci-tools@v1
with:
query_raw_dump_path: ${{ env.BENCH_PATH }}
upload_endpoint: ${{ secrets.QUERIES_UPLOAD_ENDPOINT_URL }}
upload_secret_key: ${{ secrets.QUERIES_UPLOAD_SECRET }}
if: github.event_name == 'push' && github.repository == 'saleor/saleor'
- name: Run E2E tests
run: |
pytest -m "e2e"