Skip to content

Commit

Permalink
Improve CI
Browse files Browse the repository at this point in the history
  • Loading branch information
joren485 committed Oct 5, 2024
1 parent 48ee989 commit 727d837
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 12 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,34 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Check for trailing whitespaces"
run: "grep --exclude-dir='.git' --exclude='*.md' --exclude='*.png' --files-with-matches --recursive '[[:blank:]]$' && exit 1 || echo 'No trailing whitespaces found.'"

- name: "Check for files with the yml extension"
run: "if [[ -n $(find . -iname '*.yml') ]]; then exit 1; fi"

- uses: "actions/setup-python@v3"
- uses: "actions/setup-python@v5"
with:
python-version: '3.12'

- name: "Install dependencies"
run: "pip install --no-cache-dir --upgrade --quiet ansible ansible-lint black"
- name: "Run shellcheck"
run: "find . -type f -name '*.sh*' -exec shellcheck {} \\;"

- name: "Disable Vault Password"
run: "sed --in-place --expression 's/vault_password_file/# vault_password_file/' ansible.cfg"

- name: "Install dependencies"
run: |
pip install --no-cache-dir --upgrade --quiet poetry
poetry install
- name: "Run ansible-lint"
run: "ansible-lint -q"
run: "poetry run ansible-lint -q"

- name: "Run shellcheck"
run: "find . -type f -name '*.sh*' -exec shellcheck {} \\;"
- name: "Run ruff"
run: "poetry run ruff check"

- name: "Run black"
run: "black --include='\\.py(?:\\.j2)?' --check ."
- name: "Run yamllint"
run: "poetry run yamllint ."
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
password_file
.idea
.vscode
poetry.lock
11 changes: 11 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

extends: "default"

ignore:
- "vault.yaml"

rules:
line-length: false
truthy:
check-keys: false
1 change: 0 additions & 1 deletion host_vars/druif/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ packages_host:
- "iw"
- "pwgen"
- "pycharm-community-edition"
- "python-black"
- "python-poetry"
- "veracrypt"
- "vlc"
Expand Down
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "dotfiles"
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
ansible = "^10.4.0"

[tool.poetry.group.dev.dependencies]
ruff = "^0.6.9"
ansible-lint = { version = "^24.9.2", markers = "platform_system != 'Windows'" }
yamllint = "^1.35.1"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"BLE001",
"D100",
"D203",
"D212",
"COM812",
"ISC001",
"S113",
"T201",
"TRY301",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
5 changes: 3 additions & 2 deletions roles/sway/files/scripts/coinbase_usd_checker.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python
# Ansible managed

import requests
import sys

import requests

URL_BTC = "https://api.coinbase.com/v2/prices/BTC-USD/spot"
URL_ETH = "https://api.coinbase.com/v2/prices/ETH-USD/spot"

Expand All @@ -13,7 +14,7 @@
elif sys.argv[1] == "eth":
response = requests.get(URL_ETH)
else:
raise ValueError()
raise ValueError

price = round(float(response.json()["data"]["amount"]), 2)
except Exception:
Expand Down

0 comments on commit 727d837

Please sign in to comment.