-
Notifications
You must be signed in to change notification settings - Fork 427
129 lines (105 loc) · 3.8 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- 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
uses: snok/install-poetry@v1
with:
# installation-arguments: --git https://github.com/python-poetry/poetry.git@fedff6da43f33a350598ec0ea85b5dca30178a03 # 1.5.1
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Run ensure pytest installed
run: poetry run pip install pytest=="7.2.0"
- name: Run unit tests
run: poetry run python -m pytest --import-mode=append
- name: Run parsers unit tests
run: poetry run python -m pytest tests_parsers -s --import-mode=append
- name: Install dependencies
run: poetry run pip install ruff
- name: Run Ruff
run: poetry run ruff . --line-length 132 --ignore E501,E402
format:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
python-version: [3.8]
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install libxml2-dev libxslt-dev python3-dev libgeoip-dev ssdeep libfuzzy-dev
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: false
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
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