Skip to content

Commit

Permalink
Add yamllint with CI workflow (#50)
Browse files Browse the repository at this point in the history
* Add yamllint package to Poetry

* Add CI workflow for yamllint

* Add yamllint rules files

* Fix all the yamllint errors
  • Loading branch information
klaasnicolaas authored May 9, 2024
1 parent 6685c9e commit 0f36d09
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ updates:
directory: "/"
schedule:
interval: daily
time: "04:00"
time: "04:00"
1 change: 1 addition & 0 deletions .github/workflows/additional-tags.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Additional Tags

# yamllint disable-line rule:truthy
on:
push:
tags:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Sync labels

# yamllint disable-line rule:truthy
on:
push:
branches:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,26 @@ jobs:
run: poetry run ruff check --output-format=github .
- name: 🚀 Run ruff formatter
run: poetry run ruff format --check .

yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🏗 Set up Poetry
run: pipx install poetry
- name: 🏗 Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "poetry"
- name: 🏗 Install workflow dependencies
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: 🏗 Install Python dependencies
run: poetry install --no-interaction
- name: 🚀 Run yamllint
run: poetry run yamllint .
39 changes: 19 additions & 20 deletions .github/workflows/publishtopypi.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
---
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

# yamllint disable-line rule:truthy
on:
release:
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
PACKAGE_VERSION: ${{ github.event.release.tag_name }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
PACKAGE_VERSION: ${{ github.event.release.tag_name }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
66 changes: 66 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
ignore: |
.venv/lib
rules:
braces:
level: error
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
brackets:
level: error
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
colons:
level: error
max-spaces-before: 0
max-spaces-after: 1
commas:
level: error
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
comments:
level: error
require-starting-space: true
min-spaces-from-content: 1
comments-indentation:
level: error
document-end:
level: error
present: false
document-start:
level: error
present: true
empty-lines:
level: error
max: 1
max-start: 0
max-end: 1
hyphens:
level: error
max-spaces-after: 1
indentation:
level: error
spaces: 2
indent-sequences: true
check-multi-line-strings: false
key-duplicates:
level: error
line-length:
level: warning
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
new-line-at-end-of-file:
level: error
new-lines:
level: error
type: unix
trailing-spaces:
level: error
truthy:
level: error
80 changes: 79 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pytest-cov = "5.0.0"
pytest-freezer = "0.4.8"
ruff = "0.4.2"
syrupy = "4.6.1"
yamllint = "1.35.1"

[tool.coverage.run]
plugins = ["covdefaults"]
Expand Down

0 comments on commit 0f36d09

Please sign in to comment.