From c3757aa7cc33f54e250d62f629a4a8570f1a2464 Mon Sep 17 00:00:00 2001 From: Stavros Ntentos <133706+stdedos@users.noreply.github.com> Date: Mon, 23 Oct 2023 10:40:34 +0300 Subject: [PATCH] MOAR `pre-commit` + `README.md` Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com> --- .codecov.yml | 1 + .github/workflows/checks.yaml | 7 ++-- .github/workflows/release.yml | 3 +- .github/workflows/run-tests.yaml | 64 ++++++++++++++++---------------- .gitignore | 3 ++ .pre-commit-config.yaml | 48 ++++++++++++++++++++---- README.md | 5 ++- setup.py | 0 8 files changed, 86 insertions(+), 45 deletions(-) mode change 100644 => 100755 setup.py diff --git a/.codecov.yml b/.codecov.yml index f6947b3..93b0afc 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,2 +1,3 @@ +--- ignore: - tests/input/**/*.py diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 54c30db..f36fc99 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -1,3 +1,4 @@ +--- name: Checks on: @@ -11,7 +12,7 @@ on: env: CACHE_VERSION: 1 KEY_PREFIX: base-venv - DEFAULT_PYTHON: "3.11" + DEFAULT_PYTHON: '3.11' PRE_COMMIT_CACHE: ~/.cache/pre-commit concurrency: @@ -99,9 +100,7 @@ jobs: with: path: venv fail-on-cache-miss: true - key: - ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ - needs.prepare-base.outputs.python-key }} + key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ needs.prepare-base.outputs.python-key }} - name: Restore pre-commit environment id: cache-precommit uses: actions/cache@v3.3.2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fb9cbe..17139ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,4 @@ +--- name: Release on: @@ -6,7 +7,7 @@ on: - published env: - DEFAULT_PYTHON: "3.11" + DEFAULT_PYTHON: '3.11' permissions: contents: read diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index d44d33e..656f11f 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -1,3 +1,4 @@ +--- name: Testing on: @@ -39,40 +40,41 @@ jobs: shell: ${{ matrix.os == 'windows-latest' && 'pwsh' || '/bin/bash --noprofile --norc -Eeuxo pipefail {0}' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Slugify GITHUB_REPOSITORY - run: echo "GITHUB_REPOSITORY_SLUG=${GITHUB_REPOSITORY////_}" >> $GITHUB_ENV + - name: Slugify GITHUB_REPOSITORY + run: echo "GITHUB_REPOSITORY_SLUG=${GITHUB_REPOSITORY////_}" >> $GITHUB_ENV - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: setup.py + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: setup.py - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox - - name: Test with tox - env: - FORCE_COLOR: 1 - PYTEST_CI_ARGS: --cov-report=xml --cov-report=html --junitxml=test_artifacts/test_report.xml --color=yes - run: tox ${{ matrix.python-version == '3.6' && '--skip-missing-interpreters=true' || '' }} + - name: Test with tox + env: + FORCE_COLOR: 1 + PYTEST_CI_ARGS: --cov-report=xml --cov-report=html --junitxml=test_artifacts/test_report.xml --color=yes + run: tox ${{ matrix.python-version == '3.6' && '--skip-missing-interpreters=true' || '' }} - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: ${{ matrix.os }},${{ matrix.python-version }} - fail_ci_if_error: true - files: test_artifacts/cobertura.xml + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: ${{ matrix.os }},${{ matrix.python-version }} + fail_ci_if_error: true + files: test_artifacts/cobertura.xml - - name: Create artifacts - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: ${{ env.GITHUB_REPOSITORY_SLUG }}_test-artifacts_${{ github.event_name }}_${{ github.event.pull_request.number || github.sha }}_${{ matrix.os }}_py${{ matrix.python-version }} - path: test_artifacts/ + - name: Create artifacts + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: ${{ env.GITHUB_REPOSITORY_SLUG }}_test-artifacts_${{ github.event_name }}_${{ github.event.pull_request.number || github.sha }}_${{ matrix.os + }}_py${{ matrix.python-version }} + path: test_artifacts/ diff --git a/.gitignore b/.gitignore index 4012e01..4fce772 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ sandbox/**/*.py /test_artifacts/ +# ruff Python linter +.ruff_cache/ + ## Mostly complete version from https://github.com/github/gitignore/blob/e5323759e387ba347a9d50f8b0ddd16502eb71d4/Python.gitignore # Byte-compiled / optimized / DLL files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50be1c3..ee1a67f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +--- ci: skip: [pylint] @@ -9,14 +10,37 @@ repos: exclude: ^.idea/ - id: trailing-whitespace - id: pretty-format-json - args: [ "--no-sort-keys", "--autofix", "--indent=4" ] exclude: ^.vscode/ + args: + - --autofix + - --no-sort-keys + - --indent=4 + - id: check-yaml + - id: check-toml + - id: check-vcs-permalinks + - id: check-shebang-scripts-are-executable + - id: name-tests-test + exclude: ^tests/(input/|base_tester(|_test).py$) + args: + - --pytest-test-first + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.1 + hooks: + - id: yamlfmt + args: + - --mapping + - '2' + - --sequence + - '4' + - --offset + - '2' - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.0.292 hooks: - id: ruff - args: ["--fix"] - exclude: "tests/input/" + args: + - --fix + exclude: tests/input/ - repo: https://github.com/psf/black rev: 23.9.1 hooks: @@ -41,16 +65,26 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - id: text-unicode-replacement-char + - repo: local + hooks: + - id: python-no-log-fatal + name: avoid logger.fatal( + description: A quick check for the deprecated `.fatal()` method of python loggers + entry: (? ``` -Or in `pylintrc`: +Or in `.pylintrc`: ```ini [MASTER] diff --git a/setup.py b/setup.py old mode 100644 new mode 100755