Normalize files #5508
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |