forked from itpp-labs/pos-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
264 lines (258 loc) · 10.4 KB
/
DINAR-pr.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# Copyright 2020 IT Projects Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "DINAR"
on:
pull_request:
jobs:
pre-commit:
name: "pre-commit"
# Let Quick Review/Tests run first
needs:
- review
- tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: "3.7.x"
- name: Check Python Version
run:
echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/[email protected]
review:
name: "Quick Review"
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
path: REPO
- name: Checkout DINAR
uses: actions/checkout@v2
with:
path: DINAR
repository: itpp-labs/DINAR-fork
ref: master
- uses: actions/setup-python@v1
with:
python-version: "3.7.x"
- name: Install python tools
run: |
pip install plumbum PyGithub pyyaml
- name: Analyze PR
run: |
# sets environment variables that available in next steps via $ {{ env.PR_... }} notation
cd REPO
python ../DINAR/workflow-files/analyze-modules.py updated ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.number }}
- name: Configure docker
run: |
bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN || secrets.GITHUB_TOKEN }}
echo "PR_FILES=../../REPO" >> $GITHUB_ENV
- name: HOW TO RUN ODOO LOCALLY
if: always()
run: |
export MODULES=${{ env.PR_MODULES }}
export LOAD_MODULES=${{ env.PR_MODULES_LOAD }}
export PR_NUM=${{ github.event.number }}
export VERSION=${{ github.event.pull_request.base.ref }}
export REVISION_PR=${{ github.event.pull_request.head.sha}}
export DINAR_REPO="itpp-labs/DINAR-fork"
bash DINAR/workflow-files/how-to-run-locally.sh
- name: Check Python Version
run:
echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('REPO/.pre-commit-config.yaml') }}
- name: Install pre-commit
run: |
pip install pre-commit
- name: PRE-COMMIT against updated files only
run: |
cd REPO
git fetch origin ${{ github.event.pull_request.base.ref }}
echo "CHANGED FILES:"
git diff --name-only --no-ext-diff FETCH_HEAD..HEAD -- .
echo "RUN PRE-COMMIT:"
pre-commit run --show-diff-on-failure --color=always --show-diff-on-failure --files $(git diff --name-only --no-ext-diff FETCH_HEAD..HEAD -- .)
tests:
name: "Quick Tests"
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
path: REPO
- name: Checkout DINAR
uses: actions/checkout@v2
with:
path: DINAR
repository: itpp-labs/DINAR-fork
ref: master
- name: Configure docker
run: |
bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN || secrets.GITHUB_TOKEN }}
echo "PR_FILES=../../REPO" >> $GITHUB_ENV
- name: Install python tools
run: |
pip install plumbum PyGithub pyyaml
- name: Download Docker images with preinstalled modules
run: |
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml pull
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --no-start
- name: Analyze PR
run: |
# Get list of installed modules
ODOO_BASE_MODULES=$(docker inspect \
--format '{{ index .Config.Labels "dinar.odoo.modules"}}' \
dinar_odoo_1)
echo "ODOO_BASE_MODULES=$ODOO_BASE_MODULES"
# sets environment variables that available in next steps via $ {{ env.PR_... }} notation
cd REPO
python ../DINAR/workflow-files/analyze-modules.py updated ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.number }} $ODOO_BASE_MODULES
- name: Install json parser
run: |
sudo apt-get install jq
- name: Install Additional Dependencies (Modules)
if: env.PR_MODULES_DEPS != ''
run: |
# Install new dependencies without tests
export MODULES="${{ env.PR_MODULES_DEPS }}"
export LOAD_MODULES="${{ env.PR_MODULES_LOAD }}"
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit
- name: Install Additional Dependencies (Packages)
if: env.PR_DEPS != ''
run: |
# TODO https://github.com/itpp-labs/DINAR/issues/42
exit 1
- name: Prepare Artifact Folder
run: |
mkdir new-deps/
# create dummy file to be sure that Artifact will be uploaded
echo ok > new-deps/.empty
echo "ARTIFACT=empty" >> $GITHUB_ENV
- name: Prepare DINAR with additional dependencies
if: env.PR_MODULES_DEPS != '' || env.PR_DEPS != ''
run: |
# Save artifacts for local run and for integrations Tests
bash DINAR/workflow-files/save-docker-layers.sh new-deps/
echo "${{ env.PR_MODULES_DEPS }}" > new-deps/modules.txt
echo "ARTIFACT=yes" >> $GITHUB_ENV
- name: Save DINAR with dependencies
uses: actions/upload-artifact@v1
with:
name: new-deps
path: new-deps/
- name: HOW TO RUN QUICK TESTS LOCALLY
if: always()
run: |
export MODULES=${{ env.PR_MODULES }}
export LOAD_MODULES=${{ env.PR_MODULES_LOAD }}
export PR_NUM=${{ github.event.number }}
export VERSION=${{ github.event.pull_request.base.ref }}
export REVISION_PR=${{ github.event.pull_request.head.sha}}
export DINAR_REPO="itpp-labs/DINAR-fork"
export ODOO_EXTRA_ARG=--test-enable
bash DINAR/workflow-files/how-to-run-locally.sh ${{ secrets.GITHUB_TOKEN }}
- name: Test updated modules
if: env.PR_MODULES != ''
run: |
export MODULES="${{ env.PR_MODULES }}"
export LOAD_MODULES="${{ env.PR_MODULES_LOAD }}"
export ODOO_EXTRA_ARG=--test-enable
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit
tests-all:
name: Integration Tests
# Let Quick Review/Tests run first
# This job uses artifacts from "Quick Tests"
needs:
- tests
- review
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
path: REPO
- name: Checkout DINAR
uses: actions/checkout@v2
with:
path: DINAR
repository: itpp-labs/DINAR-fork
ref: master
- name: Install python tools
run: |
pip install plumbum pyyaml
- name: Download Additional Dependencies artifact
uses: actions/download-artifact@v1
with:
name: new-deps
path: new-deps/
- name: Check artifact
run: |
if [ ! -f new-deps/modules.txt ]; then
echo "ARTIFACT=empty" >> $GITHUB_ENV
fi
- name: Configure Docker
run: |
bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN || secrets.GITHUB_TOKEN }}
echo "PR_FILES=../../REPO" >> $GITHUB_ENV
- name: Analyze PR
run: |
# sets environment variables that available in next steps via $ {{ env.PR_... }} notation
DEPS_MODULES=$(cat new-deps/modules.txt || true)
cd REPO
python ../DINAR/workflow-files/analyze-modules.py all "$DEPS_MODULES"
- name: Install json parser
run: |
sudo apt-get install jq
- name: HOW TO RUN TESTS LOCALLY
if: always()
run: |
export MODULES=${{ env.ALL_MODULES }}
export LOAD_MODULES=${{ env.ALL_MODULES_LOAD }}
export PR_NUM=${{ github.event.number }}
export VERSION=${{ github.event.pull_request.base.ref }}
export REVISION_PR=${{ github.event.pull_request.head.sha}}
export DINAR_REPO="itpp-labs/DINAR-fork"
export ODOO_EXTRA_ARG=--test-enable
bash DINAR/workflow-files/how-to-run-locally.sh ${{ secrets.GITHUB_TOKEN }}
- name: Download base images
run: |
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml pull
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --no-start
- name: Apply new-deps artifact
if: env.ARTIFACT != 'empty'
run: |
bash DINAR/workflow-files/load-docker-layers.sh new-deps/
- name: Test all modules
run: |
export MODULES="${{ env.ALL_MODULES }}"
export LOAD_MODULES="${{ env.ALL_MODULES_LOAD }}"
export ODOO_EXTRA_ARG=--test-enable
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit