Skip to content

Commit dee0ab7

Browse files
feat: added CI pipeline and tests (#3)
1 parent ed369b3 commit dee0ab7

File tree

6 files changed

+168
-5
lines changed

6 files changed

+168
-5
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
# TODO: Add CI workflow
1+
name: CI-Pipeline
2+
3+
# Controls when the workflow will run, when comment is created
4+
on:
5+
issue_comment:
6+
types:
7+
- created
8+
jobs:
9+
call-terraform-ci-pipeline:
10+
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/common-terraform-module-ci-v2.yml@v1.17.9
11+
secrets: inherit

.github/workflows/release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Release-Pipeline
2+
3+
# Trigger on push(merge) to main branch
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
call-terraform-release-pipeline:
11+
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/common-release.yml@v1.17.9
12+
secrets: inherit

stack_definition.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
{
2-
"inputs": [],
2+
"inputs": [
3+
{
4+
"name": "ibmcloud_api_key",
5+
"required": true,
6+
"type": "password",
7+
"hidden": false
8+
},
9+
{
10+
"name": "resource_group_name",
11+
"required": false,
12+
"type": "string",
13+
"hidden": false
14+
}
15+
],
316
"members": [
417
{
518
"inputs": [
619
{
720
"name": "resource_group",
8-
"value": "__NULL__"
21+
"value": "ref:../../inputs/resource_group_name"
922
},
1023
{
1124
"name": "resource_tags",
@@ -17,7 +30,11 @@
1730
},
1831
{
1932
"name": "prefix",
20-
"value": "mock"
33+
"value": "primary"
34+
},
35+
{
36+
"name": "ibmcloud_api_key",
37+
"value": "ref:../../inputs/ibmcloud_api_key"
2138
}
2239
],
2340
"name": "primary-da",
@@ -27,7 +44,7 @@
2744
"inputs": [
2845
{
2946
"name": "resource_group",
30-
"value": "ref:/configs/primary-da/outputs/resource_group"
47+
"value": "ref:../../inputs/resource_group_name"
3148
},
3249
{
3350
"name": "resource_tags",
@@ -40,6 +57,10 @@
4057
{
4158
"name": "prefix",
4259
"value": "secondary"
60+
},
61+
{
62+
"name": "ibmcloud_api_key",
63+
"value": "ref:../../inputs/ibmcloud_api_key"
4364
}
4465
],
4566
"name": "secondary-da",

tests/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Tests
2+
3+
For information about how to create and run tests, see [Validation tests](https://terraform-ibm-modules.github.io/documentation/#/tests) in the project documentation.
4+
5+
<!-- Add any more steps that are specific to testing this module and that are not in the docs. -->

tests/go.mod

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
module github.com/terraform-ibm-modules/stack-ibm-template
2+
3+
go 1.21
4+
5+
toolchain go1.21.3
6+
7+
require (
8+
github.com/stretchr/testify v1.9.0
9+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.31.1
10+
)
11+
12+
require (
13+
github.com/IBM-Cloud/bluemix-go v0.0.0-20240402122236-5c5b994a3f1a // indirect
14+
github.com/IBM-Cloud/power-go-client v1.6.0 // indirect
15+
github.com/IBM/cloud-databases-go-sdk v0.6.0 // indirect
16+
github.com/IBM/go-sdk-core/v5 v5.17.0 // indirect
17+
github.com/IBM/platform-services-go-sdk v0.62.6 // indirect
18+
github.com/IBM/project-go-sdk v0.2.9 // indirect
19+
github.com/IBM/vpc-go-sdk v0.50.0 // indirect
20+
github.com/Microsoft/go-winio v0.6.1 // indirect
21+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
22+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
23+
github.com/davecgh/go-spew v1.1.1 // indirect
24+
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
25+
github.com/ghodss/yaml v1.0.0 // indirect
26+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
27+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
28+
github.com/go-git/go-git/v5 v5.12.0 // indirect
29+
github.com/go-logr/logr v1.3.0 // indirect
30+
github.com/go-logr/stdr v1.2.2 // indirect
31+
github.com/go-openapi/analysis v0.21.5 // indirect
32+
github.com/go-openapi/errors v0.22.0 // indirect
33+
github.com/go-openapi/jsonpointer v0.20.1 // indirect
34+
github.com/go-openapi/jsonreference v0.20.3 // indirect
35+
github.com/go-openapi/loads v0.21.3 // indirect
36+
github.com/go-openapi/runtime v0.26.0 // indirect
37+
github.com/go-openapi/spec v0.20.12 // indirect
38+
github.com/go-openapi/strfmt v0.23.0 // indirect
39+
github.com/go-openapi/swag v0.22.5 // indirect
40+
github.com/go-openapi/validate v0.22.4 // indirect
41+
github.com/go-playground/locales v0.14.1 // indirect
42+
github.com/go-playground/universal-translator v0.18.1 // indirect
43+
github.com/go-playground/validator/v10 v10.19.0 // indirect
44+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
45+
github.com/google/go-cmp v0.6.0 // indirect
46+
github.com/google/uuid v1.6.0 // indirect
47+
github.com/gruntwork-io/terratest v0.46.13 // indirect
48+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
49+
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
50+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
51+
github.com/jinzhu/copier v0.4.0 // indirect
52+
github.com/josharian/intern v1.0.0 // indirect
53+
github.com/kevinburke/ssh_config v1.2.0 // indirect
54+
github.com/leodido/go-urn v1.4.0 // indirect
55+
github.com/mailru/easyjson v0.7.7 // indirect
56+
github.com/mitchellh/mapstructure v1.5.0 // indirect
57+
github.com/oklog/ulid v1.3.1 // indirect
58+
github.com/opentracing/opentracing-go v1.2.0 // indirect
59+
github.com/pjbgf/sha1cd v0.3.0 // indirect
60+
github.com/pmezard/go-difflib v1.0.0 // indirect
61+
github.com/skeema/knownhosts v1.2.2 // indirect
62+
github.com/xanzy/ssh-agent v0.3.3 // indirect
63+
go.mongodb.org/mongo-driver v1.14.0 // indirect
64+
go.opentelemetry.io/otel v1.16.0 // indirect
65+
go.opentelemetry.io/otel/metric v1.16.0 // indirect
66+
go.opentelemetry.io/otel/trace v1.16.0 // indirect
67+
golang.org/x/crypto v0.22.0 // indirect
68+
golang.org/x/mod v0.14.0 // indirect
69+
golang.org/x/net v0.23.0 // indirect
70+
golang.org/x/sys v0.19.0 // indirect
71+
golang.org/x/text v0.14.0 // indirect
72+
golang.org/x/tools v0.16.1 // indirect
73+
gopkg.in/warnings.v0 v0.1.2 // indirect
74+
gopkg.in/yaml.v2 v2.4.0 // indirect
75+
gopkg.in/yaml.v3 v3.0.1 // indirect
76+
)

tests/pr_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package tests
2+
3+
import (
4+
"fmt"
5+
"github.com/stretchr/testify/assert"
6+
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testprojects"
7+
"os"
8+
"testing"
9+
)
10+
11+
func TestProjectsFullTest(t *testing.T) {
12+
13+
options := testprojects.TestProjectOptionsDefault(&testprojects.TestProjectsOptions{
14+
Testing: t,
15+
StackConfigurationOrder: []string{
16+
"primary-da",
17+
"secondary-da",
18+
},
19+
})
20+
options.StackMemberInputs = map[string]map[string]interface{}{
21+
"primary-da": {
22+
"prefix": fmt.Sprintf("p%s", options.Prefix),
23+
},
24+
"secondary-da": {
25+
"prefix": fmt.Sprintf("s%s", options.Prefix),
26+
},
27+
}
28+
options.StackInputs = map[string]interface{}{
29+
"resource_group_name": options.ResourceGroup,
30+
"ibmcloud_api_key": os.Getenv("TF_VAR_ibmcloud_api_key"),
31+
}
32+
33+
err := options.RunProjectsTest()
34+
if assert.NoError(t, err) {
35+
t.Log("TestProjectsFullTest Passed")
36+
} else {
37+
t.Error("TestProjectsFullTest Failed")
38+
}
39+
}

0 commit comments

Comments
 (0)