Merge pull request #1743 from intezer/add-pdf-miner-integration #5433
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: 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 |