apply ruff linter and fixes to all codebase #222
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: Test package for linter issues and run tests | |
on: | |
pull_request: | |
branches: | |
- main | |
- development | |
paths: | |
- .github/workflows/test-package.yaml | |
- setup.py | |
- MANIFEST.in | |
- ocean_data_parser/** | |
- tests/** | |
push: | |
branches: | |
- main | |
- development | |
paths: | |
- setup.py | |
- MANIFEST.in | |
- ocean_data_parser/** | |
- tests/** | |
jobs: | |
testing: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry install --with dev,geo | |
- name: ruff check | |
id: ruff_check | |
run: poetry run ruff check --output-format=github . | |
continue-on-error: true | |
- name: ruff import sorting check | |
id: ruff_imports | |
run: poetry run ruff check --select I --output-format=github . | |
continue-on-error: true | |
- name: ruff format | |
id: ruff_format | |
run: poetry run ruff format --check . | |
continue-on-error: true | |
- name: Check for ruff issues | |
if: steps.ruff_check.outcome == 'failure' || steps.ruff_imports.outcome == 'failure' || steps.ruff_format.outcome == 'failure' | |
run: | | |
echo "Some ruff steps failed. Please check the logs for more information.\n" | |
echo "Some of the issues can be fixed by running the following commands:\n" | |
echo " poetry run ruff check --fix . # for fixing all default issues" | |
echo " poetry run ruff check --fix --select I . # for fixing import sorting issues" | |
echo " poetry run ruff format . # for formatting the code" | |
exit 1 | |
- name: Review if metadata is updated | |
uses: dorny/paths-filter@v3 | |
continue-on-error: true | |
id: changes | |
with: | |
base: ${{ github.base_ref }} | |
ref: ${{ github.ref }} | |
filters: | | |
vocabularies: | |
- 'ocean_data_parser/vocabularies/**' | |
- 'ocean_data_parser/metatadata/**' | |
- 'tests/test_metadata.py' | |
changelog: | |
- 'CHANGELOG.md' | |
- name: Run tests with metadata tests | |
if: steps.changes.outputs.vocabularies == 'true' | |
run: poetry run pytest -W error::UserWarning --nerc-vocab -n auto | |
- name: Run tests without metadata tests | |
if: steps.changes.outputs.vocabularies == 'false' | |
run: poetry run pytest -W error::UserWarning -k "not test_metadata" -n auto | |
- name: Run benchmark | |
run: poetry run pytest tests/run_benchmark.py --benchmark-json output.json | |
- name: CHANGELOG updated check | |
if: steps.changes.outputs.changelog == 'false' | |
run: | | |
echo "CHANGELOG.md update is required." | |
exit 1 | |