From a9bd53ce9e8dc7dc6fd28754dfb30c48c0d56358 Mon Sep 17 00:00:00 2001 From: R Max Espinoza Date: Thu, 4 Jul 2024 20:21:44 +0200 Subject: [PATCH] build: use python3.12 as default version --- .github/workflows/builds.yml | 10 ++++++---- .github/workflows/checks.yml | 14 ++++++++++---- .github/workflows/tests.yml | 11 +++++++++-- requirements-tests.txt | 2 +- src/scrapy_redis/dupefilter.py | 2 +- src/scrapy_redis/spiders.py | 6 ++++-- tox.ini | 27 ++++++++++++++++++++------- 7 files changed, 51 insertions(+), 21 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 834ff7a2..d44c7599 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -1,6 +1,8 @@ # This is GitHub Action for cross platform building name: build on: + push: + branches: [master] pull_request: branches: [master] @@ -11,18 +13,18 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.11.3"] + python-version: ["3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Run build - env: + env: TOXENV: build run: | pip install -r requirements-tests.txt diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index eb51abc6..11e7c918 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,28 +1,34 @@ # This is GitHub Action for linting and security check name: check on: + push: + branches: [master] pull_request: branches: [master] +concurrency: + group: ${{github.workflow}}-${{ github.ref }} + cancel-in-progress: true + jobs: checks: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: ["3.11.3"] + python-version: ["3.12"] env: [security, flake8] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Run check - env: + env: TOXENV: ${{ matrix.env }} run: | pip install -r requirements-tests.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c970c9a7..c424851a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,8 @@ # This is GitHub Action for tests name: test on: + push: + branches: [master] pull_request: branches: [master] @@ -10,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11.3"] + python-version: ["3.12"] services: redis: @@ -24,7 +26,12 @@ jobs: container: python:${{ matrix.python-version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} - name: Run pytest env: diff --git a/requirements-tests.txt b/requirements-tests.txt index 1ce8f1a3..87758fd5 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -3,4 +3,4 @@ flake8 mock pytest>=6.0,<7 pytest-cov -tox>=3.0,<4 +tox>=4.0,<5 diff --git a/src/scrapy_redis/dupefilter.py b/src/scrapy_redis/dupefilter.py index b914883f..dea88c8c 100644 --- a/src/scrapy_redis/dupefilter.py +++ b/src/scrapy_redis/dupefilter.py @@ -122,7 +122,7 @@ def request_fingerprint(self, request): } fingerprint_json = json.dumps(fingerprint_data, sort_keys=True) return hashlib.sha1(fingerprint_json.encode()).hexdigest() - + @classmethod def from_spider(cls, spider): settings = spider.settings diff --git a/src/scrapy_redis/spiders.py b/src/scrapy_redis/spiders.py index c7c93b7b..36c56b28 100644 --- a/src/scrapy_redis/spiders.py +++ b/src/scrapy_redis/spiders.py @@ -172,8 +172,10 @@ def make_request_from_data(self, data): if is_dict(formatted_data): parameter = json.loads(formatted_data) else: - self.logger.warning(f"{TextColor.WARNING}WARNING: String request is deprecated, please use JSON data format. \ - Detail information, please check https://github.com/rmax/scrapy-redis#features{TextColor.ENDC}") + self.logger.warning( + f"{TextColor.WARNING}WARNING: String request is deprecated, please use JSON data format. " + f"Detail information, please check https://github.com/rmax/scrapy-redis#features{TextColor.ENDC}" + ) return FormRequest(formatted_data, dont_filter=True) if parameter.get('url', None) is None: diff --git a/tox.ini b/tox.ini index cfbf3941..8e825c2e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,17 @@ [tox] +requires = + tox>=4 envlist = security flake8 - py{38,39,310,311}-scrapy{26,27,28,29}-redis{42,43,44,45,46,50} + py{38,39,310,311,312}-scrapy{26,27,28,29,210,211}-redis{42,43,44,45,46,50} minversion = 3.0.0 [base] deps = -r requirements-tests.txt -r requirements.txt + setuptools [testenv] basepython = @@ -16,6 +19,7 @@ basepython = py39: python3.9 py310: python3.10 py311: python3.11 + py312: python3.12 deps = {[base]deps} scrapy26: scrapy~=2.6.0 @@ -30,33 +34,42 @@ deps = redis45: redis~=4.5.0 redis46: redis~=4.6.0 redis50: redis~=5.0.0 +passenv = + REDIS_HOST + REDIS_PORT commands = python -m pytest # --cov-report term --cov=scrapy_redis [testenv:flake8] basepython = - python3.11 + python3.12 deps = {[base]deps} commands = - flake8 --ignore=W503,E265,E731 docs/ tests/ + flake8 --ignore=W503,E265,E731 docs src tests [testenv:security] -basepython = python3.11 +basepython = + python3.12 deps = - bandit==1.7.3 + bandit~=1.7.3 commands = bandit -r -c .bandit.yml src/ tests/ [testenv:pytest] -basepython = python3.11 +basepython = + python3.12 deps = {[testenv]deps} +passenv = + REDIS_HOST + REDIS_PORT commands = python -m pytest --cov-report term --cov=scrapy_redis [testenv:build] -basepython=python3.11 +basepython = + python3.12 deps = {[base]deps} build