-
Notifications
You must be signed in to change notification settings - Fork 8
206 lines (206 loc) · 10.6 KB
/
integration-test.yaml
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Copyright (c) IBM Corporation.
# Copyright (c) Microsoft Corporation.
name: integration-test
on:
workflow_dispatch:
inputs:
enableAppGWIngress:
description: 'Application Gateway Ingress Controller'
required: true
type: boolean
default: true
deployWLO:
description: 'WebSphere Liberty Operator'
required: true
type: boolean
default: false
deployApplication:
description: 'Sample application'
required: true
type: boolean
default: true
deleteAzureResources:
description: 'Delete Azure resources at the end'
required: true
type: boolean
default: true
# Allows you to run this workflow using GitHub workflow dispatch APIs
# PERSONAL_ACCESS_TOKEN=<GITHUB_PERSONAL_ACCESS_TOKEN>
# REPO_NAME=WASdev/azure.liberty.aks
# Enable/disable AGIC, WebSphere Liberty Operator and sample application. Keep/delete Azure resources at the end.
# curl --verbose -XPOST -u "WASdev:${PERSONAL_ACCESS_TOKEN}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/${REPO_NAME}/actions/workflows/integration-test.yaml/dispatches --data '{"ref": "main", "inputs":{"enableAppGWIngress": "true|false", "deployWLO": "true|false", "deployApplication": "true|false", "deleteAzureResources": "true|false"}}'
repository_dispatch:
types: [integration-test]
# Allows you to run this workflow using GitHub repository dispatch APIs
# PERSONAL_ACCESS_TOKEN=<GITHUB_PERSONAL_ACCESS_TOKEN>
# REPO_NAME=WASdev/azure.liberty.aks
# Enable/disable AGIC, WebSphere Liberty Operator and sample application. Keep/delete Azure resources at the end.
# curl --verbose -X POST https://api.github.com/repos/${REPO_NAME}/dispatches -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" --data '{"event_type": "integration-test", "client_payload": {"enableAppGWIngress": true|false, "deployWLO": true|false, "deployApplication": true|false, "deleteAzureResources": true|false}}'
env:
repoName: "azure.liberty.aks"
azureCredentials: ${{ secrets.AZURE_CREDENTIALS }}
userName: ${{ secrets.USER_NAME }}
msTeamsWebhook: ${{ secrets.MSTEAMS_WEBHOOK }}
testResourceGroup: libertyAksTestRG${{ github.run_id }}${{ github.run_number }}
testDeploymentName: libertyAksTestDeployment${{ github.run_id }}${{ github.run_number }}
location: eastus
jobs:
integration-test:
runs-on: ubuntu-latest
steps:
- name: Get versions of external dependencies
run: |
curl -Lo external-deps-versions.properties https://raw.githubusercontent.com/Azure/azure-javaee-iaas/main/external-deps-versions.properties
source external-deps-versions.properties
echo "azCliVersion=${AZ_CLI_VERSION}" >> $GITHUB_ENV
echo "bicepVersion=${BICEP_VERSION}" >> $GITHUB_ENV
echo "refArmttk=${ARM_TTK_REFERENCE}" >> $GITHUB_ENV
echo "refJavaee=${AZURE_JAVAEE_IAAS_REFERENCE}" >> $GITHUB_ENV
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up bicep
run: |
curl -Lo bicep https://github.com/Azure/bicep/releases/download/${{ env.bicepVersion }}/bicep-linux-x64
chmod +x ./bicep
sudo mv ./bicep /usr/local/bin/bicep
bicep --version
- name: Checkout azure-javaee-iaas
uses: actions/checkout@v2
with:
repository: Azure/azure-javaee-iaas
path: azure-javaee-iaas
ref: ${{ env.refJavaee }}
- name: Checkout arm-ttk
uses: actions/checkout@v2
with:
repository: Azure/arm-ttk
path: arm-ttk
ref: ${{ env.refArmttk }}
- name: Checkout ${{ env.repoName }}
uses: actions/checkout@v2
with:
path: ${{ env.repoName }}
ref: ${{ github.event.inputs.ref }}
- name: Build azure-javaee-iaas
run: mvn -DskipTests clean install --file azure-javaee-iaas/pom.xml
- name: Build ${{ env.repoName }}
run: |
enableAppGWIngress=false
if ${{ inputs.enableAppGWIngress == true || github.event.client_payload.enableAppGWIngress == true }}; then
enableAppGWIngress=true
fi
echo "enableAppGWIngress=${enableAppGWIngress}" >> $GITHUB_ENV
deployWLO=false
if ${{ inputs.deployWLO == true || github.event.client_payload.deployWLO == true }}; then
deployWLO=true
fi
deployApplication=false
if ${{ inputs.deployApplication == true || github.event.client_payload.deployApplication == true }}; then
deployApplication=true
fi
echo "deployApplication=${deployApplication}" >> $GITHUB_ENV
cd ${{ env.repoName }}
mvn -Dgit.repo=${{ env.userName }} -Dgit.tag=$GITHUB_REF_NAME -DcreateCluster=true -DcreateACR=true \
-DenableAppGWIngress=${enableAppGWIngress} -DappgwUsePrivateIP=false -DappGatewayCertificateOption=generateCert -DenableCookieBasedAffinity=true \
-DdeployWLO=${deployWLO} -Dedition="IBM WebSphere Application Server" -DproductEntitlementSource="Standalone" \
-DdeployApplication=${deployApplication} -DappImagePath=icr.io/appcafe/open-liberty/samples/getting-started -DappReplicas=2 \
-Dtest.args="-Test All" -Pbicep -Passembly -Ptemplate-validation-tests clean install
- uses: azure/login@v1
id: azure-login
with:
creds: ${{ env.azureCredentials }}
- name: Start the deployment
run: |
cd ${{ env.repoName }}/target/cli
chmod a+x deploy.azcli
./deploy.azcli -n ${{ env.testDeploymentName }} -g ${{ env.testResourceGroup }} -l ${{ env.location }}
- name: Verify the deployment
run: |
outputs=$(az deployment group show -n ${{ env.testDeploymentName }} -g ${{ env.testResourceGroup }} --query 'properties.outputs')
appHttpEndpoint=$(echo $outputs | jq -r '.appHttpEndpoint.value')
echo "appHttpEndpoint: ${appHttpEndpoint}"
appHttpsEndpoint=$(echo $outputs | jq -r '.appHttpsEndpoint.value')
echo "appHttpsEndpoint: ${appHttpsEndpoint}"
if [[ $deployApplication == "true" ]]; then
if [[ -z "$appHttpEndpoint" ]]; then
echo "Invalid value of appHttpEndpoint: ${appHttpEndpoint}"
exit 1
fi
curl --verbose --connect-timeout 60 --max-time 180 --retry 10 --retry-delay 30 --retry-max-time 180 --retry-connrefused $appHttpEndpoint
if [[ $? -ne 0 ]]; then
echo "Failed to access ${appHttpEndpoint}."
exit 1
fi
elif [[ -n "$appHttpEndpoint" ]]; then
echo "Invalid value of appHttpEndpoint: ${appHttpEndpoint}"
exit 1
fi
if [[ $deployApplication == "true" && $enableAppGWIngress == "true" ]]; then
if [[ -z "$appHttpsEndpoint" ]]; then
echo "Invalid value of appHttpsEndpoint: ${appHttpsEndpoint}"
exit 1
fi
curl --verbose --connect-timeout 60 --max-time 180 --retry 10 --retry-delay 30 --retry-max-time 180 --retry-connrefused $appHttpsEndpoint -k
if [[ $? -ne 0 ]]; then
echo "Failed to access ${appHttpsEndpoint}."
exit 1
fi
elif [[ -n "$appHttpsEndpoint" ]]; then
echo "Invalid value of appHttpsEndpoint: ${appHttpsEndpoint}"
exit 1
fi
- name: Delete all Azure resources
id: delete-resources-in-group
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.deleteAzureResources) || (github.event_name == 'repository_dispatch' && github.event.client_payload.deleteAzureResources) }}
uses: azure/CLI@v1
with:
azcliversion: ${{ env.azCliVersion }}
inlineScript: |
az group delete -n ${{ env.testResourceGroup }} --yes --no-wait
- name: Generate artifact file name and path
id: artifact_file
run: |
version=$(awk '/<version>[^<]+<\/version>/{gsub(/<version>|<\/version>/,"",$1);print $1;exit;}' ${{ env.repoName }}/pom.xml)
artifactName=${{ env.repoName }}-$version-arm-assembly
unzip ${{ env.repoName }}/target/$artifactName.zip -d ${{ env.repoName }}/target/$artifactName
echo "##[set-output name=artifactName;]${artifactName}"
echo "##[set-output name=artifactPath;]${{ env.repoName }}/target/$artifactName"
- name: Archive ${{ env.repoName }} template
uses: actions/upload-artifact@v1
if: success()
with:
name: ${{steps.artifact_file.outputs.artifactName}}
path: ${{steps.artifact_file.outputs.artifactPath}}
notification:
needs: integration-test
if: always()
runs-on: ubuntu-latest
steps:
- name: Output inputs from workflow_dispatch
run: echo "${{ toJSON(github.event.inputs) }}"
- name: Output client_payload from repository_dispatch
run: echo "${{ toJSON(github.event.client_payload) }}"
- name: Send notification
if: ${{ env.msTeamsWebhook != 'NA' }}
run: |
workflowJobs=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ env.userName }}/${{ env.repoName }}/actions/runs/${{ github.run_id }}/jobs)
successIntegrationTestJob=$(echo $workflowJobs | jq 'select(.jobs != null) | .jobs | map(select(.name=="integration-test" and .conclusion=="success")) | length')
echo "$successIntegrationTestJob"
if [ -z $successIntegrationTestJob ];then
echo "jobs not retrieved."
elif (($successIntegrationTestJob == 0));then
echo "Job integration-test failed, send notification to Teams"
curl ${{ env.msTeamsWebhook }} \
-H 'Content-Type: application/json' \
--data-binary @- << EOF
{
"@context":"http://schema.org/extensions",
"@type":"MessageCard",
"text":"Workflow integration-test of repo ${{ env.repoName }} failed, please take a look at: https://github.com/${{ env.userName }}/${{ env.repoName }}/actions/runs/${{ github.run_id }}"
}
EOF
else
echo "Job integration-test succeeded."
fi