From c2651262096b33852966aab3929be3275d422f1f Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Wed, 29 Nov 2023 10:05:25 +0100 Subject: [PATCH 1/2] Add GitHub actions for linting and automated testing --- .github/workflows/lint.yml | 25 +++++++++++++++++++++++++ .github/workflows/test.yml | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b03923b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint +on: + push: + branches: + - master + pull_request: + merge_group: +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Install dependencies + run: pip install black==22.12.0 isort==5.12.0 flake8==6.1.0 + - name: Run black + run: black --check . + - name: Run isort + run: isort --diff --check . + - name: Run flake8 + # E203: whitespace before ':', ignored by Black, non-PEP8-compliant + # E501: line too long, black'll take care of that + run: flake8 --max-line-length=88 --extend-ignore=E203,E501 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5d9235c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Test +on: + push: + branches: + - master + pull_request: + merge_group: +jobs: + unit: + runs-on: ubuntu-latest + services: + redis: + image: redis + ports: + - 6399:6379 + strategy: + matrix: + python: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + - name: Install dependencies + run: pip install -r requirements-testing.txt + - name: Run tests + run: tox From 4598a878bdfee6d0c92469eea949b271d52ddcd1 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Wed, 29 Nov 2023 10:36:30 +0100 Subject: [PATCH 2/2] Fix flake8 errors in existing code --- tests/test_tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tasks.py b/tests/test_tasks.py index 5314711..e6b33d2 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -16,7 +16,7 @@ def test_init(self, celery_app): Test that task initialization sets up the necessary attributes. """ task_instance = self._get_task_instance(celery_app) - assert task_instance._LockableTask__lock_key == f"tests.test_tasks.my_task_lock" + assert task_instance._LockableTask__lock_key == "tests.test_tasks.my_task_lock" assert task_instance._LockableTask__lock is None def test_standard_connection(self, celery_app):