From b0e2c4c4fde6c8014d4c287aec23893375ebad6e Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 7 Oct 2024 14:18:35 +0200 Subject: [PATCH] Initial GA, precommits, tox Signed-off-by: Petr "Stone" Hracek --- .github/workflows/pre-commit-tests.yml | 33 ++++++++++++++++++++++++++ .github/workflows/python-tests.yml | 26 ++++++++++++++++++++ .pre-commit-config.yaml | 23 ++++++++++++++++++ tox.ini | 9 +++++++ 4 files changed, 91 insertions(+) create mode 100644 .github/workflows/pre-commit-tests.yml create mode 100644 .github/workflows/python-tests.yml create mode 100644 .pre-commit-config.yaml create mode 100644 tox.ini diff --git a/.github/workflows/pre-commit-tests.yml b/.github/workflows/pre-commit-tests.yml new file mode 100644 index 0000000..31e5c8c --- /dev/null +++ b/.github/workflows/pre-commit-tests.yml @@ -0,0 +1,33 @@ +name: pre-commit-tests@Auto-merger + +on: + pull_request: + branches: + - main +jobs: + sanity: + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Get sha + id: sha + run: | + echo "::set-output name=SHA::$(git rev-parse HEAD)" + + - name: Install needed dependences for sanity checks + id: sched_test + run: | + sudo apt-get update && sudo apt-get -y install curl jq make git shellcheck python3 python3-pip + pip3 install pre-commit + + - name: Run Sanity pre-commit tests + continue-on-error: true + id: pre_commit_tests + run: | + set +e + pre-commit run --all + echo ::set-output name=exit_status::$? diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml new file mode 100644 index 0000000..8ce75d9 --- /dev/null +++ b/.github/workflows/python-tests.yml @@ -0,0 +1,26 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +name: Run Tox tests on auto-merger + +jobs: + tox_test: + name: Tox test + strategy: + matrix: + tox_env: [py36, py37, py38, py39, py310, py311, py312] + # Use GitHub's Linux Docker host + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run Tox tests on auto-merger + id: test + uses: fedora-python/tox-github-action@main + with: + tox_env: ${{ matrix.tox_env }} + dnf_install: gcc rpm-devel git python3-devel diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..29bee78 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +# HOWTO: https://pre-commit.com/#usage +# pip3 install pre-commit +# pre-commit install + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.2.3 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-merge-conflict + - id: check-yaml + - id: detect-private-key + - id: end-of-file-fixer + - id: trailing-whitespace + - id: flake8 + args: + - --max-line-length=120 +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.711 + hooks: + - id: mypy + args: [--no-strict-optional, --ignore-missing-imports] diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e3a3b5b --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +skipsdist = True +envlist = py36,py37,py38,py39,py310,py311,py312 + +[testenv] +commands = python3 -m pytest --color=yes -v --showlocals tests/ +deps = + pytest + flexmock