-
Notifications
You must be signed in to change notification settings - Fork 427
112 lines (92 loc) · 3.08 KB
/
python-package.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: Python package
env:
COLUMNS: 120
on:
push:
branches: [ master, staging ]
pull_request:
branches: [ master, staging ]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
python-version: ["3.8", "3.11"]
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Checkout test files repo
uses: actions/checkout@v3
with:
repository: CAPESandbox/CAPE-TestFiles
path: tests/data/
- name: Install dependencies
run: |
sudo apt update && sudo apt-get install libxml2-dev libxslt-dev python3-dev libgeoip-dev ssdeep libfuzzy-dev p7zip-full innoextract unrar upx
- name: Install poetry
run: pip install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
# check-latest: true
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install requirements
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Run Ruff
run: poetry run ruff . --line-length 132 --ignore E501,E402
- name: Run unit tests
run: poetry run python -m pytest --import-mode=append
# Test parsers only if any parser changed
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'modules/processing/parsers/CAPE/*.py'
- if: steps.changes.outputs.src == 'true'
run: poetry run python -m pytest tests_parsers -s --import-mode=append
# Todo unify in future
format:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
python-version: ["3.8", "3.11"]
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get install libxml2-dev libxslt-dev python3-dev libgeoip-dev ssdeep libfuzzy-dev
- name: Install poetry
run: pip install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
check-latest: true
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install requirements
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Format with black
run: poetry run black .
# to be replaced with ruff
- name: Format imports with isort
run: poetry run isort .
- name: Commit changes if any
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
git commit -m "style: Automatic code formatting" -a
git push
fi