Skip to content

Commit

Permalink
chore: pre-commit improvements (#348)
Browse files Browse the repository at this point in the history
##### SUMMARY

- Speed up pre-commit by moving some tasks out of pre-commit
- Move network related hooks out of pre-commit (allow enabling
pre-commit.ci)
- Some optimization
- Use pre-commit.ci
  • Loading branch information
jooola authored Oct 6, 2023
1 parent 7f4e4e9 commit 9eab32c
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 306 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

jobs:
pre-commit:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -15,9 +15,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.x
cache: pip
cache-dependency-path: requirements.txt

- name: Install dependencies
run: pip install pre-commit
run: make venv

- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure
- name: Lint docs
run: make lint-docs
26 changes: 26 additions & 0 deletions .github/workflows/vendor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Vendor

on:
push:
branches: [main, stable-1]
paths:
- plugins/module_utils/vendor/**
- scripts/vendor.py
pull_request:
paths:
- plugins/module_utils/vendor/**
- scripts/vendor.py

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Ensure vendors are not diverging
run: make vendor-check
21 changes: 1 addition & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ repos:
hooks:
- id: prettier
files: \.(md|ya?ml)$
exclude: ^changelogs/changelog.yaml$

- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
Expand All @@ -49,22 +48,12 @@ repos:
- id: antsibull-changelog-lint
- id: antsibull-changelog-lint-changelog-yaml

- repo: local
hooks:
- id: antsibull-docs-lint-collection
name: antsibull-docs lint-collection
description: Lint the collection docs
language: python
entry: antsibull-docs lint-collection-docs --plugin-docs .
pass_filenames: false
additional_dependencies:
- antsibull-docs==2.3.1

- repo: https://github.com/ansible/ansible-lint
rev: v6.20.3
hooks:
- id: ansible-lint
name: ansible-lint
args: [--offline]

- repo: local
hooks:
Expand All @@ -83,14 +72,6 @@ repos:

- repo: local
hooks:
- id: check-hcloud-vendor
name: check hcloud vendor
description: Ensure the hcloud vendored files are in sync
language: python
entry: python3 scripts/vendor.py
pass_filenames: false
files: ^scripts/vendor.py$

- id: check-integration-test-files
name: check integration test files
description: Ensure the integration test files are in sync
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ SHELL := bash
vendor:
python3 scripts/vendor.py

vendor-check:
python3 scripts/vendor.py --check

venv:
python3 -m venv venv
venv/bin/pip install -r requirements.txt

lint: venv
venv/bin/pylint plugins

lint-docs:
venv/bin/antsibull-docs lint-collection-docs --plugin-docs .

clean:
git clean -xdf \
-e tests/integration/cloud-config-hcloud.ini
Loading

0 comments on commit 9eab32c

Please sign in to comment.