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. - Follow updating the golden files to update the test output, review the new additions/changes to ensure they are what you expect 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.
Examples are tested by extracting them from the README.md files into a GitHub Actions workflow.
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
name: My Example
on: [pull_request]
jobs:
my_example:
...
```
[//]: <> (END EXAMPLE)
The examples are then modified in two ways:
- Use local paths for any Infracost actions, e.g. replace
uses: infracost/actions/setup@v3
with./setup
. - Replace any
infracost/actions/comment
steps 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 examples_test
GitHub Actions workflow as separate jobs.
The script that handles extracting and modifying the examples is ./scripts/generateExamplesTest.js
You can test the examples locally with act. To install on Mac OS X:
brew install act
Install packages:
npm install
Setup required environment variables
cp .env.example .env
# Edit .env to add any required environment variables.
Then run (with act
, select the Medium size image):
npm run examples:test
You can update the golden files for the examples by running:
export GITHUB_TOKEN=<GITHUB_PERSONAL_ACCESS_TOKEN>
npm run examples:update_golden
One of the Infracost team members should follow these steps to release this repo:
git checkout master && git pull origin master
git tag vX.Y.Z && git push origin vX.Y.Z
(following semantic versioning)git tag -f v2 && git push origin v2 -f
(assuming the new release is backward compatible with v1)- Confirm that the repo tags show matching git SHAs for vX.Y.X and v2.
- Create a release for v.X.Y.Z and publish it in the GitHub Marketplace.