diff --git a/.github/RELEASE-TEMPLATE.md b/.github/RELEASE-TEMPLATE.md index 5d5b38f..7147e6f 100644 --- a/.github/RELEASE-TEMPLATE.md +++ b/.github/RELEASE-TEMPLATE.md @@ -9,7 +9,7 @@ Use version 0.8 if you need compatibility with NetBox 3.7 ## Update procedure * Run NetBox's `upgrade.sh`, and restart NetBox -Check [the documentation](https://github.com/Alef-Burzmali/netbox-data-flows/blob/main/docs/installation-configuration.md#upgrade) for further instructions. +Check [the documentation](https://alef-burzmali.github.io/netbox-data-flows/installation-configuration/#upgrade) for further instructions. ## Changes * ... diff --git a/.github/workflows/python-build.yml b/.github/workflows/build-package.yml similarity index 81% rename from .github/workflows/python-build.yml rename to .github/workflows/build-package.yml index b54eec7..232c624 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/build-package.yml @@ -7,19 +7,31 @@ permissions: contents: read jobs: + check-linting: + uses: ./.github/workflows/check-linting.yml + + run-tests: + uses: ./.github/workflows/run-tests.yml + build: name: Check and build project + needs: [check-linting, run-tests] runs-on: "ubuntu-latest" + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.11" + - name: Install dependencies run: | python -m pip install --upgrade pip pip install build twine + - name: Compare version from tag and from project run: | PROJECT_VERSION=$(grep -F "__version__ =" netbox_data_flows/__init__.py | cut -d\" -f2) @@ -33,13 +45,16 @@ jobs: echo "Version mismatch" >&2 exit 1 fi + - name: Build project run: python -m build . + - name: Verify build run: python -m twine check --strict dist/* + - name: Save build artifacts uses: actions/upload-artifact@v4 with: name: distributions path: dist/* - retention-days: 2 + retention-days: 3 diff --git a/.github/workflows/check-documentation.yml b/.github/workflows/check-documentation.yml new file mode 100644 index 0000000..5cdf3a0 --- /dev/null +++ b/.github/workflows/check-documentation.yml @@ -0,0 +1,37 @@ +name: Test the documentation build + +on: + push: + paths: + - 'docs/**' + branches-ignore: + - 'gh-pages' + pull_request: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + check-documentation: + name: Check documentation + runs-on: "ubuntu-latest" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements_docs.txt + + - name: Check documentation build + run: | + mkdocs build --strict diff --git a/.github/workflows/check-linting.yml b/.github/workflows/check-linting.yml new file mode 100644 index 0000000..876583b --- /dev/null +++ b/.github/workflows/check-linting.yml @@ -0,0 +1,49 @@ +name: Check linting on push and pull request + +on: + push: + paths-ignore: + - 'docs/**' + branches-ignore: + - 'gh-pages' + pull_request: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + check-linting: + name: Check linting + runs-on: ubuntu-latest + + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies & set up configuration + run: | + python -m pip install --upgrade pip + pip install -r requirements_dev.txt + + - name: "Check code formatting with black" + run: | + black --check netbox_data_flows + + - name: "Check PEP8 compliance with Flake8" + run: | + flake8 --extend-ignore=D100,D101,D102,D103,D104,D105,D106,D107,D401 --max-line-length 120 netbox_data_flows + + - name: "Check import order" + run: | + isort --check netbox_data_flows + + - name: "Check manifest" + run: | + check-manifest diff --git a/.github/workflows/python-release.yml b/.github/workflows/prepare-release.yml similarity index 70% rename from .github/workflows/python-release.yml rename to .github/workflows/prepare-release.yml index 874891d..0a5797e 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/prepare-release.yml @@ -9,29 +9,36 @@ permissions: contents: write jobs: - black: - uses: ./.github/workflows/python-black.yml - build: - needs: black - uses: ./.github/workflows/python-build.yml + build-package: + uses: ./.github/workflows/build-package.yml + autorelease: name: Create Draft Release - needs: [black, build] + needs: [build-package] runs-on: "ubuntu-latest" + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Get version of project run: | PROJECT_VERSION=$(grep -F "__version__ =" netbox_data_flows/__init__.py | cut -d\" -f2) echo "Version from __init__.py: ${PROJECT_VERSION}" echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV - - run: mkdir dist - - uses: actions/download-artifact@v4 + + - name: Create staging directory + run: mkdir dist + + - name: Fetch build artifacts + uses: actions/download-artifact@v4 with: name: distributions path: dist/ - - name: Prepare release Notes - run: git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md" + + - name: Prepare Release Notes + run: git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s' --no-merges >> ".github/RELEASE-TEMPLATE.md" + - name: Create Release Draft uses: softprops/action-gh-release@v2 with: diff --git a/.github/workflows/publish-documentation.yml b/.github/workflows/publish-documentation.yml new file mode 100644 index 0000000..a45bf2b --- /dev/null +++ b/.github/workflows/publish-documentation.yml @@ -0,0 +1,35 @@ +name: Create documentation and publish it to GitHub pages + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: write + +jobs: + publish-documentation: + name: Publish documentation + runs-on: "ubuntu-latest" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements_docs.txt + + - name: Check documentation build + run: | + mkdocs build --strict + + - name: Publish documentation + run: | + mkdocs gh-deploy --force diff --git a/.github/workflows/python-publish-pypi.yml b/.github/workflows/publish-pypi.yml similarity index 58% rename from .github/workflows/python-publish-pypi.yml rename to .github/workflows/publish-pypi.yml index 19bc60e..f1554fb 100644 --- a/.github/workflows/python-publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -8,22 +8,33 @@ permissions: contents: read jobs: - build: - uses: ./.github/workflows/python-build.yml - testpypi-publish: + build-package: + uses: ./.github/workflows/build-package.yml + + publish-pypi: name: Upload release to PyPI - needs: build + needs: [build-package] runs-on: ubuntu-latest + environment: name: pypi url: https://pypi.org/p/netbox-data-flows + permissions: id-token: write + steps: - - run: mkdir dist - - uses: actions/download-artifact@v4 + - name: Create staging directory + run: mkdir dist + + - name: Fetch build artifacts + uses: actions/download-artifact@v4 with: name: distributions path: dist/ + - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + + publish-documentation: + uses: ./.github/workflows/publish-documentation.yml diff --git a/.github/workflows/python-black.yml b/.github/workflows/python-black.yml deleted file mode 100644 index 40e394b..0000000 --- a/.github/workflows/python-black.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Lint with Black - -on: [push, pull_request, workflow_call] - -permissions: - contents: read - -jobs: - lint: - name: Black - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: psf/black@stable - with: - options: "--check" - src: "netbox_data_flows" diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bf9209c..ccbc650 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,8 +7,6 @@ on: branches-ignore: - 'gh-pages' pull_request: - paths-ignore: - - 'docs/**' workflow_call: workflow_dispatch: @@ -16,7 +14,7 @@ permissions: contents: read jobs: - check-linting: + run-tests: name: Run tests runs-on: ubuntu-latest env: @@ -89,3 +87,4 @@ jobs: working-directory: netbox run: | python netbox/manage.py test --parallel auto netbox_data_flows + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b0cdc1e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,58 @@ +default_stages: [pre-commit] +default_install_hook_types: [pre-commit, pre-push] + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: no-commit-to-branch + - id: check-ast + - id: check-toml + - id: end-of-file-fixer + stages: ["pre-commit"] + - id: trailing-whitespace + stages: ["pre-commit"] + +- repo: https://github.com/psf/black + rev: 24.4.2 + hooks: + - id: black + +- repo: local + hooks: + - id: pyproject-flake8 + name: pyproject-flake8 + language: system + pass_filenames: true + entry: pflake8 + types: ["python"] + +- repo: https://github.com/mgedmin/check-manifest + rev: "0.49" + hooks: + - id: check-manifest + +- repo: local + hooks: + - id: check-missing-migrations + name: check-missing-migrations + entry: python /opt/netbox-dev/netbox/manage.py makemigrations netbox_data_flows --check + language: system + pass_filenames: false + types: ["python"] + stages: ["pre-push", "manual"] + - id: check-pending-migrations + name: check-pending-migrations + entry: python /opt/netbox-dev/netbox/manage.py migrate netbox_data_flows --check + language: system + pass_filenames: false + types: ["python"] + stages: ["pre-push", "manual"] + - id: run-tests + name: run-tests + entry: python /opt/netbox-dev/netbox/manage.py test --parallel auto netbox_data_flows + language: system + pass_filenames: false + types: ["python"] + stages: ["manual"] + verbose: true diff --git a/MANIFEST.in b/MANIFEST.in index cb27955..33d989e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,7 @@ include *.md recursive-include netbox_data_flows/templates *.html recursive-include docs *.md *.png + +exclude .editorconfig .pre-commit-config.yaml +exclude mkdocs.yml +exclude requirements_dev.txt requirements_docs.txt