Skip to content

Commit

Permalink
Add pre-commit (#460)
Browse files Browse the repository at this point in the history
* Add pre-commit

  - add configs to pyproject.toml
  - add .pre-commit-config.yaml
  - remove mypy.yml, flak8.yml, pycodestyle.yml
  - replace os.path with pathlib.path
  - remove whitespaces
  - fix new lines
  - small fixes

* fix conf.py
  • Loading branch information
nikteliy authored Oct 10, 2023
1 parent 36996c2 commit 5f9de73
Show file tree
Hide file tree
Showing 45 changed files with 145 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/actions/linux_armv7l/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM ghcr.io/nikteliy/manylinux_2_24_armv7l:python3.7
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion .github/actions/linux_armv7l/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ runs:
- ${{ inputs.platform }}
- ${{ inputs.makefile }}
- ${{ inputs.python }}
- ${{ inputs.wheeldir }}
- ${{ inputs.wheeldir }}
2 changes: 1 addition & 1 deletion .github/actions/linux_armv7l/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -o errexit
set -o pipefail
set -o nounset

exec "$INPUT_SCRIPT"
exec "$INPUT_SCRIPT"
2 changes: 1 addition & 1 deletion .github/actions/manylinux_2_24_aarch64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM quay.io/pypa/manylinux_2_24_aarch64:latest
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion .github/actions/manylinux_2_24_aarch64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ runs:
- ${{ inputs.platform }}
- ${{ inputs.makefile }}
- ${{ inputs.python }}
- ${{ inputs.wheeldir }}
- ${{ inputs.wheeldir }}
2 changes: 1 addition & 1 deletion .github/actions/manylinux_2_24_x86_64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM quay.io/pypa/manylinux_2_24_x86_64:latest
COPY /entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion .github/actions/manylinux_2_24_x86_64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ runs:
- ${{ inputs.platform }}
- ${{ inputs.makefile }}
- ${{ inputs.python }}
- ${{ inputs.wheeldir }}
- ${{ inputs.wheeldir }}
4 changes: 2 additions & 2 deletions .github/actions/prepare_snap7/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
with:
path: snap7-full-1.4.2.7z
key: ${{ inputs.snap7-archive-url }}

- name: Install choco packages
if: steps.snap7-archive.outputs.cache-hit != 'true' && runner.os == 'Windows'
shell: bash
Expand All @@ -31,4 +31,4 @@ runs:

- name: Update wheel
shell: bash
run: python3 -m pip install --upgrade pip wheel build
run: python3 -m pip install --upgrade pip wheel build
1 change: 0 additions & 1 deletion .github/build_scripts/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ ${INPUT_PYTHON} -m pip install wheel build auditwheel patchelf
${INPUT_PYTHON} -m build . --wheel -C="--build-option=--plat-name=${INPUT_PLATFORM}"

auditwheel repair dist/*${INPUT_PLATFORM}.whl --plat ${INPUT_PLATFORM} -w ${INPUT_WHEELDIR}

9 changes: 4 additions & 5 deletions .github/workflows/build-and-test-arm32v7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare snap7 archive
uses: ./.github/actions/prepare_snap7

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm

- name: Build wheel
uses: ./.github/actions/linux_armv7l
with:
Expand Down Expand Up @@ -55,14 +55,13 @@ jobs:
uses: docker/setup-qemu-action@v2
with:
platforms: arm

- name: Run tests in docker:arm32v7
run: |
docker run --platform linux/arm/v7 --rm --interactive -v $PWD/tests:/tests \
-v $PWD/pyproject.toml:/pyproject.toml \
-v $PWD/wheelhouse:/wheelhouse \
"arm32v7/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
"arm32v7/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
python -m pip install pytest pytest-asyncio $(ls wheelhouse/*manylinux_2_24_armv7l.whl)
python -m pytest tests/ -m "server or util or client or mainloop or partner"
EOF
7 changes: 3 additions & 4 deletions .github/workflows/build-and-test-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare snap7 archive
uses: ./.github/actions/prepare_snap7

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- name: Build wheel
uses: ./.github/actions/manylinux_2_24_aarch64
with:
Expand Down Expand Up @@ -61,9 +61,8 @@ jobs:
docker run --rm --interactive -v $PWD/tests:/tests \
-v $PWD/pyproject.toml:/pyproject.toml \
-v $PWD/wheelhouse:/wheelhouse \
"arm64v8/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
"arm64v8/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
python3 -m pip install $(ls wheelhouse/*_aarch64.whl)
python3 -m pip install pytest pytest-asyncio
python -m pytest tests/ -m "server or util or client or mainloop or partner"
EOF
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare snap7 archive
uses: ./.github/actions/prepare_snap7

Expand All @@ -23,7 +23,7 @@ jobs:
makefile: x86_64_linux.mk
python: /opt/python/cp38-cp38/bin/python
wheeldir: wheelhouse/${{ runner.os }}/

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare snap7 archive
uses: ./.github/actions/prepare_snap7

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- name: Run doc
run: |
cd doc
make html
make html
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
24 changes: 0 additions & 24 deletions .github/workflows/flake8.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -y python3-pip
- name: Run mypy
run: make mypy
run: make mypy
2 changes: 0 additions & 2 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ jobs:
run: |
pytest -m "server or util or client or mainloop"
sudo pytest -m partner
13 changes: 13 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: pre-commit
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
22 changes: 0 additions & 22 deletions .github/workflows/pycodestyle.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ venv/
.vscode/

# DLL
snap7.dll
snap7.dll
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.5.0'
hooks:
- id: mypy
additional_dependencies: [types-setuptools]
files: ^snap7

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.284'
hooks:
- id: ruff
12 changes: 6 additions & 6 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ Special thanks for this release to
---

* Drop python 2 support (#214)
* Feature request: ReadSZL() (#196)
* Feature request: ReadSZL() (#196)
* Keep argument format across the functions (#193)
* Drop Python2 Tests (#167)
* Support for S5TIME (#163)
* Add type annotations (#157)
* client.full_upload() return bytearray size 65536 (#127)
* Some client tests segfault on Linux (#26)
* Drop Python2 Tests (#167)
* Support for S5TIME (#163)
* Add type annotations (#157)
* client.full_upload() return bytearray size 65536 (#127)
* Some client tests segfault on Linux (#26)
* Not all functions are implemented yet (#25)

special thanks to [Fabian Beitler](https://github.com/swamper123) and
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
include README.rst

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ test: venv/bin/pytest
sudo venv/bin/pytest tests/test_partner.py # run this as last to prevent pytest cache dir creates as root

clean:
rm -rf venv python_snap7.egg-info .pytest_cache .tox dist .eggs
rm -rf venv python_snap7.egg-info .pytest_cache .tox dist .eggs
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ Special thanks to
* Thomas W for his S7comm wireshark plugin
* `Fabian Beitler <https://github.com/swamper123>`_ and `Nikteliy <https://github.com/nikteliy>`_ for their contributions towards the 1.0 release
* `Lautaro Nahuel Dapino <https://github.com/lautarodapin>`_ for his contributions.


2 changes: 1 addition & 1 deletion doc/API/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Client
======

.. automodule:: snap7.client
:members:
:members:
2 changes: 1 addition & 1 deletion doc/API/partner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Partner
=======

.. automodule:: snap7.partner
:members:
:members:
Loading

0 comments on commit 5f9de73

Please sign in to comment.