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

[FEATURE REQUEST] Add Ansible Lint to build pipeline #1176

Closed
1 of 13 tasks
to-bar opened this issue Apr 21, 2020 · 9 comments
Closed
1 of 13 tasks

[FEATURE REQUEST] Add Ansible Lint to build pipeline #1176

to-bar opened this issue Apr 21, 2020 · 9 comments

Comments

@to-bar
Copy link
Contributor

to-bar commented Apr 21, 2020

Is your feature request related to a problem? Please describe.
Currently we have the ability to use Ansible-lint in the devcontainer and output the results in junit format.

Describe the solution you'd like
We want to integrate this into the Azure build pipelines as well and publish the results:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=trx%2Cyaml

Describe alternatives you've considered
None

Additional context
See https://github.com/epiphany-platform/epiphany/blob/develop/core/src/epicli/.vscode/tasks.json how Ansible-lint can be executed.


DoD checklist

  • Changelog updated
  • COMPONENTS.md updated / doesn't need to be updated
  • Schema updated / doesn't need to be updated
  • Feature has automated tests
  • Automated tests passed (QA pipelines)
    • apply
    • upgrade
  • Idempotency tested
  • Documentation added / updated / doesn't need to be updated
  • All conversations in PR resolved
  • Solution meets requirements and is done according to design doc
  • Usage compliant with license
  • Backport tasks created / doesn't need to be backported
@to-bar to-bar added this to the Improvements milestone Apr 21, 2020
@rafzei rafzei changed the title Add Ansible Lint to build pipeline and configure to detect tasks without a name [FEATURE REQUEST] Add Ansible Lint to build pipeline Jul 29, 2020
@atsikham
Copy link
Contributor

atsikham commented Aug 7, 2020

@rafzei It also can be configured via pre-commit git hooks.

@rafzei
Copy link
Contributor

rafzei commented Oct 16, 2020

@rafzei It also can be configured via pre-commit git hooks.

GH Actions is also an option. Anyway, first thing is to create a list of roles as in issue description.

@to-bar
Copy link
Contributor Author

to-bar commented Oct 28, 2020

@seriva
Copy link
Collaborator

seriva commented Aug 31, 2021

Also generate output using: https://pypi.org/project/ansible-lint-junit/
Then publish with: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=trx%2Cyaml

This because pytest and pylint are also producing junit output at this point, so we can have everything similar.

@mkyc
Copy link
Contributor

mkyc commented Oct 8, 2021

Consider using GitHub Actions.

@to-bar
Copy link
Contributor Author

to-bar commented Nov 5, 2021

Waits for ansible/ansible-lint#1446

@asciible
Copy link
Contributor

I tried all workarounds mentioned in ansible/ansible-lint#1446, without success; the load-failure false positives keep showing.
So, as @to-bar said, this should wait for the resolution of that bug.

@asciible
Copy link
Contributor

asciible commented Jan 13, 2022

Tested on pipeline with:

cd $(System.DefaultWorkingDirectory)

mkdir -p linting_tests
ansible-lint --nocolor \
             --parseable-severity \
             > linting_tests/ansible_lint_errors

# Suppress the next line when the "load-failure" bug in ansible-lint is solved
sed -i '/load-failure/d' linting_tests/ansible_lint_errors

error_count=$(wc -l linting_tests/ansible_lint_errors | awk '{ print $1 }')

# Convert to junit
ansible-lint-junit linting_tests/ansible_lint_errors \
             -o linting_tests/ansible_lint_errors.xml

test $error_count -le $(ansible_lint_error_threshold)

Take a look at the [DRAFT] CI build ansible-lint pipeline for a full picture

@to-bar
Copy link
Contributor Author

to-bar commented Jan 13, 2022

  1. Please add the bug number/link to the comment over sed -i '/load-failure/d'
  2. I think we can install all prerequisites in Dockerfile to save time - then they will be present in Azure DevOps agent image we use

@seriva seriva closed this as completed Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants