ci: 按路径拆分静态检查
yaml / yaml (pull_request) Successful in 20s
terraform / validate (pull_request) Successful in 22s
ansible / lint (pull_request) Successful in 4m5s

This commit is contained in:
2026-09-10 08:33:26 +00:00
parent 1b2e551392
commit 8f6b08bd20
4 changed files with 114 additions and 83 deletions
+57
View File
@@ -0,0 +1,57 @@
---
name: ansible
on:
push:
branches: [main]
paths:
- 'infrastructure/**/ansible/**'
- '.ansible-lint'
- '.gitea/workflows/ansible.yml'
pull_request:
paths:
- 'infrastructure/**/ansible/**'
- '.ansible-lint'
- '.gitea/workflows/ansible.yml'
env:
ANSIBLE_COLLECTIONS_PATH: /root/.ansible/collections
jobs:
lint:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Bootstrap uv
run: |
python3 -m pip install --user --break-system-packages \
--index-url https://pypi.org/simple --quiet uv==0.11.7
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Install ansible-lint and collections
run: |
for i in 1 2 3 4 5; do
uv tool install ansible-core --with paramiko --with pywinrm --quiet && break
echo "attempt $i failed"; sleep 10
done
for i in 1 2 3 4 5; do
uv tool install ansible-lint --quiet && break
echo "attempt $i failed"; sleep 10
done
export PATH="$HOME/.local/bin:$PATH"
for p in infrastructure/proxmox infrastructure/samba-ad infrastructure/openbao; do
ansible-galaxy collection install \
-r "$p/ansible/requirements.yml" -p "$ANSIBLE_COLLECTIONS_PATH"
done
- name: ansible-lint
run: |
export PATH="$HOME/.local/bin:$PATH"
rc=0
for p in infrastructure/openbao infrastructure/samba-ad infrastructure/proxmox; do
echo "::group::$p"
(cd "$p/ansible" && ansible-lint -c ../../../.ansible-lint --nocolor -f pep8 .) || rc=1
echo "::endgroup::"
done
exit $rc