Skip to content

Commit

Permalink
fix: Linting refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
szinn committed Jan 26, 2025
1 parent f3be1b6 commit 1afb0a7
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 89 deletions.
2 changes: 0 additions & 2 deletions .ci/flake8/.flake8

This file was deleted.

22 changes: 0 additions & 22 deletions .ci/jscpd/jscpd.json

This file was deleted.

8 changes: 0 additions & 8 deletions .ci/prettier/.prettierrc.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .ci/secretlint/.secretlintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .ci/actionlint/actionlint.yml → .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
self-hosted-runner:
labels:
- k8s-homelab
- k8s-homelab-runner
153 changes: 108 additions & 45 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,119 @@ concurrency:
cancel-in-progress: true

jobs:
build:
name: Lint
actionlint:
name: actionlint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate Token
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
id: app-token
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}

- name: MegaLinter
uses: oxsecurity/megalinter/flavors/terraform@1fc052d03c7a43c78fe0fee19c9d648b749e0c01 # v8.3.0
env:
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"
PRINT_ALPACA: false
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'workflow_dispatch' }}
ENABLE_LINTERS: |-
${{
join(
fromJSON('
[
"ACTION_ACTIONLINT",
"ANSIBLE_ANSIBLE_LINT",
"COPYPASTE_JSCPD",
"MARKDOWN_MARKDOWNLINT",
"PYTHON_FLAKE8",
"PYTHON_PYLINT",
"REPOSITORY_GIT_DIFF",
"REPOSITORY_SECRETLINT",
"TERRAFORM_TERRAFORM_FMT",
"YAML_PRETTIER",
"YAML_YAMLLINT"
]
'),
','
files: |
.github/workflows/**/*.yml
.github/workflows/**/*.yaml
- name: Run actionlint
if: steps.changed-files.outputs.any_changed == 'true'
uses: bjw-s/[email protected]
with:
actionlint_config: .github/actionlint.yaml
file_pattern: ${{ steps.changed-files.outputs.all_changed_files }}

yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: |
**.yml
**.yaml
- name: Install yamllint
if: steps.changed-files.outputs.any_changed == 'true'
shell: bash
run: |
pip install --user yamllint
- name: Run yamllint
if: steps.changed-files.outputs.any_changed == 'true'
shell: bash
run: |
yamllint --config-file .yamllint.yaml --format github ${{ steps.changed-files.outputs.all_changed_files }}
markdownlint:
name: markdownlint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: |
**.md
- name: Run markdownlint-cli2
if: steps.changed-files.outputs.any_changed == 'true'
uses: bjw-s/[email protected]
with:
markdownlint_config: .markdownlint.yaml
file_pattern: ${{ steps.changed-files.outputs.all_changed_files }}

prettier:
name: prettier
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45

- name: Run prettier
if: steps.changed-files.outputs.any_changed == 'true'
uses: bjw-s/[email protected]
with:
prettier_ignore: .prettierignore
prettier_config: .prettierrc.yaml
file_pattern: ${{ steps.changed-files.outputs.all_changed_files }}

lint_success:
needs:
- actionlint
- prettier
- yamllint
- markdownlint
if: |
always()
name: Lint successful
runs-on: ubuntu-latest
steps:
- name: Check job status
if: >-
${{
(
contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
)
}}
ACTION_ACTIONLINT_CONFIG_FILE: .ci/actionlint/actionlint.yml
ANSIBLE_ANSIBLE_LINT_ARGUMENTS: "-c .ci/ansible-lint/.ansible-lint ansible"
COPYPASTE_JSCPD_CONFIG_FILE: .ci/jscpd/jscpd.json
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .ci/markdownlint/markdownlint.yaml
MARKDOWN_MARKDOWNLINT_RULES_PATH: .ci/markdownlint/
PYTHON_FLAKE8_CONFIG_FILE: .ci/flake8/.flake8
YAML_YAMLLINT_CONFIG_FILE: .ci/yamllint/.yamllint.yaml
YAML_PRETTIER_CONFIG_FILE: .ci/prettier/.prettierrc.yaml
YAML_PRETTIER_ARGUMENTS: --ignore-path .ci/prettier/.prettierignore
}}
run: exit 1
File renamed without changes.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: yamllint
args:
- --config-file
- .ci/yamllint/.yamllint.yaml
- .yamllint.yaml

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
Expand Down Expand Up @@ -57,7 +57,7 @@ repos:
- id: markdownlint
args:
- --config
- ".ci/markdownlint/.markdownlint.yaml"
- .markdownlint.yaml

- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion .ci/yamllint/.yamllint.yaml → .yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ ignore: |
hack/
.private/
.terraform/
.venv/
.vscode/
*.sops.*
gotk-components.yaml
*.zinn.tech.yaml
tech-wildcard-tls.yaml
wildcard-tls.yaml
extends: default
rules:
truthy:
Expand Down
1 change: 1 addition & 0 deletions .ci/ansible-lint/.ansible-lint → ansible/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
exclude_paths:
- files/
1 change: 1 addition & 0 deletions ansible/files/ragnar/minio.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
services:
minio:
command: server /data --console-address ":9001"
Expand Down
1 change: 1 addition & 0 deletions ansible/files/ragnar/node-exporter.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
services:
node-exporter:
command:
Expand Down
3 changes: 2 additions & 1 deletion ansible/files/ragnar/smartctl-exporter.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
services:
smartctl-exporter:
command:
Expand All @@ -6,6 +7,6 @@ services:
image: quay.io/prometheuscommunity/smartctl-exporter:v0.13.0
ports:
- "9633:9633"
privileged: True
privileged: true
restart: always
user: root
1 change: 1 addition & 0 deletions ansible/playbooks/update-pikvm-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update PiKVM Certificate
hosts: pikvm
remote_user: root
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/update-pikvm-configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update PiKVM Configuration
hosts: pikvm
remote_user: root
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/update-proxmox-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update Proxmox Certificate
hosts: "ares"
remote_user: root
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/update-ragnar-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update TrueNAS Certificate
hosts: ragnar
become: true
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/update-ragnar-configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update Ragnar Configuration
hosts: ragnar
tasks:
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/update-titan-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update Gatus Certificate
hosts: titan
remote_user: root
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/update-udmse-configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update Styx Configuration
hosts: styx
tasks:
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/update-unifi-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Update UniFi Certificate
hosts: styx zeus
tasks:
Expand Down

0 comments on commit 1afb0a7

Please sign in to comment.