-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed
retention_policy
block from `azurerm_monitor_diagnostic_se…
…tting` & added `terraform` tests. (#16) * added `terraform` tests. * use env var authentication * added `init` step in validate * docs: updated readme * aded complete example for single test * added a new release and additional nodepool for complete example * address complete example issues * avoid hyphen in nodepool name * renaming rg and stg acc * rename test to complete * use single identity id * disabled retention policy by default in monitor diagnostics * fix the complete example * remove deprecated retention block from the monitor diagnostic settings * updated changelog * fix tests and added maintenance automation files * docs: updated docs * test pr comment * lets make the pR great * lets make pr great again * PR will be great someday * pr will be great someday * std out and std error as env var and recreate comment * pr is going to be great soon.... * PR is great (prettify pr comment) * fail test intentionally * check if the status of action is red or green * prettifyy ..... pr comment * prettify... pr comment * try github scripts for better formatting * better results workflow * trial fix script * better workflows trial :1 * better workflows :2 * better workflows : 3 * permissons for comenting * better workflows: 4 if readme workflow delete the comment * better workflow pass test * final workflows * better workflow 5 * switch to complete example * updated triggers * docs : updated readme and message
- Loading branch information
Showing
23 changed files
with
715 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: Module Testing | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- './*.tf' ## trigger if any terraform file has ben modified in repo root. | ||
- 'scripts/*.sh' ## trigger if any involved script has been modified. | ||
- 'tests/*.tftest.hcl' ## trigger if any test has been modified. | ||
- 'examples/complete/*.tf' ## trigger if complete example has been modified. | ||
- '.github/workflows/module-testing.yaml' ## trigger if this workflow has been modified. | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
concurrency: | ||
group: testing | ||
|
||
jobs: | ||
moduleTesting: | ||
runs-on: ubuntu-latest | ||
env: | ||
ARM_SUBSCRIPTION_ID: "${{ vars.ARM_SUBSCRIPTION_ID }}" | ||
ARM_CLIENT_ID: "${{ secrets.AZURE_CLIENT_ID }}" | ||
ARM_CLIENT_SECRET: "${{ secrets.AZURE_CLIENT_SECRET }}" | ||
ARM_TENANT_ID: "${{ secrets.AZURE_TENANT_ID}}" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: hashicorp/setup-terraform@v2 | ||
with: | ||
terraform_version: 1.6 | ||
terraform_wrapper: true | ||
|
||
## Static Analysis and Linting Test (Unit Testing) | ||
- name: Terraform validate on all examples | ||
run: | | ||
CURRENT_DIR="$(pwd)" | ||
for dir in ./examples/*; do | ||
if [[ -d "$dir" ]]; then | ||
echo "$dir" | ||
cd "$dir" || exit | ||
terraform init | ||
terraform validate | ||
cd "${CURRENT_DIR}" || exit | ||
fi | ||
done | ||
## Integrating testing using terraform native testing | ||
- name: Testing complete example | ||
working-directory: "${{ github.workspace }}/tests" | ||
id: testing | ||
run: | | ||
terraform init | ||
terraform test -no-color | ||
- uses: actions/github-script@v6 | ||
if: github.event_name == 'pull_request' && always() && !cancelled() | ||
env: | ||
TEST_OUTPUT: "${{ steps.testing.outputs.stdout }}" | ||
TEST_ERROR: "${{ steps.testing.outputs.stderr }}" | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
// 1. Retrieve existing bot comments for the PR | ||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
}) | ||
const botComment = comments.find(comment => { | ||
return comment.user.type === 'Bot' && comment.body.includes('Test Results') | ||
}) | ||
// 2. Set output data | ||
const output = `### Test Results :gear: Status: \`${{ steps.testing.outcome }}\` | ||
- \`Test Output:\` | ||
\`\`\`bash\n | ||
${process.env.TEST_OUTPUT} | ||
\`\`\` | ||
- \`Test Error Message:\` | ||
\`\`\`bash\n | ||
${process.env.TEST_ERROR} | ||
\`\`\` | ||
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`; | ||
// 3. If we have a comment, update it, otherwise create a new one | ||
if (botComment) { | ||
github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: botComment.id, | ||
body: output | ||
}) | ||
} else { | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: output | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Determine the Makefile's directory | ||
## * dir function -> https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html#index-dir | ||
## * abspath -> https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html#index-abspath-1 | ||
## * lastword -> http://gnu.ist.utl.pt/software/make/manual/html_node/Text-Functions.html#Text-Functions | ||
## * MAKEFILE_LIST -> https://ftp.gnu.org/old-gnu/Manuals/make-3.80/html_node/make_17.html | ||
MKFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
.Phony: init | ||
init: | ||
terraform init | ||
|
||
.Phony: initlock | ||
initlock: init | ||
terraform providers lock -platform=darwin_arm64 -platform=darwin_amd64 -platform=linux_amd64 -platform=linux_arm64 | ||
|
||
.Phony: fmt | ||
fmt: | ||
terraform fmt -recursive | ||
|
||
.Phony: format | ||
format: fmt | ||
|
||
.Phony: lock | ||
lock: initlock | ||
|
||
.Phony: clean | ||
clean: | ||
find . -type d -name ".terraform" -prune -exec rm -rf {} \; | ||
|
||
.Phony: clean-all | ||
clean-all: clean | ||
find . -name ".terraform.lock.hcl" -prune -exec rm -rf {} \; | ||
az logout | ||
az account clear |
Oops, something went wrong.