How to automatically detect issues in your YAML file with Appveyor
10x learner
Posted on February 16, 2022
Hello ! Iβm Xavier Jouvenot and in this small post, I am going to explain how to automatically detect issues in your YAML file with Appveyor.
Self promotion: You can find other articles on computer science and programming on my website π
Problematic
If you have CI/CD processes or if you want to create some for your project, and you have some YAML files versioned, then it may be important to make sure that they are always properly written and donβt contain any error due to indentation mistake, for example.
Moreover, having an automatic process to approve the YAML will enhance the quality of your project and facilitate the contribution from other developers from your team, or even external collaborators, since they would have direct information from the CI about the issues in the YAML files.
Solution
The short answer, for the people who donβt want to read through the entire article (I know you do that! I do it too π) is to insert the following steps in your Appveyor process:
install:
- pip install yamllint
build_script:
- yamllint --strict .
If you have my previous article about "How to easily detect issues in your YAML files", you may already know about about the tool named yamllint. For those who donβt know, this is a linter, a software able to analyse YAML files and displays the issues it found in them.
In the steps above, I start by installing this tool with the python package manager pip. Then, I run yamllint
at the root of the folder, meaning that it is going to find all the YAML files in repository and analyses them all. Moreover, by using the flag --strict
, even the warnings found by the tool will be treated as errors, making the check fail, and notifying use that the commit has some issues.
If you want, you can specify directly the list of the YAML file, instead of letting the tool scan through all the repository recursively. π
Finally, it is interesting to notice that those steps can be uses on any environment available in Appveyor. I actually made a GitHub repository in which I setup Appveyor to run the steps described before on every environment available. You can take a look here as I will update it when new environment will be available on Appveyor π
Thank you all for reading this article, And until my next article, have a splendid day π
Interesting links
- GitHub repository with the actual working code up to date, and the Appveyor jobs runned
- Appveyor build worker images
- Appveyor documentation
- yamllint GitHub repository, documentation and python package
- Learn YAML in 18 mins, by TechWorld with Nana
- YAML website and specifications
- Linter definition
- YAML wikipedia page
- pip website
- 10xlearner website
Posted on February 16, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.