🙌 Thank you for contributing and joining our mission to help engineers use cloud infrastructure economically and efficiently 🚀.
Join our community Slack channel if you have any questions or need help contributing.
This repo has an extensive list of example pipelines that can be used to jump start Infracost CI usage.
Copy another example that is similar to what you'd like to add. If you don't know which to pick, try the terraform-directory.
- Update your example's readme file with the required steps.
- Run
npm run examples:generate_tests
to generate tests for your example. - Update the repo readme, the examples readme and your new example's readme with the description of the example.
- Send a pull request and wait for an Infracost team member to review it, they'll work with you to update the example's golden file tests and expected output.
Examples are tested by extracting them from the README.md files into an Azure Pipeline.
To extract the examples, the npm run examples:generate_tests
script loops through the example directories, reads the READMEs and extracts any YAML code blocks between the markdown comment markers:
[//]: <> (BEGIN EXAMPLE)
```yml
pr:
- master
name: MyExample
jobs:
- job: my_example
...
```
[//]: <> (END EXAMPLE)
The script replaces any task with displayName
= Post Infracost Comment
with steps to generate and test the content of the comment using golden files from the ./testdata directory.
All the examples are then added to the Azure Pipeline definition examples-test.yml as separate jobs.
The script that handles extracting and modifying the examples is ./scripts/generateExamplesTest.js
Looking to make changes to the core Infracost Azure Pipeline tasks? Here's some caveats to follow:
Each task has a set of tests. To run them:
cd
totasks/<InfracostX>/
.- Run
npm install
. - Run
npm run test
.
To add tests to a given task:
- Add a test file under the
tests/
folder that sets up aMockRunner
with the task you wish to test. This should include all the inputs and pipeline setup you need to run the given scenario. See ./tasks/InfracostSetup/tests/pass-with-inputs.ts as an example. - Write a test
spec
in thetests/_suite.ts
file which should include the test file you created from step 1. - Write any assertions on the output and state of the task
- Run
npm run test
Unfortunately Azure Pipeline doesn't have the concept of local runners. Meaning you won't be able to test any task changes locally on your machine. Instead, ensure your changes are covered by unit tests, then open a PR with your changes. One of the Infracost team will help you test your changes in a live Azure environment before merging into master.
One of the Infracost team members should follow these steps to release this repo. We only create tags, not GitHub releases, as part of the release process as the GH releases aren't needed yet.
- Bump the version in vss-extension.json (following semantic versioning).
- Update the task versions in InfacostSetup to the same version as in step 1.
- Create a PR with these changes and merge them in after approval.
git checkout master && git pull origin master
.git tag vX.Y.Z && git push origin vX.Y.Z
using the same version as in step 1.git push origin vX.Y.Z
.- ensure the
Infracost.InfracostAzureDevops.PublishExtension
has run and is green. - Check the marketplace has the updated extension version.