From 2c43d68a6b67e992a21382625d8b47281d75405a Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 2 Nov 2023 16:47:09 +0100 Subject: [PATCH 1/3] Add linter configuration --- .ecrc | 5 +++ .editorconfig | 6 +++ .github/workflows/check-generic.yaml | 42 +++++++++++++++++++ .github/workflows/check.yaml | 30 +++++++++++++ .../workflows/{ci-cd.yml => release-pypi.yml} | 6 +-- .markdownlint-cli2.yaml | 12 ++++++ .yamllint | 13 ++++++ 7 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 .ecrc create mode 100644 .editorconfig create mode 100644 .github/workflows/check-generic.yaml create mode 100644 .github/workflows/check.yaml rename .github/workflows/{ci-cd.yml => release-pypi.yml} (78%) create mode 100644 .markdownlint-cli2.yaml create mode 100644 .yamllint diff --git a/.ecrc b/.ecrc new file mode 100644 index 0000000..699516a --- /dev/null +++ b/.ecrc @@ -0,0 +1,5 @@ +{ + "Exclude": [ + ".git" + ] +} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..30e849c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ +# EditorConfig is awesome: https://EditorConfig.org + +[*] +# Ensure consistent file encoding in UNIX style +charset = utf-8 +end_of_line = lf diff --git a/.github/workflows/check-generic.yaml b/.github/workflows/check-generic.yaml new file mode 100644 index 0000000..04b93cb --- /dev/null +++ b/.github/workflows/check-generic.yaml @@ -0,0 +1,42 @@ +# Generic checks to ease collaboration: +# - consistent file encoding in UNIX style +# - whitespaces in all purposes files like markdown, yaml, etc +name: Check Generic + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + editorconfig-checker: + name: Run editorconfig-checker + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install editorconfig-checker + run: pipx install "editorconfig-checker" + - name: Run editorconfig-checker + run: ec . + + markdownlint: + name: Run markdownlint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run markdownlint-cli2 + uses: DavidAnson/markdownlint-cli2-action@v13 + + yamllint: + name: Run yamllint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run yamllint + run: yamllint . diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..8066456 --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,30 @@ +name: Check + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + ruff: + name: Lint ruff + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install ruff + run: pipx ruff + - name: Run editorconfig-checker + run: ruff check . + + black: + name: Lint Black + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run Black + uses: psf/black@stable diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/release-pypi.yml similarity index 78% rename from .github/workflows/ci-cd.yml rename to .github/workflows/release-pypi.yml index 01ccb30..ad8681f 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/release-pypi.yml @@ -4,7 +4,7 @@ on: push jobs: pypi-publish: name: Upload release to PyPI - if: startsWith(github.ref, 'refs/tags/v') # On tagged release only + if: startsWith(github.ref, 'refs/tags/v') # On tagged release only runs-on: ubuntu-latest environment: name: release @@ -16,8 +16,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: 3.x - name: Generate package distribution run: python3 setup.py sdist - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 0000000..e10ab3a --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -0,0 +1,12 @@ +# Disable some built-in rules +config: + line-length: false + no-inline-html: false + first-line-h1: false + code-block-style: false # conflicts with MkDocs Admontions: https://squidfunk.github.io/mkdocs-material/reference/admonitions/ + code-fence-style: + style: backtick + +# Define glob expressions to use (only valid at root) +globs: + - "**/*.md" diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..7f2054c --- /dev/null +++ b/.yamllint @@ -0,0 +1,13 @@ +extends: default + +rules: + document-start: disable + indentation: + spaces: 2 + line-length: disable + quoted-strings: + quote-type: double + required: only-when-needed + allow-quoted-quotes: true + truthy: + check-keys: false From ddd0009cb40957f31b162964a1502a7b01b33220 Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 2 Nov 2023 16:48:11 +0100 Subject: [PATCH 2/3] Fix CI --- .github/workflows/check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 8066456..d1c07cd 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -16,7 +16,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install ruff - run: pipx ruff + run: pipx install ruff - name: Run editorconfig-checker run: ruff check . From e89ad7f366ae64145636d60d79c080883fc94e94 Mon Sep 17 00:00:00 2001 From: Daniel Mohns Date: Thu, 2 Nov 2023 16:48:58 +0100 Subject: [PATCH 3/3] Fix whitespaces in `README` --- README.md | 146 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index f2264aa..7e1f5c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenPAYGO - Python Lib -This repository contains the Python library for using implementing the different OpenPAYGOToken Suite technologies on your server (for generating tokens and decoding openpaygo metrics payloads) or device (for decoding tokens and making openpaygo metrics payloads). +This repository contains the Python library for using implementing the different OpenPAYGOToken Suite technologies on your server (for generating tokens and decoding openpaygo metrics payloads) or device (for decoding tokens and making openpaygo metrics payloads).