PaloAltoNetworks / terraform-modules-swfw-ci-workflows

Reusable workflows for Terraform Modules code repositories.
MIT License
4 stars 1 forks source link

feat!: generic Makefile/Terratest and chatops introduction #51

Closed FoSix closed 1 year ago

FoSix commented 1 year ago

Description

Introducing single, repository-wide Makefile based sub-workflows and ChatOPS reusable workflows.

Motivation and Context

BREAKING CHANGE.

The reusable workflows shift to use a single sub-workflow that runs Terratest-based action. This sub-workflow can be used to trigger any Terratest test function by providing the test name via the terratest_action parameter. This is combined with the code repo based action running a unified Makefile.

Example Makefile code ```Makefile .phony: all invalidate help all: @echo "Run [make help] for usage details." invalidate: help: @echo "This Makefile is run by specifying a module path as a target name." ; \ echo "It takes one argument: ACTION. Value of this argument is specific to a particular module." ; \ echo "It represents the name of a Terratest test function." ; \ echo "Typically this will be: Validate, Plan, Apply, Idempotence, but it should be verified with" ; \ echo " module's main_test.go file." ; \ echo ; \ echo "Example:" ; \ echo " make examples/common_vmseries ACTION=Plan" ; \ echo %: invalidate %/main.tf @cd $@ && \ echo "::group::DOWNLOADING GO DEPENDENCIES" && \ go get -v -t -d && \ go mod tidy && \ echo "::endgroup::" && \ echo "::group::ACTION >>$(ACTION)<<" && \ go test -run $(ACTION) -timeout 60m -count=1 && \ echo "::endgroup::" ```

Additionally this PR introduced reusable workflow that can be used with the ChatOPS workflows in the target repository. It's logic is based on the unified, Terratest based sub-workflows described above.

How Has This Been Tested?

Tested on Azure repo, 263-terratest-for-azure PR. And on the Azure test (internal) repository.

Screenshots (if appropriate)

Types of changes

Checklist