-
Notifications
You must be signed in to change notification settings - Fork 8
141 lines (115 loc) · 3.89 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
name: CI
# only run tests for pull requests cause no file has to be changed without review
# open -> open the pull request
# synchronize -> push to branch of pull request
on:
pull_request:
types: [opened, synchronize]
jobs:
build-pex:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ansible
pip install virtualenv
pip install wheel
pip install pex
- name: Repack confluent-kafka wheel
run: |
rm -rf tmp_pip_cache &&
mkdir tmp_pip_cache &&
cd tmp_pip_cache &&
python -m pip download $(cat ../requirements.txt | grep confluent-kafka) &&
unzip * &&
rm *.whl &&
python -m wheel pack .
- name: Build Pex File
run: |
pex . -r requirements.txt -o ./logprep.pex -c logprep --pex-root=tmp_pip_cache
- name: Upload PEX
uses: actions/upload-artifact@v2
with:
name: Logprep
path: logprep.pex
if: matrix.python-version == 3.6
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Perform unit tests
env:
PYTEST_ADDOPTS: "--color=yes"
run: |
pytest -vv tests/unit
- name: Perform acceptance tests
env:
PYTEST_ADDOPTS: "--color=yes"
run: |
pytest -vv tests/acceptance
code-quality:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Get changed python files
id: changed-files
uses: tj-actions/[email protected]
with:
files: |
**/*.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Install semgrep if python version > 3.6
run: |
pip install semgrep
if: matrix.python-version == 3.7 || matrix.python-version == 3.8 || matrix.python-version == 3.9
- name: check black formating
run: |
pip install black
black --check --diff --config ./pyproject.toml .
- name: lint changed and added files
if: steps.changed-files.outputs.all_changed_files
run: |
pylint --rcfile=.pylintrc --fail-under 9.5 ${{ steps.changed-files.outputs.all_changed_files }}
- name: Run tests and collect coverage
run: pytest tests --cov=logprep --cov-report=xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v2
- name: Check semgrep rules
if: steps.changed-files.outputs.all_changed_files && (matrix.python-version == 3.7 || matrix.python-version == 3.8 || matrix.python-version == 3.9)
run: semgrep -c .semgrep_rules -c r/python --error -l python --skip-unknown-extensions ${{ steps.changed-files.outputs.all_changed_files }}