6
6
- master
7
7
pull_request :
8
8
9
+ concurrency :
10
+ # For pull requests, cancel all currently-running jobs for this workflow
11
+ # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
12
+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13
+ cancel-in-progress : true
14
+
9
15
jobs :
10
16
lint :
11
17
runs-on : ubuntu-latest
12
18
steps :
13
- - uses : actions/checkout@master
14
- - uses : actions/setup-python@v2
19
+
20
+ - uses : actions/checkout@v3
21
+
22
+ - uses : actions/setup-python@v4
23
+ id : setup-python
15
24
with :
16
25
python-version : ' 3.8'
17
- architecture : ' x64 '
26
+
18
27
- name : Install requirements
19
28
run : |
20
29
pip install --no-cache-dir flake8
30
+
21
31
- name : run flake8
22
32
run : |
23
33
# stop the build if there are Python syntax errors or undefined names
@@ -27,24 +37,84 @@ jobs:
27
37
28
38
test :
29
39
runs-on : ubuntu-latest
40
+ services :
41
+ postgres :
42
+ image : postgres:12-alpine
43
+ env :
44
+ POSTGRES_USER : postgres
45
+ POSTGRES_PASSWORD : postgres
46
+ POSTGRES_DB : vas3k_club
47
+ options : >-
48
+ --health-cmd pg_isready
49
+ --health-interval 10s
50
+ --health-timeout 5s
51
+ --health-retries 5
52
+ ports :
53
+ - 5432:5432
54
+ redis :
55
+ image : redis:6-alpine
56
+ env :
57
+ ALLOW_EMPTY_PASSWORD : yes
58
+ ports :
59
+ - 6379:6379
60
+
30
61
steps :
31
- - uses : actions/checkout@master
32
- - name : Build image
33
- run : |
34
- docker-compose -f docker-compose.test.yml build
35
- - name : Run postgres
36
- run : |
37
- docker-compose -f docker-compose.test.yml up -d postgres
38
- - name : Run redis
39
- run : |
40
- docker-compose -f docker-compose.test.yml up -d redis
41
- - name : Run frontend
62
+ - uses : actions/checkout@v3
63
+
64
+ - uses : actions/setup-python@v4
65
+ id : setup-python
66
+ with :
67
+ python-version : ' 3.8'
68
+
69
+ - uses : actions/setup-node@v3
70
+ with :
71
+ node-version : ' 14'
72
+
73
+ - name : ⚡️ Cache webpack build
74
+ uses : actions/cache@v3
75
+ id : cache-webpack
76
+ with :
77
+ path : |
78
+ frontend/static/dist
79
+ frontend/webpack-stats.json
80
+ key : ${{ runner.os }}-webpack-${{ hashFiles('frontend/package*.json', 'frontend/webpack*.js') }}
81
+
82
+ - name : 🏗 Webpack build
83
+ if : steps.cache-webpack.outputs.cache-hit != 'true'
84
+ working-directory : ./frontend
42
85
run : |
43
- docker-compose -f docker-compose.test.yml up -d webpack
44
- - name : Wait postgres
45
- uses : jakejarvis/wait-action@master
86
+ node -v
87
+ npm -v
88
+ npm ci
89
+ npm run build
90
+
91
+ - name : ⚡️ Cache python virtualenv
92
+ uses : actions/cache@v3
93
+ id : cache-venv
46
94
with :
47
- time : ' 20s'
95
+ path : |
96
+ venv
97
+ key : ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('Pipfile.lock') }}
98
+
99
+ - name : Install pip dependencies
100
+ if : steps.cache-venv.outputs.cache-hit != 'true'
101
+ run : |
102
+ python -m venv venv
103
+ . venv/bin/activate
104
+ pip install --upgrade pip pipenv==2021.5.29
105
+ pipenv lock --dev --requirements > requirements.txt
106
+ pip install -r requirements.txt
107
+
48
108
- name : Run tests
109
+ env :
110
+ POSTGRES_USER : postgres
111
+ POSTGRES_PASSWORD : postgres
112
+ POSTGRES_DB : vas3k_club
113
+ POSTGRES_HOST : localhost
114
+ REDIS_DB : 0
115
+ REDIS_HOST : localhost
116
+ PYTHONUNBUFFERED : 1
117
+ TESTS_RUN : da
49
118
run : |
50
- docker-compose -f docker-compose.test.yml run --rm tests
119
+ . venv/bin/activate
120
+ make test-ci
0 commit comments