-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (104 loc) · 3.14 KB
/
build.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
name: Build
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- ci/*
- develop
- uat
- main
env:
BENCH_PATH: report.json
COVERAGE_PATH: coverage.xml
DATABASE_URL: "postgres://saleor:saleor@postgres:5432/saleor"
SECRET_KEY: ci-test
jobs:
# Run linters and Django related checks
lint:
name: Linters and Checks
runs-on: ubuntu-latest
container: python:3.8
steps:
- name: Checkout project sources
uses: actions/checkout@v3
- name: Install system dependencies
run: apt-get install -y libpq-dev
- name: Cache Install
uses: actions/cache@v3
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: Cache pre-commit
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-
- name: Run Linters and Checks
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
pre-commit run --all
if: ${{ always() }}
# Run tests
test:
name: Pytest and SonarCloud Scan
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:
- name: Checkout project sources
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install system dependencies
run: apt-get install -y libpq-dev
- name: Cache
uses: actions/cache@v3
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 -n 4 \
--cov-report xml \
--junitxml=xunit-reports/junit-report.xml \
--django-db-bench=${{ env.BENCH_PATH }}
- name: SonarCloud Scan # Run sonarcloud
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Run add reviewers
add-reviews:
name: Add reviewers
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/[email protected]
with:
configuration-path: ".github/auto_assign.yml"