Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI #480

Merged
merged 22 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
58 changes: 24 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Cache PyPI
uses: actions/cache@v2
with:
key: pip-lint-${{ hashFiles('requirements-dev.txt') }}
path: ~/.cache/pip
restore-keys: |
pip-lint-
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
- name: Pre-Commit hooks
uses: pre-commit/action@v2.0.0
uses: pre-commit/action@v3.0.0
- name: Install dependencies
uses: py-actions/py-dependency-install@v3.0.0
uses: py-actions/py-dependency-install@v3
with:
path: requirements-dev.txt
- name: Install itself
Expand Down Expand Up @@ -65,35 +60,25 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python ${{ matrix.pyver }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.pyver }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/cache@v2
with:
key: pip-ci-${{ runner.os }}-${{ matrix.pyver }}-${{ hashFiles('requirements-dev.txt') }}
path: ${{ steps.pip-cache.outputs.dir }}
restore-keys: |
pip-ci-${{ runner.os }}-${{ matrix.pyver }}-
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
- name: Install dependencies
uses: py-actions/py-dependency-install@v3.0.0
uses: py-actions/py-dependency-install@v3
with:
path: requirements-dev.txt
- name: Run unittests
run: pytest --cov=aiohttp_debugtoolbar --cov-report xml --cov-report html --cov-report term
run: pytest --cov-report=xml tests
env:
COLOR: 'yes'
- run: python -m coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unit
fail_ci_if_error: false

check: # This job does nothing and is only used for the branch protection
if: always()
Expand All @@ -118,18 +103,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run:
python -m pip install -U build pip wheel twine
python -m pip install -U build setuptools wheel twine
- name: Make dists
run:
python -m build
- name: PyPI upload
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
- name: Make Release
uses: aio-libs/create-release@v1.6.6
with:
changes_file: CHANGES.rst
name: aiohttp-debugtoolbar
version_file: aiohttp_debugtoolbar/__init__.py
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
dist_dir: dist
fix_issue_regex: "`#(\\d+) <https://github.com/aio-libs/aiohttp-debugtoolbar/issues/\\1>`"
fix_issue_repl: "(#\\1)"
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: "33 2 * * 2"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ python ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
68 changes: 23 additions & 45 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,29 @@
repos:
- repo: local
hooks:
- id: changelogs-rst
name: changelog filenames
language: fail
entry: >-
Changelog files must be named
####.(bugfix|feature|removal|doc|misc)(.#)?(.rst)?
exclude: >-
^CHANGES/(\.TEMPLATE\.rst|\.gitignore|\d+\.(bugfix|feature|removal|doc|misc)(\.\d+)?(\.rst)?|README\.rst)$
files: ^CHANGES/
- id: changelogs-user-role
name: Changelog files should use a non-broken :user:`name` role
language: pygrep
entry: :user:([^`]+`?|`[^`]+[\s,])
pass_filenames: true
types: [file, rst]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.0.1'
rev: 'v4.4.0'
hooks:
- id: check-merge-conflict
- repo: https://github.com/asottile/yesqa
rev: v1.3.0
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies:
- flake8-bandit==3.0.0
- flake8-bugbear==22.1.11
- flake8-import-order==0.18.1
- flake8-requirements==1.5.1
- flake8-bandit==4.1.1
- flake8-bugbear==23.7.10
- flake8-import-order==0.18.2
- flake8-requirements==1.7.8
- repo: https://github.com/psf/black
rev: '22.1.0'
rev: '23.7.0'
hooks:
- id: black
language_version: python3
language_version: python3 # Should be a command that runs python
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.0.1'
rev: 'v4.4.0'
hooks:
- id: end-of-file-fixer
exclude: >-
^docs/[^/]*\.svg$
- id: requirements-txt-fixer
exclude: >-
^requirements/constraints[.]txt$
- id: trailing-whitespace
- id: file-contents-sorter
files: |
Expand All @@ -55,37 +36,34 @@ repos:
- id: check-xml
- id: check-executables-have-shebangs
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
- id: check-symlinks
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: ['--remove']
- id: debug-statements
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- id: detect-private-key
exclude: ^examples/
- repo: https://github.com/asottile/pyupgrade
rev: 'v2.29.0'
hooks:
- id: pyupgrade
args: ['--py36-plus']
- repo: https://github.com/PyCQA/flake8
rev: '4.0.1'
rev: '6.1.0'
hooks:
- id: flake8
additional_dependencies:
- flake8-bandit==3.0.0
- flake8-bugbear==22.1.11
- flake8-import-order==0.18.1
- flake8-requirements==1.5.1
exclude: "^docs/"
- repo: git://github.com/Lucas-C/pre-commit-hooks-markup
additional_dependencies:
- flake8-bandit==4.1.1
- flake8-bugbear==23.7.10
- flake8-import-order==0.18.2
- flake8-requirements==1.7.8
- repo: https://github.com/asottile/pyupgrade
rev: 'v3.10.1'
hooks:
- id: pyupgrade
args: ['--py36-plus']
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1
hooks:
- id: rst-linter
files: >-
^[^/]+[.]rst$
exclude: >-
^CHANGES\.rst$
2 changes: 1 addition & 1 deletion aiohttp_debugtoolbar/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if sys.version_info >= (3, 8):
from typing import Literal, TypedDict
else:
from typing_extensions import Literal, TypedDict # noqa: I900
from typing_extensions import Literal, TypedDict

import aiohttp_jinja2
import jinja2
Expand Down
1 change: 0 additions & 1 deletion aiohttp_debugtoolbar/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ async def middleware(request: web.Request, handler: Handler) -> web.StreamRespon
# Intercept http redirect codes and display an html page with a
# link to the target.
if response.status in REDIRECT_CODES and getattr(response, "location", None):

context = {
"redirect_to": response.location,
"redirect_code": response.status,
Expand Down
6 changes: 3 additions & 3 deletions aiohttp_debugtoolbar/panels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def dom_id(self):
Javascript to implement custom styles and actions."""
return "pDebug%sPanel" % (self.name.replace(" ", ""))

async def process_response(self, response):
async def process_response(self, response): # noqa: B027
"""Receives the response generated by the request.

Override this method to track properties of the response."""
pass
Override this method to track properties of the response.
"""

def wrap_handler(self, handler, context_switcher):
"""May be overridden to monitor the entire lifecycle of the request.
Expand Down
1 change: 0 additions & 1 deletion aiohttp_debugtoolbar/panels/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def emit(self, record):


class LoggingPanel(DebugPanel):

name = "logging"
template = "logger.jinja2"
title = "Log Messages"
Expand Down
1 change: 0 additions & 1 deletion aiohttp_debugtoolbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def replace_insensitive(string, target, replacement):


def render(template_name, app, context, *, app_key=TEMPLATE_KEY, **kw):

lookup = app[app_key]
template = lookup.get_template(template_name)
c = context.copy()
Expand Down
2 changes: 1 addition & 1 deletion examples/extra_panels/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def basic_handler(request):

# testing for Redis
if "redis" in request.app:
with (await request.app["redis"]) as redis:
with await request.app["redis"] as redis:
await redis.set("TEST", "VAR", expire=5)
assert b"VAR" == (await redis.get("TEST")) # noqa: S101

Expand Down
17 changes: 17 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[pytest]
addopts =
# show 10 slowest invocations:
--durations=10
# a bit of verbosity doesn't hurt:
-v
# report all the things == -rxXs:
-ra
# show values of the local vars in errors:
--showlocals
# coverage reports
--cov=aiohttp_debugtoolbar/ --cov=tests/ --cov-report term
asyncio_mode = auto
filterwarnings =
error
testpaths = tests/
xfail_strict = true
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ pytest-aiohttp==1.0.4
pytest-cov==3.0.0
pytest-sugar==0.9.4
pytest-timeout==2.1.0
typing_extensions>=3.8; python_version<"3.8"
yarl==1.7.2
9 changes: 0 additions & 9 deletions setup.cfg

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ async def handler(request):


async def test_setup_not_called_exception():

request = make_mocked_request("GET", "/path")
with pytest.raises(RuntimeError):
await aiohttp_debugtoolbar.middleware(request, lambda r: r)
Expand Down
Loading