Skip to content

Commit

Permalink
feat: added CI pipeline and tests (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-butler-irl authored Apr 23, 2024
1 parent ed369b3 commit dee0ab7
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 5 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# TODO: Add CI workflow
name: CI-Pipeline

# Controls when the workflow will run, when comment is created
on:
issue_comment:
types:
- created
jobs:
call-terraform-ci-pipeline:
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/[email protected]
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Release-Pipeline

# Trigger on push(merge) to main branch
on:
push:
branches:
- main

jobs:
call-terraform-release-pipeline:
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/[email protected]
secrets: inherit
29 changes: 25 additions & 4 deletions stack_definition.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
{
"inputs": [],
"inputs": [
{
"name": "ibmcloud_api_key",
"required": true,
"type": "password",
"hidden": false
},
{
"name": "resource_group_name",
"required": false,
"type": "string",
"hidden": false
}
],
"members": [
{
"inputs": [
{
"name": "resource_group",
"value": "__NULL__"
"value": "ref:../../inputs/resource_group_name"
},
{
"name": "resource_tags",
Expand All @@ -17,7 +30,11 @@
},
{
"name": "prefix",
"value": "mock"
"value": "primary"
},
{
"name": "ibmcloud_api_key",
"value": "ref:../../inputs/ibmcloud_api_key"
}
],
"name": "primary-da",
Expand All @@ -27,7 +44,7 @@
"inputs": [
{
"name": "resource_group",
"value": "ref:/configs/primary-da/outputs/resource_group"
"value": "ref:../../inputs/resource_group_name"
},
{
"name": "resource_tags",
Expand All @@ -40,6 +57,10 @@
{
"name": "prefix",
"value": "secondary"
},
{
"name": "ibmcloud_api_key",
"value": "ref:../../inputs/ibmcloud_api_key"
}
],
"name": "secondary-da",
Expand Down
5 changes: 5 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Tests

For information about how to create and run tests, see [Validation tests](https://terraform-ibm-modules.github.io/documentation/#/tests) in the project documentation.

<!-- Add any more steps that are specific to testing this module and that are not in the docs. -->
76 changes: 76 additions & 0 deletions tests/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module github.com/terraform-ibm-modules/stack-ibm-template

go 1.21

toolchain go1.21.3

require (
github.com/stretchr/testify v1.9.0
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.31.1
)

require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20240402122236-5c5b994a3f1a // indirect
github.com/IBM-Cloud/power-go-client v1.6.0 // indirect
github.com/IBM/cloud-databases-go-sdk v0.6.0 // indirect
github.com/IBM/go-sdk-core/v5 v5.17.0 // indirect
github.com/IBM/platform-services-go-sdk v0.62.6 // indirect
github.com/IBM/project-go-sdk v0.2.9 // indirect
github.com/IBM/vpc-go-sdk v0.50.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.12.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.21.5 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/jsonpointer v0.20.1 // indirect
github.com/go-openapi/jsonreference v0.20.3 // indirect
github.com/go-openapi/loads v0.21.3 // indirect
github.com/go-openapi/runtime v0.26.0 // indirect
github.com/go-openapi/spec v0.20.12 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.22.5 // indirect
github.com/go-openapi/validate v0.22.4 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gruntwork-io/terratest v0.46.13 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jinzhu/copier v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
39 changes: 39 additions & 0 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package tests

import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testprojects"
"os"
"testing"
)

func TestProjectsFullTest(t *testing.T) {

options := testprojects.TestProjectOptionsDefault(&testprojects.TestProjectsOptions{
Testing: t,
StackConfigurationOrder: []string{
"primary-da",
"secondary-da",
},
})
options.StackMemberInputs = map[string]map[string]interface{}{
"primary-da": {
"prefix": fmt.Sprintf("p%s", options.Prefix),
},
"secondary-da": {
"prefix": fmt.Sprintf("s%s", options.Prefix),
},
}
options.StackInputs = map[string]interface{}{
"resource_group_name": options.ResourceGroup,
"ibmcloud_api_key": os.Getenv("TF_VAR_ibmcloud_api_key"),
}

err := options.RunProjectsTest()
if assert.NoError(t, err) {
t.Log("TestProjectsFullTest Passed")
} else {
t.Error("TestProjectsFullTest Failed")
}
}

0 comments on commit dee0ab7

Please sign in to comment.