-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (105 loc) · 4.96 KB
/
module-test-pipeline.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
name: Provider Test Pipeline
on: push
jobs:
test:
name: Run Provider setup and tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Terraform latest - with token
uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_wrapper: true
- name: Setup test broker
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: Setup if private provider is required
run: |
export PRIVATE_PROVIDER_VERSION="1.0.0-rc.7"
if [ -n "$PRIVATE_PROVIDER_VERSION" ]; then
echo "Using private provider version $PRIVATE_PROVIDER_VERSION"
grep -rl 'source = "' . | xargs sed -i 's@source = ".*$@source = "app.terraform.io/SolaceDev/solacebroker"@g'
grep -rl 'version = "' . | xargs sed -i "s@ version = \".*\$@ version = \"${PRIVATE_PROVIDER_VERSION}\"@g"
fi
- name: Test module from template on test broker
run: |
ci/scripts/test-module.sh ci/template-test
- name: Test module root on test broker
run: |
ci/scripts/test-module.sh ci/module-test
- name: Test examples
run: |
shopt -s extglob
for d in examples/!(adding-headers)/; do (ci/scripts/test-module.sh "$d"); done
ci/scripts/test-module.sh examples/adding-headers/ -var-file=secret.tfvars
- name: Discard any changes in checked out code
run: |
git checkout -- .
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.22"
- 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 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"
rm ./*.tf
SEMP_V2_SWAGGER_CONFIG_EXTENDED_JSON="ci/swagger_spec/$SWAGGER_SPEC_NAME" MODULE_TEMPLATE_FOLDER="internal/gen-template" ~/go/bin/broker-terraform-code-generator software-module
- name: Add copyright headers where needed
run: |
go install github.com/google/addlicense@latest
addlicense -c 'Solace Corporation. All rights reserved.' -v -l apache ./*.tf
addlicense -c 'Solace Corporation. All rights reserved.' -v -l apache $(find ./examples -name "*.tf" -type f -print0 | xargs -0)
- name: Ensure version reflects release candidate version
run: |
# only if ${GITHUB_REF_NAME} starts with 'v' or 'dev' and followed by a semver
if [[ $GITHUB_REF_NAME =~ ^(v|dev)[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
VERSION=$(echo "${GITHUB_REF_NAME}" | cut -d'v' -f2)
echo $VERSION > VERSION
fi
- name: Check changed files
uses: tj-actions/verify-changed-files@v17
id: check-changed-files
with:
files: |
!broker-terraform-code-generator
- name: Run step only when any of the above files change.
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.check-changed-files.outputs.changed_files }}"
- name: Commit back any updated source code
if: steps.check-changed-files.outputs.files_changed == 'true'
uses: EndBug/add-and-commit@v9
with:
committer_name: GitHub Actions
committer_email: [email protected]
message: 'Updating generated source'
add: ". ':!broker-terraform-code-generator'"
new_branch: GeneratedSourceUpdates-${{ github.ref_name }}
- name: Create pull request
if: steps.check-changed-files.outputs.files_changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT_BRANCH=${GITHUB_REF_NAME}
gh pr create -B ${CURRENT_BRANCH} -H "GeneratedSourceUpdates-${CURRENT_BRANCH}" --title "Merge updates into ${CURRENT_BRANCH}" --body 'Created by Github action'
echo Review and approve PR before push can continue
exit 1 // force actions stop here