generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (168 loc) · 6.6 KB
/
05_integration_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
177
178
179
180
181
182
183
name: Integration Tests
on:
schedule:
- cron: '00 08 * * *'
workflow_dispatch:
inputs:
environment:
required: true
type: choice
description: Select the Environment
options:
- dev
- uat
default: uat
tags:
description: 'run the tests tagged with'
required: false
type: string
default: 'runnable'
junit:
description: 'enable junit'
required: false
type: choice
options:
- true
- false
default: false
notify:
required: false
type: boolean
description: 'send the slack notification'
default: false
permissions:
id-token: write
contents: read
deployments: write
jobs:
integration_test:
name: Test ${{(github.event.inputs == null && 'dev') || inputs.environment }}
runs-on: ubuntu-latest
environment: ${{(github.event.inputs == null && 'dev') || inputs.environment }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@1f9a0c22da41e6ebfa534300ef656657ea2c6707
- name: Create reports folder
shell: bash
run: |
mkdir -p ./integration-test/reports
mkdir -p ./integration-test/junit
- name: Login
id: login
# from https://github.com/Azure/login/commits/master
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
with:
client-id: ${{ secrets.CI_CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
subscription-id: ${{ secrets.SUBSCRIPTION_ID }}
- name: Delete old reports
uses: azure/CLI@v1
env:
STORAGE_NAME: ${{ vars.INTEGRATION_TEST_STORAGE_ACCOUNT_NAME }}
STORAGE_FOLDER: ${{ vars.INTEGRATION_TEST_REPORTS_FOLDER }}
with:
inlineScript: |
az storage blob delete-batch \
--source "${{ env.STORAGE_FOLDER }}" \
--account-name "${{ env.STORAGE_NAME }}" \
--subscription "${{ secrets.SUBSCRIPTION_ID }}" \
--auth-mode login
- name: Run Integration Tests
shell: bash
run: |
cd ./integration-test
docker build -t wispdismantling_test .
docker run \
-e INTEGRATION_TEST_GPD_SUBSCRIPTION_KEY="${{ secrets.INTEGRATION_TEST_GPD_SUBSCRIPTION_KEY }}" \
-e INTEGRATION_TEST_NODO_SUBSCRIPTION_KEY="${{ secrets.INTEGRATION_TEST_NODO_SUBSCRIPTION_KEY }}" \
-e INTEGRATION_TEST_FORWARDER_SUBSCRIPTION_KEY="${{ secrets.INTEGRATION_TEST_FORWARDER_SUBSCRIPTION_KEY }}" \
-e INTEGRATION_TEST_TECHNICALSUPPORT_SUBSCRIPTION_KEY="${{ secrets.INTEGRATION_TEST_TECHNICALSUPPORT_SUBSCRIPTION_KEY }}" \
-e INTEGRATION_TEST_CHANNEL_WISP_PASSWORD="${{ secrets.INTEGRATION_TEST_CHANNEL_WISP_PASSWORD }}" \
-e INTEGRATION_TEST_CHANNEL_WFESP_PASSWORD="${{ secrets.INTEGRATION_TEST_CHANNEL_WFESP_PASSWORD }}" \
-e INTEGRATION_TEST_CHANNEL_CHECKOUT_PASSWORD="${{ secrets.INTEGRATION_TEST_CHANNEL_CHECKOUT_PASSWORD }}" \
-e INTEGRATION_TEST_CHANNEL_PAYMENT_PASSWORD="${{ secrets.INTEGRATION_TEST_CHANNEL_PAYMENT_PASSWORD }}" \
-e INTEGRATION_TEST_STATION_WISP_PASSWORD="${{ secrets.INTEGRATION_TEST_STATION_WISP_PASSWORD }}" \
-e TAGS="${{ inputs.tags }}" \
-e ENV="${{( github.event.inputs == null && 'dev') || inputs.environment }}" \
-v ./reports:/app/reports wispdismantling_test
- name: Upload reports
uses: azure/CLI@v1
env:
STORAGE_NAME: ${{ vars.INTEGRATION_TEST_STORAGE_ACCOUNT_NAME }}
STORAGE_FOLDER: ${{ vars.INTEGRATION_TEST_REPORTS_FOLDER }}
with:
inlineScript: |
az storage blob upload-batch \
--destination '${{ env.STORAGE_FOLDER }}/reports' \
--source ./integration-test/reports \
--account-name ${{ env.STORAGE_NAME }} \
--subscription ${{ secrets.SUBSCRIPTION_ID }} \
--overwrite true \
--auth-mode login
- name: Upload junit
if: ${{ inputs.junit == true }}
uses: azure/CLI@v1
env:
STORAGE_NAME: ${{ vars.INTEGRATION_TEST_STORAGE_ACCOUNT_NAME }}
STORAGE_FOLDER: ${{ vars.INTEGRATION_TEST_REPORTS_FOLDER }}
with:
inlineScript: |
az storage blob upload-batch \
--destination '${{ env.STORAGE_FOLDER }}/junit' \
--source ./integration-test/junit \
--account-name ${{ env.STORAGE_NAME }} \
--subscription ${{ secrets.SUBSCRIPTION_ID }} \
--overwrite true \
--auth-mode login
notify:
needs: [ integration_test ]
runs-on: ubuntu-latest
name: Notify
if: ${{ always() && inputs.notify == 'true' }}
steps:
- name: Report Status
if: ${{ inputs.notify }}
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ needs.integration_test.result }}
token: ${{ secrets.GITHUB_TOKEN }}
notify_when: 'failure,skipped'
notification_title: '<{run_url}|Scheduled Integration Test> has {status_message}'
message_format: '{emoji} <{run_url}|{workflow}> {status_message} in <{repo_url}|{repo}>'
footer: 'Linked to <{workflow_url}| workflow file>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# delete_github_deployments:
# runs-on: ubuntu-latest
# needs: integration_test
# if: ${{ always() }}
# steps:
# - name: Delete Previous deployments
# uses: actions/github-script@v6
# env:
# SHA_HEAD: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha}}
# with:
# script: |
# const { SHA_HEAD } = process.env
#
# const deployments = await github.rest.repos.listDeployments({
# owner: context.repo.owner,
# repo: context.repo.repo,
# sha: SHA_HEAD
# });
# await Promise.all(
# deployments.data.map(async (deployment) => {
# await github.rest.repos.createDeploymentStatus({
# owner: context.repo.owner,
# repo: context.repo.repo,
# deployment_id: deployment.id,
# state: 'inactive'
# });
# return github.rest.repos.deleteDeployment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# deployment_id: deployment.id
# });
# })
# );