Skip to content

Commit

Permalink
Add infrastructure to improve yaml files
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Schöchlin <[email protected]>
  • Loading branch information
scoopex committed Jul 7, 2024
1 parent 900ee6f commit 270d57a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Yamllint
on: [pull_request]
jobs:
yamllint:
name: Yamllint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Yamllint
uses: karancode/yamllint-github-action@master
with:
yamllint_strict: false
yamllint_config_filepath: .yamllint.yml
yamllint_comment: true
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .yamlfix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# base.toml
allow_duplicate_keys = false
line_length = 100
preserve_quotes = true
sequence_style = "block_style"
11 changes: 11 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
extends: default
rules:
comments: enable
line-length: disable
empty-lines: disable
ignore: |-
.git
.tox
secrets.yml
secrets-*.yml
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
venv = . venv/bin/activate
export PATH := ${PATH}:${PWD}/venv/bin
basedir = ${PWD}

VAULTPASS_FILE ?= ${PWD}/secrets/vaultpass

Expand Down Expand Up @@ -30,6 +31,23 @@ venv/bin/activate: Makefile requirements.txt
@${venv} && pip3 install -r requirements.txt
touch venv/bin/activate

#################################################
### EXPERIMENTAL, yamlfix is still very broken

.PHONY: lint-check
lint-check: deps
$(MAKE) lint-fix DO_CHECK="--check"

# Just for testing, currently yamllint seems to be broken
.PHONY: lint-fix
lint-fix: deps
${venv} && find . -type f \( -not -path "misc/node-images/node-image/*" -and -not -path "*/.venv/*" -and -not -path "*/venv/*" -regex ".*\.ya?ml" \) \
-print \
-exec yamlfix --verbose ${DO_CHECK} --config-file ${basedir}/.yamlfix.toml {} \;

### EXPERIMENTAL
#################################################

.PHONY: deps
sync: deps
@[ "${BRANCH}" ] && sed -i -e "s/version: .*/version: ${BRANCH}/" gilt.yml || exit 0
Expand Down Expand Up @@ -93,3 +111,5 @@ ifndef FILE
$(error FILE variable is not set, example 'make ansible_vault_edit FILE=environments/secrets.yml')
endif
${venv} && ansible-vault edit --vault-password-file ${VAULTPASS_FILE} ${FILE}


0 comments on commit 270d57a

Please sign in to comment.