-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (155 loc) · 7.05 KB
/
broker-build-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Test Provider triggered by a broker build
# Branch naming convention assumes dev branches start with "dev" then semver release name,
# internal QA release candidate branches start with "v" then semver release name.
# broker builds are triggered by Jenkins from a broker release branch with an example pattern of 10.9.1
on:
push:
branches-ignore:
- dev*
- v*
- main
jobs:
build:
name: Build & test provider from broker build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Check out code
uses: actions/checkout@v4
- name: Checkout generator
uses: actions/checkout@v4
with:
repository: SolaceDev/broker-terraform-code-generator
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
path: broker-terraform-code-generator
ref: "main"
- name: Build and install generator
run: |
pushd broker-terraform-code-generator
go mod tidy
go install .
ls ~/go/bin
popd
- name: Generate provider code
run: |
SWAGGER_SPEC_NAME=`ls ci/swagger_spec`
echo "Generating code using spec $SWAGGER_SPEC_NAME"
BASE=`pwd`
pushd internal/broker/generated
rm ./*
SEMP_V2_SWAGGER_CONFIG_EXTENDED_JSON="$BASE/ci/swagger_spec/$SWAGGER_SPEC_NAME" ~/go/bin/broker-terraform-code-generator appliance-provider all
popd
- name: Check changed files
uses: tj-actions/verify-changed-files@v20
id: check-changed-files
with:
files: |
!broker-terraform-code-generator
!version.go
- name: Run step only when no change detected
if: steps.check-changed-files.outputs.files_changed == 'false'
run: |
echo "No changes detected, skipping further steps"
- name: List changed files - from now on all tests are run only if there were changes
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.check-changed-files.outputs.changed_files }}"
echo ******** Excluding MarkdownDescription:
git diff -I MarkdownDescription
echo ******** Including MarkdownDescription:
git diff
- name: Set up Terraform latest
if: steps.check-changed-files.outputs.files_changed == 'true'
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Setup Test broker
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
mkdir -p $HOME/solace; chmod 777 $HOME/solace
docker run -d -p 8080:8080 -p 55555:55555 --shm-size=1g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin --env system_scaling_maxkafkabridgecount="10" --name=solace \
--env system_scaling_maxconnectioncount="1000" --mount type=bind,source=$HOME/solace,destination=/var/lib/solace,ro=false solace/solace-pubsub-standard:latest
while ! curl -s localhost:8080 | grep aurelia ; do sleep 1 ; done
- name: Run acceptance test
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
make vet
make testacc
- name: Use local provider
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
echo "
provider_installation {
dev_overrides {
\"registry.terraform.io/solaceproducts/solacebrokerappliance\" = \"${HOME}/go/bin\"
}
direct {}
}" > ~/.terraformrc
- name: Build documentation
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
make generate-docs
- name: Build provider
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
make test-coverage
make install
ls ~/go/bin
terraform-provider-solacebrokerappliance -h
- name: Run provider test - create custom messageVPN with large config
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
pushd ci/broker_vpn_test
# Create
terraform plan
terraform apply -auto-approve
sleep 1
popd
- name: Run generate test - generate complete large config file for custom messageVPN file
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
SOLACEBROKER_REGISTRY_OVERRIDE=registry.terraform.io/solaceproducts/solacebroker SOLACEBROKER_USERNAME=admin SOLACEBROKER_PASSWORD=admin SOLACEBROKER_SKIP_API_CHECK=true terraform-provider-solacebrokerappliance generate --url=http://localhost:8080 solacebroker_msg_vpn.test test messageVpn.tf
cat messageVpn.tf
- name: Run provider test - delete large config
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
pushd ci/broker_vpn_test
terraform plan
terraform destroy -auto-approve
sleep 1
popd
- name: Test state upgrade
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
pushd ci/state_upgrade
bash -c "terraform plan &> results.out" || echo "Expecting terraform plan to fail"
cat results.out | grep "Found deprecated state key 'deprecated_att"
cp terraform.tfstate terraform.tfstate.bak
sed -i '/deprecated_att/d' terraform.tfstate # remove deprecated non-null attributes from state
terraform plan | grep "3 to add"
terraform apply -auto-approve | grep "Apply complete"
# GH actions fails on following commands, need to investigate. Passes locally.
# diff terraform.tfstate terraform.tfstate.bak > diff.out
# ls -l
# cat diff.out
# grep "> \"schema_version\": 0," diff.out | wc -l | grep 3 # verify schema has been upgraded
# grep "> \"deprecated1\": null," diff.out # verify deprecated has been removed
# grep "> \"deprecated2\": null," diff.out # verify deprecated has been removed
# grep "< \"clear_percent\": 20," diff.out # verify string has been converted to number
# grep "< \"egress_enabled\": true," diff.out # verify string has been converted to bool
# terraform destroy -auto-approve
popd
- name: Commit back the generated code
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add internal/broker/generated/
git add docs/
# Use the latest commit message and append a note
MESSAGE="$(git log -1 --pretty=%B) - added generated code and docs updates [skip ci]"
git commit -m "$MESSAGE"
git push