Skip to content

Commit 9a1931e

Browse files
committed
Update pre-commit workflow to install Ansible and dependent collections and roles for ansible-lint
Signed-off-by: Webster Mudge <[email protected]>
1 parent 3641624 commit 9a1931e

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

.github/workflows/pre-commit.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
# Copyright 2024 Cloudera, Inc.
2+
# Copyright 2025 Cloudera, Inc.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -13,16 +13,40 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
name: Execute Precommit Linting and Checks
16+
name: Lint Collection
1717

1818
on:
1919
pull_request:
2020
push:
2121
branches: [main, devel]
2222
jobs:
2323
pre-commit:
24+
name: Lint collection
2425
runs-on: ubuntu-latest
2526
steps:
26-
- uses: actions/checkout@v4
27-
- uses: actions/setup-python@v5
28-
- uses: pre-commit/[email protected]
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Python and caching
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: "3.12"
34+
cache: "pip"
35+
36+
- name: Set up Ansible and Ansible collections and roles
37+
run: |
38+
sudo update-alternatives --install /usr/bin/python python $(which python3) 1
39+
pip install --upgrade pip
40+
pip install "ansible-core<2.17" ansible-builder bindep pycodestyle voluptuous pylint pyyaml ansible-lint
41+
42+
- name: Install Ansible collections and roles
43+
run: |
44+
mkdir -p /usr/share/ansible/collections /usr/share/ansible/roles
45+
ansible-galaxy collection install -r builder/requirements.yml -p /usr/share/ansible/collections
46+
ansible-galaxy role install -r builder/requirements.yml -p /usr/share/ansible/roles
47+
48+
- name: Execute pre-commit
49+
uses: pre-commit/[email protected]
50+
env:
51+
ANSIBLE_COLLECTION_PATHS: /usr/share/ansible/collections
52+
ANSIBLE_ROLE_PATHS: /usr/share/ansible/roles

0 commit comments

Comments
 (0)