-
-
Notifications
You must be signed in to change notification settings - Fork 29
175 lines (167 loc) · 5.46 KB
/
Copy pathopen_dbm-code-checking.yml
File metadata and controls
175 lines (167 loc) · 5.46 KB
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
# This workflow will check OpenDMB code quality and run unit tests
# For more information see: https://www.aicure.com/open_dbm#cicd
name: OpenDBM Code Checking
on:
push:
branches: [ master ]
paths:
- 'dbm_lib/**'
- 'opendbm/**'
- '.github/workflows/open_dbm-code-checking.yml'
- '.github/workflows/open_dbm-build-checking.yml'
- 'tests/**'
- 'pkg/**'
- 'resources/**'
- 'requirements.txt'
pull_request:
branches: [ master ]
paths:
- 'dbm_lib/**'
- 'opendbm/**'
- '.github/workflows/open_dbm-code-checking.yml'
- '.github/workflows/open_dbm-build-checking.yml'
- 'tests/**'
- 'pkg/**'
- 'resources/**'
- 'requirements.txt'
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout OpenDBM code
uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v23.1
- name: Report list of changed files
run: |
echo Changed files: ${{ steps.changed-files.outputs.all_changed_files }}
- name: Get PYTHON changed files
id: python-changed-files
uses: tj-actions/changed-files@v23.1
with:
files: |
*.py*
**/*.py*
- name: Report list of PYTHON changed files
run: |
echo Changed PYTHON files: ${{ steps.python-changed-files.outputs.all_changed_files }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Run flake8
run: |
pip install flake8
for file in ${{ steps.python-changed-files.outputs.all_changed_files }}; do
flake8 $file --count --show-source --statistics
done
vulnerability_scanning:
runs-on: ubuntu-latest
steps:
- name: Checkout OpenDBM code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Run safety
run: |
pip install safety
safety check
unit_tests:
runs-on: ubuntu-latest
steps:
- name: 🔍 GH_TOKEN
if: env.GH_TOKEN == ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
- name: Checkout OpenDBM code
uses: actions/checkout@v3
with:
token: ${{ env.GH_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull OpenFace Image
run: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/dbm-openface:latest
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -e .[test]
- name : Install libsndfile and sox(only for linux machine)
run: |
sudo apt-get install libsndfile1
sudo apt-get install sox
sudo apt-get install ffmpeg
- name: Run Pytest and Coverage
id: odbm_test
run: |
ls -lart
pip install pytest coverage
coverage run -m pytest
coverage report -mi --fail-under=80 --skip-covered
- name: Update shield TEST status only for branch push master
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && always() }}
run: |
echo "${{ steps.odbm_test.outcome }}"
set -x
test_status='${{ steps.odbm_test.outcome }}'
if [ "$test_status" = "success" ] ; then
COLOR=green
STATUS=passed
else
COLOR=red
STATUS=failed
fi
curl "https://img.shields.io/badge/test:status-$STATUS-$COLOR?style=flat" > images/badges/test_status.svg
git config --global user.name 'AiCure ODBM Pipeline'
git config --global user.email 'system@aicure.com'
if [[ `git status --porcelain` ]]; then
git pull origin master
git add images/badges/test_status.svg
git commit -am "Modify test status in test badge"
git push
else
echo "no changes on test badge"
fi
- name: Update shield COVERAGE only for branch push master
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
set -x
total=`coverage report -i | grep TOTAL | awk '{print $4+0}'`
if (( $(echo "$total < 30" | bc -l) )) ; then
COLOR=red
elif (( $(echo "$total >= 60" | bc -l) )); then
COLOR=green
else
COLOR=orange
fi
curl "https://img.shields.io/badge/code:coverage-$total%25-$COLOR?style=flat" > images/badges/code_coverage.svg
git config --global user.name 'AiCure ODBM Pipeline'
git config --global user.email 'system@aicure.com'
if [[ `git status --porcelain` ]]; then
git pull origin master
git add images/badges/code_coverage.svg
git commit -am "Modify coverage percentage in coverage badge"
git push
else
echo "no changes on coverage badge"
fi