Skip to content

feat: add ansible.ansible-lint composite action and integration workflow - #30

Open
posquit0 wants to merge 4 commits into
mainfrom
feat/ansible-workflows
Open

posquit0 wants to merge 4 commits into
mainfrom
feat/ansible-workflows

Conversation

@posquit0

Copy link
Copy Markdown
Member

👋 Background

The Ansible half of #1, split out so it can be reviewed and adopted on its own. #1 keeps the Packer actions and the packer.templates.integration workflow; nothing is shared between the two halves, so the split is a clean cut with no changes to the content.

CI building blocks for the Ansible project in the packer-templates repository, following the same convention as the terraform.* actions and integration workflows: the logic lives in a composite action and the workflow only wires it together.

🔗 Related Issues

⚙️ Description

New composite action

Action Purpose
ansible.ansible-lint ansible-lint from the project directory, optionally installing Galaxy collections first

It takes target_dir and follows the check-action interface every check action on main now has: it resolves the target, runs through shell.run, exposes skipped, stdout, stderr, and exitcode, and on failure appends its output to the job summary through github.step-summary.

  • requirements_file installs the Galaxy collections into RUNNER_TEMP rather than the checkout, so they resolve for linting but are never linted themselves. ANSIBLE_COLLECTIONS_PATH is pinned during the install, otherwise ansible-galaxy reports the collections as already present when a copy exists elsewhere on the runner and installs nothing.
  • annotations_enabled (default true) re-runs ansible-lint with -f json on failure and turns each finding into a workflow error, warning, or notice, matching the interface feat(actions): annotate the failing lines from validate, tflint, and actionlint #24 and feat(actions): annotate findings from terraform fmt, terraform-docs, and check-jsonschema #26 gave the Terraform and GitHub Actions checks.
  • The action skips with a notice when target_dir holds no YAML files, since ansible-lint exits 0 there and would report a vacuous pass.
  • --nocolor is passed so the job summary does not carry escape sequences.

New reusable workflow

Workflow Jobs Purpose
ansible.integration.yaml lint Install ansible-lint and lint one Ansible project directory

python comes from mise.setup-tools, so a repository's own mise.toml or .tool-versions still wins over the workflow's python_version default. ansible-lint is then installed with pip, pinned by ansible_lint_version when it is set.

Validation

yamllint (repo config) and actionlint pass on both files.

The action's script was previously executed directly against a checkout of tedilabs/packer-templates:

Case Result
Galaxy install from ansible/requirements.yaml into an empty path Installs all four pinned collections
ansible-lint against ansible/ Passes, 37 files, production profile, no escape sequences in the log

🚨 To Reviewers

The two files are byte-identical to their state on feat/packer-workflows at the head of #1, so a review that already covered them there carries over.

@github-actions

Copy link
Copy Markdown

GitHub Actions Integration

Repository actionlint check-jsonschema (workflows) check-jsonschema (actions)
tedilabs/github-actions

✅ All 1 passed.

Without `install_args`, `mise install` resolves every tool in the calling
repository's mise config. `packer-templates` pins `packer` and
`terraform` in `.tool-versions`, neither of which a lint job runs, as the
Terraform integration workflows already avoid by naming the tools they
need.
@posquit0

Copy link
Copy Markdown
Member Author

Added the missing install_args in 1fa65d0: the mise step now passes install_args: python, since ansible-lint is installed from pip in the next step.

Without it, mise install resolves every tool in the calling repository's mise config — for packer-templates that is packer 1.15.4 and terraform 1.15.6, neither of which this lint job runs. Matches how the Terraform integration workflows name the tools they need.

…se config

Drop the `python_version` input and the throwaway global mise config it
was written to, matching the Terraform integration workflows since #18:
the tools and their versions come from the calling repository's own
`mise.toml` or `.tool-versions`, with no workflow-side default. A caller
therefore has to pin `python` there.

Pass the project directory as `working_directory` as well, so a
`mise.toml` placed there overrides the repository-wide one.
@posquit0

Copy link
Copy Markdown
Member Author

Same treatment as the Packer workflow — 5afd15c.

  • default-tools removed, along with the python_version input, matching the Terraform integration workflows since feat(workflows)!: take Terraform tool versions from the repository's mise config #18: no workflow-side default, versions come from the calling repository's mise config. The consequence is that a caller now has to pin python there, which is called out in the step comment.
  • working_directory: ${{ inputs.target_dir }} added, so a mise.toml inside the Ansible project directory overrides the repository-wide one.

ansible_lint_version is untouched, since ansible-lint still comes from pip rather than mise.

Companion change on the consumer side: tedilabs/packer-templates#17 folds .tool-versions into mise.toml and adds the python pin this now depends on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant