Skip to content

Commit

Permalink
Workflow tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
szinn committed Jun 5, 2024
1 parent 6cf87dd commit 1f77bb9
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 38 deletions.
4 changes: 4 additions & 0 deletions .ci/actionlint/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
self-hosted-runner:
labels:
- k8s-homelab
2 changes: 2 additions & 0 deletions .ci/flake8/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
default: true
"no-inline-html": {"allowed_elements": ["h1", "div", "img"]}

MD033:
allowed_elements:
- h1
- div
- img

# MD013/line-length - Line length
MD013:
Expand All @@ -16,8 +21,6 @@ MD013:
tables: true
# Include headings
headings: true
# Include headings
headers: true
# Strict length checking
strict: false
# Stern length checking
Expand Down
14 changes: 14 additions & 0 deletions .ci/markdownlint/markdownlint.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
# MD013/line-length - Line length
MD013: false

# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
MD024:
# Only check sibling headings
allow_different_nesting: true
# Only check sibling headings
siblings_only: true

# MD033/no-inline-html - Inline HTML
MD033: false
6 changes: 6 additions & 0 deletions .ci/prettier/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.direnv
.private
.vscode
*.sops.*
ansible/roles/xanmanning.k3s/
gotk-components.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ area/hack:
- any-glob-to-any-file: "hack/**/*"
area/infrastructure:
- changed-files:
- any-glob-to-any-file: "infrastructure/**/*"
- any-glob-to-any-file: "terraform/**/*"
area/taskfile:
- changed-files:
- any-glob-to-any-file:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/create-blacklist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
HOSTS_FILE="/tmp/hosts.blacklist"
destination="hosts.blacklist"
destination_adguard="hosts-adguard.blacklist"
HOSTS_FILES="$HOSTS_FILE.d"
HOSTS_FILES="${HOSTS_FILE}.d"
mkdir -p "${HOSTS_FILES}"
download() {
echo "download($1)"
curl \
--location --max-redirs 3 \
--max-time 20 --retry 3 --retry-delay 0 --retry-max-time 60 \
"$1" > "$(mktemp "${HOSTS_FILES}"/XXXXXX)"
echo "download($1)"
curl \
--location --max-redirs 3 \
--max-time 20 --retry 3 --retry-delay 0 --retry-max-time 60 \
"$1" > "$(mktemp "${HOSTS_FILES}"/XXXXXX)"
}
# https://firebog.net/
Expand Down Expand Up @@ -88,8 +88,8 @@ jobs:
-e '/^$/d' | \
awk '!a[$0]++' | sort -u > "${HOSTS_FILE}"
cat "${HOSTS_FILE}" | sed -e 's/^/0.0.0.0 /g' > "${destination}"
cat "${HOSTS_FILE}" | sed -e 's/^/||/g' -e 's/$/^/g' > "${destination_adguard}"
sed -e 's/^/0.0.0.0 /g' <"${HOSTS_FILE}" >"${destination}"
sed -e 's/^/||/g' -e 's/$/^/g' <"${HOSTS_FILE}" >"${destination_adguard}"
rm -rf "${HOSTS_FILES}"
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/flux-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ jobs:
- name: Generate Diff
id: diff
run: |
echo "diff<<EOF" >> $GITHUB_OUTPUT
cat diff.patch >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "### Diff" >> $GITHUB_STEP_SUMMARY
echo '```diff' >> $GITHUB_STEP_SUMMARY
cat diff.patch >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat diff.patch;
{
echo 'diff<<EOF'
cat diff.patch
echo EOF
} >> "$GITHUB_OUTPUT";
{
echo "### Diff"
echo '```diff'
cat diff.patch
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- if: ${{ steps.diff.outputs.diff != '' }}
name: Add comment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/link-checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
--json number \
| jq --raw-output '.[0].number' \
)
echo "issue-number=${issue_number}" >> $GITHUB_OUTPUT
echo "issue-number=${issue_number}" >> "${GITHUB_OUTPUT}"
echo "${issue_number}"
- name: Create or Update Issue
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Lint

on:
workflow_dispatch:
pull_request:
branches:
- main

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

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

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

- name: MegaLinter
uses: oxsecurity/megalinter/flavors/[email protected]
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"
]
'),
','
)
}}
ACTION_ACTIONLINT_CONFIG_FILE: .ci/actionlint/actionlint.yml
COPYPASTE_JSCPD_CONFIG_FILE: .ci/jscpd/jscpd.json
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .ci/markdownlint/markdownlint.config.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
10 changes: 5 additions & 5 deletions .github/workflows/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ jobs:
KUBECONFIG: "${{ steps.kubeconfig.outputs.filePath }}"
shell: bash
run: |
curl -fsSL -o $GITHUB_WORKSPACE/crd-extractor.sh \
curl -fsSL -o "${GITHUB_WORKSPACE}/crd-extractor.sh" \
https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/Utilities/crd-extractor.sh
chmod +x $GITHUB_WORKSPACE/crd-extractor.sh
bash $GITHUB_WORKSPACE/crd-extractor.sh
chmod +x "${GITHUB_WORKSPACE}/crd-extractor.sh"
bash "${GITHUB_WORKSPACE}/crd-extractor.sh"
- name: Login to GHCR
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
Expand All @@ -84,7 +84,7 @@ jobs:

- name: Publish schemas as OCI
run: |
flux push artifact $OCI_REPO:$(git rev-parse --short HEAD) \
flux push artifact "${OCI_REPO}:$(git rev-parse --short HEAD)" \
--path="/home/runner/.datree/crdSchemas" \
--source="${{ github.repositoryUrl }}" \
--revision="main"
Expand Down Expand Up @@ -127,7 +127,7 @@ jobs:
- name: Pull schemas as OCI
run: |
mkdir -p /home/runner/crdSchemas
flux pull artifact $OCI_REPO:$(git rev-parse --short HEAD) --output /home/runner/crdSchemas
flux pull artifact "${OCI_REPO}:$(git rev-parse --short HEAD)" --output /home/runner/crdSchemas
- name: Write nginx-unprivileged Dockerfile
run: |
Expand Down
19 changes: 16 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
fail_fast: false

exclude: |
(?x)^(
docs/_assets/.*
| .*\.sops\.toml
)$
repos:
- repo: https://github.com/adrienverge/yamllint.git
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args:
- --config-file
- .github/linters/yamllint/.yamllint.yaml
- .ci/yamllint/.yamllint.yaml

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand All @@ -21,26 +29,31 @@ repos:
args: [--maxkb=2048]
- id: check-merge-conflict
- id: check-executables-have-shebangs

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: forbid-crlf
- id: forbid-tabs

- repo: https://github.com/sirosen/fix-smartquotes
rev: 0.2.0
hooks:
- id: fix-smartquotes

- repo: https://github.com/k8s-at-home/sops-pre-commit
rev: v2.1.1
hooks:
- id: forbid-secrets

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: markdownlint
args:
- --config
- ".github/linters/markdownlint/.markdownlint.yaml"
- ".ci/markdownlint/.markdownlint.yaml"

- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
Expand Down
5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

4 changes: 2 additions & 2 deletions .taskfiles/format/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tasks:
cmds:
- >-
prettier
--config '.github/linters/prettier/.prettierrc.yaml'
--config '.ci/prettier/.prettierrc.yaml'
--list-different
--ignore-unknown
--parser=markdown
Expand All @@ -25,7 +25,7 @@ tasks:
cmds:
- >-
prettier
--config '.github/linters/prettier/.prettierrc.yaml'
--config '.ci/prettier/.prettierrc.yaml'
--list-different
--ignore-unknown
--parser=yaml
Expand Down
11 changes: 8 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@
"setup": "import",
"config": "environment"
},
"prettier.configPath": ".github/linters/prettier/.prettierrc.yaml",
"prettier.ignorePath": ".prettierignore",
"prettier.configPath": ".ci/prettier/.prettierrc.yaml",
"prettier.ignorePath": ".ci/prettier/.prettierignore",
"yaml.schemas": {
"Kubernetes": "kubernetes/*.yaml",
"https://json.schemastore.org/kustomization.json": "file:///Users/scotte/Development/k8s-homelab/kubernetes/apps/tekton/tasks/kustomization.yaml"
},
"yaml.customTags": ["!env_var"],
"explorer.autoReveal": false
"explorer.autoReveal": false,
"markdownlint.config": {
"MD033": false,
"MD041": false,
"MD045": false
}
}

0 comments on commit 1f77bb9

Please sign in to comment.