-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (160 loc) · 5.42 KB
/
ci.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
name: ci-for-build-and-tests
on:
pull_request:
branches: [ "main", "develop" ]
jobs:
check_modified_files:
name: Check modified files in directories
runs-on: ubuntu-latest
outputs:
docker_files_changes_found: ${{ steps.check_docker_files.outputs.changes_found }}
r8s_files_changes_found: ${{ steps.check_r8s_files.outputs.changes_found }}
src_files_changes_found: ${{ steps.check_src_files.outputs.changes_found }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check modified files in r8s directory
id: check_r8s_files
shell: bash
run: |
git fetch origin ${{ github.event.pull_request.base.sha }}
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }})
echo "Changed files: ${changed_files}"
checked_directory="r8s/"
for file in ${changed_files}
do
if [[ ${file} == ${checked_directory}* ]]
then
echo "Target directory was modified."
echo "changes_found=true" >>$GITHUB_OUTPUT
exit 0
fi
done
echo "Target directory was not modified."
echo "changes_found=false" >>$GITHUB_OUTPUT
echo "dist=/tmp/bavp/dist" >>$GITHUB_OUTPUT
- name: Check modified files in docker directory
id: check_docker_files
shell: bash
run: |
git fetch origin ${{ github.event.pull_request.base.sha }}
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }})
echo "Changed files: ${changed_files}"
checked_directory="docker/"
for file in ${changed_files}
do
if [[ ${file} == ${checked_directory}* ]]
then
echo "Target directory was modified."
echo "changes_found=true" >>$GITHUB_OUTPUT
exit 0
fi
done
echo "Target directory was not modified."
echo "changes_found=false" >>$GITHUB_OUTPUT
echo "dist=/tmp/bavp/dist" >>$GITHUB_OUTPUT
- name: Check modified files in src directory
id: check_src_files
shell: bash
run: |
git fetch origin ${{ github.event.pull_request.base.sha }}
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }})
echo "Changed files: ${changed_files}"
checked_directory="src/"
for file in ${changed_files}
do
if [[ ${file} == ${checked_directory}* ]]
then
echo "Target directory was modified."
echo "changes_found=true" >>$GITHUB_OUTPUT
exit 0
fi
done
echo "Target directory was not modified."
echo "changes_found=false" >>$GITHUB_OUTPUT
echo "dist=/tmp/bavp/dist" >>$GITHUB_OUTPUT
build_package:
name: Build CLI package
needs: check_modified_files
if: ${{ needs.check_modified_files.outputs.r8s_files_changes_found == 'true' }}
uses: ./.github/workflows/build-and-check-python-package.yml
with:
path: ./r8s
test_python:
name: Run Python tests
needs: check_modified_files
if: ${{ needs.check_modified_files.outputs.src_files_changes_found == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Setup test env
run: |
python -VV
pip install virtualenv
virtualenv .venv
source .venv/bin/activate
pip --cache-dir=.cache/pip --quiet install tox
- name: Run tests
run:
source .venv/bin/activate
tox -e py310-lambdas
- name: Upload coverage report
if: steps.check_files.outputs.changes_found == 'true'
uses: actions/upload-artifact@v4
with:
name: lambdas-coverage-report
path: coverage.xml
retention-days: 1
- name: Upload test report
if: steps.check_files.outputs.changes_found == 'true'
uses: actions/upload-artifact@v4
with:
name: lambdas-test-report
path: report.xml
retention-days: 1
test_docker:
name: Run Docker tests
needs: check_modified_files
if: ${{ needs.check_modified_files.outputs.docker_files_changes_found == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Setup test env
run: |
python -VV
pip install virtualenv
virtualenv .venv
source .venv/bin/activate
pip --cache-dir=.cache/pip --quiet install tox
- name: Run docker tests
if: steps.check_files.outputs.changes_found == 'true'
run: |
source .venv/bin/activate
tox -e py310-docker
- name: Upload coverage report
if: steps.check_files.outputs.changes_found == 'true'
uses: actions/upload-artifact@v4
with:
name: docker-coverage-report
path: coverage.xml
retention-days: 1
- name: Upload test report
if: steps.check_files.outputs.changes_found == 'true'
uses: actions/upload-artifact@v4
with:
name: docker-test-report
path: report.xml
retention-days: 1