From 6aeda2c48bf50c5081a2f5cf8dfed096440a6e5f Mon Sep 17 00:00:00 2001 From: olofvndrhr Date: Tue, 20 Feb 2024 08:34:56 +0100 Subject: [PATCH] add issue templates, ci linting and update pre-commit --- .gitea/workflows/check_code.yml | 14 --------- .github/issue_template/bug_report.md | 35 +++++++++++++++++++++++ .github/issue_template/feature_request.md | 20 +++++++++++++ .github/workflows/check_code.yml | 28 ++++++++++++++++++ .lefthook/pre-commit/format.sh | 5 ---- justfile | 35 ++++++++++++++--------- lefthook.yml | 12 ++++++-- 7 files changed, 113 insertions(+), 36 deletions(-) delete mode 100644 .gitea/workflows/check_code.yml create mode 100644 .github/issue_template/bug_report.md create mode 100644 .github/issue_template/feature_request.md create mode 100644 .github/workflows/check_code.yml delete mode 100644 .lefthook/pre-commit/format.sh diff --git a/.gitea/workflows/check_code.yml b/.gitea/workflows/check_code.yml deleted file mode 100644 index 5fa5085..0000000 --- a/.gitea/workflows/check_code.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: check code - -on: - push: - branches: [main, master] - - pull_request: - branches: [main, master] - -jobs: - check-code: - uses: actions/workflows/.gitea/workflows/check_python_hatch.yml@master - with: - run-tests: false diff --git a/.github/issue_template/bug_report.md b/.github/issue_template/bug_report.md new file mode 100644 index 0000000..73b6308 --- /dev/null +++ b/.github/issue_template/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Create a report to help improve the tool +title: "[BUG] " +labels: bug +assignees: olofvndrhr + +--- + +**System info (please complete the following information):** + +- Host: [e.g. Linux/Debian or Docker] +- `octodns-netbox-dns` version [e.g. v2.1.5] +- `netbox-dns` version [e.g. v2.1.5] +- Netbox version [e.g. v2.1.5] + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/issue_template/feature_request.md b/.github/issue_template/feature_request.md new file mode 100644 index 0000000..fe7a08b --- /dev/null +++ b/.github/issue_template/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEATURE] " +labels: feature-request +assignees: olofvndrhr + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/check_code.yml b/.github/workflows/check_code.yml new file mode 100644 index 0000000..fad3fce --- /dev/null +++ b/.github/workflows/check_code.yml @@ -0,0 +1,28 @@ +name: check code + +on: + push: + branches: [main, master] + + pull_request: + branches: [main, master] + +jobs: + check-code: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v3 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: install hatch + run: pip install -U hatch + + - name: test codestyle + run: hatch run lint:style + + - name: test typing + run: hatch run lint:typing diff --git a/.lefthook/pre-commit/format.sh b/.lefthook/pre-commit/format.sh deleted file mode 100644 index 119a1f2..0000000 --- a/.lefthook/pre-commit/format.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/env bash - -set -euxo pipefail - -just format diff --git a/justfile b/justfile index c34fc9a..86e85b5 100644 --- a/justfile +++ b/justfile @@ -6,7 +6,7 @@ set shell := ["bash", "-uc"] set dotenv-load show_receipts: - @just --list + just --list show_system_info: @echo "==================================" @@ -18,34 +18,41 @@ show_system_info: @echo "==================================" setup: - @asdf install - @lefthook install + asdf install + lefthook install create_venv: @echo "creating venv" - @python3 -m pip install --upgrade pip setuptools wheel - @python3 -m venv venv + python3 -m pip install --upgrade pip setuptools wheel + python3 -m venv venv install_deps: @echo "installing dependencies" - @python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt - @pip3 install -r /tmp/requirements.txt + python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt + pip3 install -r /tmp/requirements.txt install_deps_dev: @echo "installing dev dependencies" - @python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt - @python3 -m hatch dep show requirements --env-only >> /tmp/requirements.txt - @pip3 install -r /tmp/requirements.txt + python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt + python3 -m hatch dep show requirements --env-only >> /tmp/requirements.txt + pip3 install -r /tmp/requirements.txt create_reqs: @echo "creating requirements" - @pipreqs --force --savepath requirements.txt src/octodns_netbox_dns + pipreqs --force --savepath requirements.txt src/octodns_netbox_dns lint: just show_system_info - @hatch run lint:style - @hatch run lint:typing + hatch run lint:style + hatch run lint:typing format: just show_system_info - @hatch run lint:fmt + hatch run lint:fmt + +check: + just format + just lint + +build: + hatch build --clean diff --git a/lefthook.yml b/lefthook.yml index 71f4593..7981015 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -2,7 +2,13 @@ colors: true no_tty: false pre-commit: - scripts: - "format.sh": + commands: + 01_ruff_check: stage_fixed: true - runner: bash + glob: "*.py" + run: ruff check --fix-only --exit-zero --silent {all_files} + + 02_ruff_format: + stage_fixed: true + glob: "*.py" + run: ruff format {all_files}