From 69f26773f5644c394f63054619599799481e1070 Mon Sep 17 00:00:00 2001 From: Sharoon Thomas Date: Tue, 7 May 2024 17:35:44 +0200 Subject: [PATCH] Clean up CI file --- .github/workflows/ci.yml | 36 +++++++++++++---------------------- .pre-commit-config.yaml | 10 ++++++++++ fulfil_client/signals.py | 3 +-- tests/test_data_structures.py | 2 +- 4 files changed, 25 insertions(+), 26 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d11c8a0..c9043b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: chartboost/ruff-action@v1 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Python Lint + run: | + pip install ruff>=0.4.3 + ruff check . + ruff format --check . build: strategy: matrix: @@ -16,34 +23,17 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements_dev.txt + - name: Install from source (required for the pre-commit tests) run: pip install . + - name: Test with pytest - run: pytest --cov=./ --cov-report=xml tests/test_serialization.py - release: - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Set up Python 3.11 - uses: actions/setup-python@v1 - with: - python-version: 3.11 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements_dev.txt - make dist - - name: Publish package - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_password }} + run: pytest tests/test_serialization.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8734090 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.4.3 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format diff --git a/fulfil_client/signals.py b/fulfil_client/signals.py index 7708ddd..c608e1c 100644 --- a/fulfil_client/signals.py +++ b/fulfil_client/signals.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ flask.signals ~~~~~~~~~~~~~ @@ -43,7 +42,7 @@ def _fail(self, *args, **kwargs): "not installed." ) - send = lambda *a, **kw: None + send = lambda *a, **kw: None # noqa connect = disconnect = has_receivers_for = receivers_for = ( temporarily_connected_to ) = connected_to = _fail diff --git a/tests/test_data_structures.py b/tests/test_data_structures.py index df4827f..a378919 100644 --- a/tests/test_data_structures.py +++ b/tests/test_data_structures.py @@ -183,7 +183,7 @@ def test_multi_cache_with_redis(self, res_user_model_with_cache): def test_multi_cache_empty_list(self, res_user_model_with_cache): "Should not raise an error" - records = res_user_model_with_cache.from_cache_multi([]) + res_user_model_with_cache.from_cache_multi([]) def test_inequality_of_saved_records(self, res_user_model, module_model): assert res_user_model.query.first() != module_model.query.first()