Skip to content

Update pre-commit and linting #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8aa1f0a
Update pre-commit, Hatch environments, and ansible-lint
wmudge Jul 8, 2025
630336d
Update ansible-lint hook to run offline
wmudge Jul 9, 2025
5630a04
Add ansible-lint configuration and ignore list
wmudge Jul 14, 2025
c01b3c6
Update pre-commit workflow to install Ansible and dependent collectio…
wmudge Jul 15, 2025
570cc93
Initialize core changelog files
wmudge Jul 15, 2025
9b24cb3
Initialize core ansible-list operations and ignore file
wmudge Jul 15, 2025
bedc981
Update required_ansible version to >2.15.0
wmudge Jul 15, 2025
3f75c90
Fix documentation formatting for ansible-lint
wmudge Jul 15, 2025
dfe89e9
Add Python requirements to default environment
wmudge Jul 15, 2025
6599b5e
Update galaxy.yml to 3.0.0-rc.1 release candidate
wmudge Jul 15, 2025
b162010
Update deprecated lint-ansible-docs action
wmudge Jul 15, 2025
203fcf3
Update collection for changelog management
wmudge Jul 15, 2025
aa9bdb6
Add JMESPath to Python requirements
wmudge Jul 15, 2025
e4939eb
Add cloud and cluster collections as devel
wmudge Jul 15, 2025
76ec77c
Add collection dependencies to pre-commit (Python and system)
wmudge Jul 16, 2025
c9aba93
Update dependencies to read from collection's requirements.yml
wmudge Jul 16, 2025
7d455aa
Update collections to latest ansible<2.17 supported versions
wmudge Jul 16, 2025
f93a2f8
Use upstream cloudera.cluster dependency
wmudge Jul 16, 2025
332b9ce
Update older collection versions
wmudge Jul 16, 2025
55f63c4
Update deprecated community.aws modules
wmudge Jul 16, 2025
b3f257c
Update pre-commit workflow for deprecated action
wmudge Jul 16, 2025
c353fc2
Remove ansible-lint from pre-commit due to isolated environments
wmudge Jul 16, 2025
c0f98e6
Add ansible-lint workflow with pre-configured Python environment
wmudge Jul 16, 2025
679dc1d
Remove ansible-lint hook
wmudge Jul 16, 2025
a4b2980
Fix YAML formatting
wmudge Jul 16, 2025
a9154d1
Update requirements.yml
wmudge Jul 16, 2025
1e7f689
Add Ansible paths
wmudge Jul 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# profile: safety
quiet: true
strict: false
verbosity: 0
offline: true
268 changes: 268 additions & 0 deletions .ansible-lint-ignore

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .config/molecule/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Copyright 2024 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
# Copyright 2025 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Lint Collection

on:
pull_request:
push:
branches: [main, devel]
jobs:
pre-commit:
name: Execute ansible-lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Set up Ansible
run: |
sudo update-alternatives --install /usr/bin/python python $(which python3) 1
python -m pip install --upgrade pip
python -m pip install "ansible-core<2.17" ansible-builder bindep pycodestyle voluptuous pylint pyyaml

- name: Install Ansible collections and roles
run: |
mkdir -p /usr/share/ansible/collections /usr/share/ansible/roles
ansible-galaxy collection install . -p /usr/share/ansible/collections
ansible-galaxy collection install -r requirements.yml -p /usr/share/ansible/collections
ansible-galaxy role install -r requirements.yml -p /usr/share/ansible/roles

- name: Set up Ansible collection dependencies
run: |
ansible-builder introspect --write-pip final_python.txt --write-bindep final_bindep.txt /usr/share/ansible/collections
[[ -f final_python.txt ]] && pip install -r final_python.txt || echo "No Python dependencies found."
[[ -f final_bindep.txt ]] && bindep --file final_bindep.txt || echo "No system dependencies found."

- name: Run ansible-lint
uses: ansible/ansible-lint@main
with:
setup_python: false
env:
ANSIBLE_COLLECTION_PATHS: /usr/share/ansible/collections
ANSIBLE_ROLE_PATHS: /usr/share/ansible/roles
2 changes: 1 addition & 1 deletion .github/workflows/label_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));

- name: 'Unzip artifact'
- name: "Unzip artifact"
run: unzip pr_number.zip

- name: Read the PR number
Expand Down
44 changes: 38 additions & 6 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2024 Cloudera, Inc.
---
# Copyright 2025 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,17 +13,48 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Execute Precommit Linting and Checks
name: Check Collection

on:
pull_request:
push:
branches: [main, devel]

jobs:
pre-commit:
name: Execute pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Set up pre-commit and Ansible
run: |
# sudo update-alternatives --install /usr/bin/python python $(which python3) 1
python -m pip install --upgrade pip
python -m pip install pre-commit
# python -m pip install "ansible-core<2.17" ansible-builder bindep pycodestyle voluptuous pylint pyyaml ansible-lint

# - name: Install Ansible collections and roles
# run: |
# mkdir -p /usr/share/ansible/collections /usr/share/ansible/roles
# ansible-galaxy collection install . -p /usr/share/ansible/collections
# ansible-galaxy collection install -r requirements.yml -p /usr/share/ansible/collections
# ansible-galaxy role install -r requirements.yml -p /usr/share/ansible/roles

# - name: Set up Ansible collection dependencies
# run: |
# ansible-builder introspect --write-pip final_python.txt --write-bindep final_bindep.txt /usr/share/ansible/collections
# [[ -f final_python.txt ]] && pip install -r final_python.txt || echo "No Python dependencies found."
# [[ -f final_bindep.txt ]] && bindep --file final_bindep.txt || echo "No system dependencies found."

- name: Run pre-commit
run: |
pre-commit run -a --show-diff-on-failure --color=always
# env:
# ANSIBLE_COLLECTION_PATHS: /usr/share/ansible/collections
# ANSIBLE_ROLE_PATHS: /usr/share/ansible/roles
3 changes: 1 addition & 2 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ name: Publish documentation
on:
push:
branches:
- 'main'
- "main"

workflow_dispatch:

jobs:
build-ansible-docs:
name: Build Ansible Docs
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish_galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ name: Publish to Ansible Galaxy
on:
release:
types: [published]

jobs:
galaxy_release:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reset_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ on:
- synchronize
- ready_for_review
branches:
- 'release/**'
- 'devel'
- 'devel-pvc-base'
- "release/**"
- "devel"
- "devel-pvc-base"

jobs:
reset:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ name: Validate Pull Request
on:
pull_request:
branches:
- 'release/**'
- 'devel'
- "release/**"
- "devel"

jobs:
validate:
Expand All @@ -32,8 +32,8 @@ jobs:
- name: Setup Python and caching
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
python-version: "3.9"
cache: "pip"

- name: Set up Ansible collections
run: |
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Report installed Python dependencies
run: pip freeze

- name: Validate collection
- name: Test collection
run: |
pushd /usr/share/ansible/collections/ansible_collections/cloudera/exe
#ansible-lint
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/validate_pr_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ name: Validate Pull Request documentation
on:
pull_request:
branches:
- 'release/**'
- 'devel'
- "release/**"
- "devel"

workflow_dispatch:

jobs:
validate-docs:
name: Validate Ansible Docs
uses: cloudera-labs/github-actions/.github/workflows/lint-ansible-docs.yml@v1
uses: cloudera-labs/github-actions/.github/workflows/lint-ansible-docs.yml@v2
with:
antsibull-log-upload: true
collection-namespace: cloudera
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,6 @@ cython_debug/

# UV package manager
uv.lock

# Ansible tests
.ansible
34 changes: 31 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2024 Cloudera, Inc.
---
# Copyright 2025 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,13 +15,40 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-json
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: debug-statements
- id: detect-aws-credentials
args:
- --allow-missing-credentials
- id: detect-private-key
- id: forbid-submodules
# - id: name-tests-test
- repo: https://github.com/asottile/add-trailing-comma.git
rev: v3.2.0
hooks:
- id: add-trailing-comma
name: ensure trailing commas
args:
- --py36-plus
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 25.1.0
hooks:
- id: black
name: lint python
# - repo: https://github.com/ansible/ansible-lint
# rev: v25.6.1
# hooks:
# - id: ansible-lint
# name: lint ansible
# language: system
Loading