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

Recursively extract tasks from blocks #1809

Merged
merged 3 commits into from Jan 12, 2022

Conversation

cognifloyd
Copy link
Member

allow matchtask() to match embedded tasks

- block:
  - block:
    - template:
        src: ...

See for example:
https://github.com/ansible-community/ansible-lint/blob/ff90dd4a5b1f105028a4c4d5d70a9cd2bcb69bdb/examples/roles/role_for_no_same_owner/tasks/fail.yml#L13-L19

The no-same-owner rule, added in #1450, uses that test tasks file. It does its own task parsing to ensure it can recursively find tasks. We should allow all rules to recursively find tasks.

@cognifloyd cognifloyd requested a review from a team as a code owner January 11, 2022 18:12
@cognifloyd cognifloyd requested review from relrod, cidrblock and priyamsahoo and removed request for a team January 11, 2022 18:12
@ssbarnea ssbarnea added the bug label Jan 12, 2022
Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

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

This change needs a modification of at least one test that will verify the fixed bug or we risk breaking it in the future.

Can you modify one test or add a new one that ensures that this change fixes a bug? The test should fail without it and pass after this change goes in.

If I understood correctly it should be ok to modify one example and add a deep bug that is not found without this change.

allow matchtask() to match embedded tasks

- block:
  - block:
    - template:
        src: ...
@copart-jafloyd copart-jafloyd force-pushed the recursive-extract_from_list branch 2 times, most recently from 2a984e4 to c1cccd2 Compare January 12, 2022 15:35
@cognifloyd
Copy link
Member Author

LOL. I updated CommandHasChangesCheckRule to detect command tasks in blocks... and now lots of tests are failing because we don't have changed_when in most of the examples.

@ssbarnea
Copy link
Member

Updating one rule/test to make use of it should be enough to prevent regression. Feel free to add changed_when: false or to update the tests to count for the new number of failures.

Now that CommandHasChangesCheckRule looks in blocks,
we need to adjust a playbook to make sure it does not
have false positives.
@cognifloyd
Copy link
Member Author

I only had to update 1 playbook. 😌 Tests are green now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants