mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2026-08-09 15:33:18 +02:00
fix(ci): make Ansible collection lint resilient
- Retry Galaxy collection installation on transient network failures\n- Cache installed collections before running pre-commit\n- Run Ansible-lint offline after collection provisioning
This commit is contained in:
committed by
Techno Tim
parent
5747bfce0e
commit
665e274820
@@ -22,6 +22,7 @@ jobs:
|
||||
cache: 'pip' # caching pip dependencies
|
||||
|
||||
- name: Restore Ansible cache
|
||||
id: cache-ansible
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # 6.1.0
|
||||
with:
|
||||
path: ~/.ansible/collections
|
||||
@@ -37,6 +38,26 @@ jobs:
|
||||
python3 -m pip install -r requirements.txt
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Install Ansible collections with retries
|
||||
if: steps.cache-ansible.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
for attempt in 1 2 3 4 5; do
|
||||
if ansible-galaxy collection install -r collections/requirements.yml; then
|
||||
exit 0
|
||||
fi
|
||||
echo "Ansible Galaxy attempt ${attempt} failed; retrying."
|
||||
sleep $((attempt * 10))
|
||||
done
|
||||
exit 1
|
||||
|
||||
- name: Save Ansible collection cache
|
||||
if: steps.cache-ansible.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # 6.1.0
|
||||
with:
|
||||
path: ~/.ansible/collections
|
||||
key: ansible-${{ hashFiles('collections/requirements.yml') }}
|
||||
|
||||
- name: Run pre-commit
|
||||
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # 3.0.1
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ repos:
|
||||
- id: ansible-lint
|
||||
additional_dependencies: [ansible-core==2.18.0]
|
||||
language_version: python3.12
|
||||
args: [--offline]
|
||||
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||
rev: v0.9.0.6
|
||||
hooks:
|
||||
|
||||
Reference in New Issue
Block a user