-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (99 loc) · 3.25 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
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:
cli_files_changes_found: ${{ steps.check_cli_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 cli directory
id: check_cli_files
shell: bash
run: |
ls -la ./.github/workflows/
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="cli/"
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.cli_files_changes_found == 'true' }}
uses: ./.github/workflows/build-and-check-python-package.yml
with:
path: ./cli
tests:
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: tests
run: |
source .venv/bin/activate
tox -e py310
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
retention-days: 1
- name: Upload test report
uses: actions/upload-artifact@v4
with:
name: test-report
path: report.xml
retention-days: 1