diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4a78b887..d7a374be 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,5 +11,5 @@ - [ ] Ran `site.yml` playbook - [ ] Ran `reset.yml` playbook - [ ] Did not add any unnecessary changes -- [ ] 🚀 - [ ] Ran pre-commit install at least once before committing +- [ ] 🚀 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..54be8ff0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,15 @@ +--- +name: "CI" +on: + pull_request: + push: + branches: + - master + paths-ignore: + - '**/README.md' +jobs: + lint: + uses: ./.github/workflows/lint.yml + test: + uses: ./.github/workflows/test.yml + needs: [lint] diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f0d5345c..495fa7e6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,12 +1,7 @@ --- name: Linting on: - pull_request: - push: - branches: - - master - paths-ignore: - - '**/README.md' + workflow_call: jobs: pre-commit-ci: name: Pre-Commit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f05cd74..2acad54f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,17 +1,11 @@ --- name: Test on: - pull_request: - push: - branches: - - master - paths-ignore: - - '**/README.md' + workflow_call: jobs: molecule: name: Molecule runs-on: macos-12 - strategy: matrix: scenario: diff --git a/.gitignore b/.gitignore index 94927b1b..92ba18c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .env/ -*.log \ No newline at end of file +*.log diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7583144b..e6fbf597 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,35 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: 3298ddab3c13dd77d6ce1fc0baf97691430d84b0 # v4.3.0 hooks: - id: requirements-txt-fixer - id: sort-simple-yaml - id: detect-private-key + - id: check-merge-conflict + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] - repo: https://github.com/adrienverge/yamllint.git - rev: v1.28.0 + rev: 9cce2940414e9560ae4c8518ddaee2ac1863a4d2 # v1.28.0 hooks: - id: yamllint args: [-c=.yamllint] - repo: https://github.com/ansible-community/ansible-lint.git - rev: v6.8.2 + rev: a058554b9bcf88f12ad09ab9fb93b267a214368f # v6.8.6 hooks: - id: ansible-lint - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.8.0.4 + rev: 4c7c3dd7161ef39e984cb295e93a968236dc8e8a # v0.8.0.4 hooks: - id: shellcheck + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: 04618e68aa2380828a36a23ff5f65a06ae8f59b9 # v1.3.1 + hooks: + - id: remove-crlf + - id: remove-tabs + - repo: https://github.com/sirosen/texthooks + rev: 30d9af95631de0d7cff4e282bde9160d38bb0359 # 0.4.0 + hooks: + - id: fix-smartquotes diff --git a/LICENSE b/LICENSE index 4947287f..f433b1a5 100644 --- a/LICENSE +++ b/LICENSE @@ -174,4 +174,4 @@ incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS \ No newline at end of file + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index e7879c61..1b7dd87a 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,10 @@ It is run automatically in CI, but you can also run the tests locally. This might be helpful for quick feedback in a few cases. You can find more information about it [here](molecule/README.md). +### Pre-commit Hooks + +This repo uses `pre-commit` and `pre-commit-hooks` to lint and fix common style and syntax errors. Be sure to install python packages and then run `pre-commit install`. For more information, see [pre-commit](https://pre-commit.com/) + ## Thanks 🤝 This repo is really standing on the shoulders of giants. Thank you to all those who have contributed and thanks to these repos for code and ideas: diff --git a/ansible.cfg b/ansible.cfg index 12821fe5..faecd2f6 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -20,4 +20,4 @@ scp_if_ssh = smart retries = 3 ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o Compression=yes -o ServerAliveInterval=15s pipelining = True -control_path = %(directory)s/%%h-%%r \ No newline at end of file +control_path = %(directory)s/%%h-%%r diff --git a/deploy.sh b/deploy.sh index 5fa1b30a..808cdb37 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,3 +1,3 @@ #!/bin/bash -ansible-playbook site.yml -i inventory/my-cluster/hosts.ini \ No newline at end of file +ansible-playbook site.yml -i inventory/my-cluster/hosts.ini diff --git a/requirements.in b/requirements.in index 6cb45dd8..151033d3 100644 --- a/requirements.in +++ b/requirements.in @@ -7,5 +7,6 @@ molecule-vagrant>=1.0.0 molecule>=4.0.3 netaddr>=0.8.0 pre-commit>=2.20.0 +pre-commit-hooks>=1.3.1 pyyaml>=6.0 -yamllint>=1.28.0 \ No newline at end of file +yamllint>=1.28.0 diff --git a/requirements.txt b/requirements.txt index 85768b93..f9bf7ee4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -128,6 +128,8 @@ pluggy==1.0.0 # via molecule pre-commit==2.20.0 # via -r requirements.in +pre-commit-hooks==4.3.0 + # via -r requirements.in pyasn1==0.4.8 # via # pyasn1-modules @@ -179,7 +181,9 @@ rich==12.6.0 rsa==4.9 # via google-auth ruamel-yaml==0.17.21 - # via ansible-lint + # via + # ansible-lint + # pre-commit-hooks ruamel-yaml-clib==0.2.7 # via ruamel-yaml selinux==0.2.1 @@ -196,7 +200,9 @@ text-unidecode==1.3 toml==0.10.2 # via pre-commit tomli==2.0.1 - # via black + # via + # black + # pre-commit-hooks typing-extensions==4.4.0 # via # black diff --git a/roles/k3s/master/templates/metallb.crds.j2 b/roles/k3s/master/templates/metallb.crds.j2 index 809733b7..e984ebbc 100644 --- a/roles/k3s/master/templates/metallb.crds.j2 +++ b/roles/k3s/master/templates/metallb.crds.j2 @@ -77,7 +77,7 @@ spec: aggregationLength: default: 32 description: The aggregation-length advertisement option lets - you “roll up” the /32s into a larger prefix. + you "roll up" the /32s into a larger prefix. format: int32 minimum: 1 type: integer @@ -167,7 +167,7 @@ spec: aggregationLength: default: 32 description: The aggregation-length advertisement option lets - you “roll up” the /32s into a larger prefix. + you "roll up" the /32s into a larger prefix. format: int32 minimum: 1 type: integer @@ -359,7 +359,7 @@ spec: aggregationLength: default: 32 description: The aggregation-length advertisement option lets you - “roll up” the /32s into a larger prefix. Defaults to 32. Works for + "roll up" the /32s into a larger prefix. Defaults to 32. Works for IPv4 addresses. format: int32 minimum: 1 @@ -367,7 +367,7 @@ spec: aggregationLengthV6: default: 128 description: The aggregation-length advertisement option lets you - “roll up” the /128s into a larger prefix. Defaults to 128. Works + "roll up" the /128s into a larger prefix. Defaults to 128. Works for IPv6 addresses. format: int32 type: integer