Skip to content
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

[WIP] Ansible-lint: Add example config for github action #612

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
MarkusTeufelberger marked this conversation as resolved.
Show resolved Hide resolved
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

skip_list:
# TODO: Fix and enable one-by-one over time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But only the ones that make sense. sanity[cannot-ignore] looks pretty much wrong, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope that the eventual goal is to have both the collection(s) and ansible-lint rules in a state that no rule skips or any changes to default configs are necessary. For sanity[cannot-ignore] for example I am hardlocked on ansible/ansible#79700 making it into ansible-core and every version of ansible-core falling out of support until I can disable this in my collection. Similar with the shebangs in this repo here apparently?

There are some easy wins with fixing the long tail of errors (end of line whitespace and such) and automatic rewrites could be used or introduced for some things too. There are however also some issues with that (e.g. ansible/ansible-lint#3226 will hit every collection created from the default template).

- command-instead-of-module
- command-instead-of-shell
- key-order[task]
- jinja[spacing]
- no-free-form
- schema[galaxy]
- schema[tasks]
- name[missing]
- name[play]
- var-naming[no-role-prefix]
- var-naming[pattern]
- yaml[brackets]
- yaml[comments]
- yaml[empty-lines]
- yaml[indentation]
- yaml[line-length]
- yaml[new-line-at-end-of-file]
- yaml[trailing-spaces]
- name[template]
- name[casing]
- risky-file-permissions
- risky-shell-pipe
- galaxy[tags]
- ignore-errors
- no-changed-when
- no-handler
- sanity[cannot-ignore]
- fqcn[action-core]
- jinja[invalid]
- fqcn[action]
18 changes: 18 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

name: ansible-lint
on: # yamllint disable-line rule:truthy
pull_request:
branches: ["main", "stable-*"]
jobs:
build:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Run ansible-lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A checkout step needs to be added before here. There was a breaking change in the action that started requiring that.

uses: ansible/ansible-lint-action@v6
MarkusTeufelberger marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# https://github.com/marketplace/actions/ansible-test

name: EOL CI
on:
on: # yamllint disable-line rule:truthy
MarkusTeufelberger marked this conversation as resolved.
Show resolved Hide resolved
# Run EOL CI against all pushes (direct commits, also merged PRs), Pull Requests
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Collection Docs
concurrency:
group: docs-pr-${{ github.head_ref }}
cancel-in-progress: true
on:
on: # yamllint disable-line rule:truthy
pull_request_target:
types: [opened, synchronize, reopened, closed]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Collection Docs
concurrency:
group: docs-push-${{ github.sha }}
cancel-in-progress: true
on:
on: # yamllint disable-line rule:truthy
push:
branches:
- main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later

name: execution environment
on:
on: # yamllint disable-line rule:truthy
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

name: Verify REUSE

on:
on: # yamllint disable-line rule:truthy
push:
branches: [main]
pull_request:
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/acme_inspect/tasks/impl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@
account_uri: "{{ account_creation.headers.location }}"
url: "{{ new_order.headers.location }}"
method: get
register: order
- debug: var=order
register: cert_order
- debug: var=cert_order

- name: Get authzs for order
- name: Get authzs for cert_order
acme_inspect:
acme_directory: https://{{ acme_host }}:14000/dir
acme_version: 2
Expand All @@ -120,7 +120,7 @@
account_uri: "{{ account_creation.headers.location }}"
url: "{{ item }}"
method: get
loop: "{{ order.output_json.authorizations }}"
loop: "{{ cert_order.output_json.authorizations }}"
register: authz
- debug: var=authz

Expand Down
14 changes: 7 additions & 7 deletions tests/integration/targets/acme_inspect/tests/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@
- new_order.output_json.status == 'pending'
- "'finalize' in new_order.output_json"

- name: Check get order output
- name: Check get cert_order output
assert:
that:
- order is not changed
- "'directory' in order"
- "'headers' in order"
- "'output_text' in order"
- "'output_json' in order"
- cert_order is not changed
- "'directory' in cert_order"
- "'headers' in cert_order"
- "'output_text' in cert_order"
- "'output_json' in cert_order"
# The order of identifiers and authorizations is randomized!
# - new_order.output_json == order.output_json
# - new_order.output_json == cert_order.output_json

- name: Check get authz output
assert:
Expand Down