Skip to content

Commit

Permalink
feat: add Ansible linter (#37)
Browse files Browse the repository at this point in the history
feat: add docs to the README
  • Loading branch information
coreone authored Jan 29, 2024
1 parent f745d7e commit e51cd07
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ansible-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: python-linting

'on':
workflow_call:
inputs:
additional_packages:
default: ''
description: String of additional packages that should be installed.
required: false
type: string
jobs_run_on:
default: ubuntu-latest
description: The runner group on which jobs will run.
required: false
type: string
python_version:
description: The version of Python to use for the run.
default: '3.11'
required: false
type: string
timeout_minutes:
description: The maximum time (in minutes) for a job to run.
default: 5
required: false
type: number
working_directory:
description: The working directory where all jobs should be executed.
default: '.'
required: false
type: string

jobs:
linting:
defaults:
run:
working-directory: ${{ inputs.working_directory }}
runs-on: ${{ inputs.jobs_run_on }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install additional packages
if: ${{ inputs.additional_packages != '' }}
run: sudo apt-get install -y ${{ inputs.additional_packages }}
- name: Install poetry
run: pipx install poetry
- name: "Set up Python ${{ inputs.python_version }}"
uses: actions/setup-python@v5
with:
cache: poetry
python-version: "${{ inputs.python_version }}"
- name: Configure Poetry
run: poetry config virtualenvs.in-project true
- name: Install dependencies
run: poetry install
- name: Ansible-lint version
run: poetry run ansible-lint --version
- name: Lint with yamllint
run: poetry run yamllint . -s
- name: Lint with ansible-lint
run: poetry run ansible-lint -s --offline
timeout-minutes: ${{ inputs.timeout_minutes }}
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ ADRs in the repository. The workflow assumes the output goes to the `README.md`
same directory as the ADRs. This check makes sure PRs haven't forgotten to run this
command as part of their commits.

### ansible-lint.yaml

This workflow will setup [Python][5] (`3.11`) and lint the repository using both
[yamllint][13] and [ansible-lint](https://github.com/ansible/ansible-lint). [Poetry][3]
is used to install the [Python][5] dependencies. Both [yamllint][13] and
[ansible-lint](https://github.com/ansible/ansible-lint) are expected to be installed by
the [Poetry][3] configuration in the repository using this workflow.

#### ansible-lint Inputs

* `additional_packages`: String of additional packages that should be
installed. Default: ``
* `python_version`: The version of [Python][5] to use. Default: `3.11`

### conventional-commit.yaml

This workflow will run the
Expand Down Expand Up @@ -107,7 +121,7 @@ and `8`. The dependency installation and unit tests will all happen using

### python-deploy-to-pypi.yaml

This workflow will setup [Python][5] (`3.1.1`) and do a build and deploy of the
This workflow will setup [Python][5] (`3.11`) and do a build and deploy of the
[Python][5] package to [PyPi][2] using [Poetry][3].

#### python-deploy-to-pypi Inputs
Expand All @@ -123,9 +137,9 @@ This workflow will setup [Python][5] (`3.1.1`) and do a build and deploy of the

### python-lint.yaml

This workflow will setup [Python][5] (`3.1.1`) and lint the repository.
This workflow will setup [Python][5] (`3.11`) and lint the repository.
[Poetry][3] is used to install any [Python][5] dependencies. By default the
linters run are [yamllint](https://github.com/adrienverge/yamllint), and
linters run are [yamllint][13], and
[pylama](https://github.com/AtomLinter/linter-pylama). As of August 2023,
[pylama](https://github.com/AtomLinter/linter-pylama) has been deprecated, so
you can run [Ruff](https://github.com/astral-sh/ruff) as the [Python][5] linter
Expand All @@ -146,7 +160,7 @@ by setting the `use_ruff` input to `true`.

### python-test-deploy-to-pypi.yaml

This workflow will setup [Python][5] (`3.1.1`) and do a build and deploy of the
This workflow will setup [Python][5] (`3.11`) and do a build and deploy of the
[Python][5] package to [Test PyPi][6] using [Poetry][3].

#### python-test-deploy-to-pypi Inputs
Expand Down Expand Up @@ -281,3 +295,4 @@ As a note, this repository uses the default labels for formatting the
[10]: https://www.terraform.io/ "Terraform"
[11]: https://terragrunt.gruntwork.io/ "Terragrunt"
[12]: https://forge.puppet.com/ "Puppet Forge"
[13]: https://github.com/adrienverge/yamllint "yamllint"

0 comments on commit e51cd07

Please sign in to comment.