-
Notifications
You must be signed in to change notification settings - Fork 7
148 lines (130 loc) · 6.76 KB
/
run-e2e-tests.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
name: Run E2E Tests
on:
pull_request:
branches:
- master
- 'release-**.x'
jobs:
create_ephemeral_spinnaker_and_run_tests:
name: create-destroy ephemeral spinnaker and run tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Check If Stack File Changed
id: check_stack
env:
BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
run: |
diff=$(git diff origin/$BRANCH_NAME HEAD stack.yml)
if [ -z "$diff" ]; then
echo "##[set-output name=changed;]false"
else
echo "##[set-output name=changed;]true"
fi
- name: Cancel checks out-of-date
if: steps.check_stack.outputs.changed == 'true'
uses: fkirc/skip-duplicate-actions@v4
with:
cancel_others: 'true'
- name: Wait For Other Tests To Finish
if: steps.check_stack.outputs.changed == 'true'
uses: softprops/turnstyle@v1
with:
same-branch-only: false
env:
GITHUB_TOKEN: ${{ secrets.ASTROLABE_GITHUB_TOKEN }}
- name: Give Github time to merge new changes if exist
if: steps.check_stack.outputs.changed == 'true'
run: sleep 10s
shell: bash
- name: Get ArtifactId From Stack Services
if: steps.check_stack.outputs.changed == 'true'
id: services
run: |
services=( $(yq e '.services | to_entries | .[] | .key + "," + .value.image.repository + ":" + .value.image.tag' stack.yml ) )
for service in "${services[@]}"; do
repoTag=(${service//,/ })
echo "##[set-output name=${repoTag[0]};]${repoTag[1]}"
done
- name: Trigger Ephemeral Spinnaker And Tests
if: steps.check_stack.outputs.changed == 'true'
uses: armory-io/spin-trigger-pipeline-action@master
id: trigger_tests
with:
baseUrl: https://spinnaker-api.internal.armory.io:8443/api/v1
source: create-ephemeral-spinnaker
parameters: 'namespace:${{ github.event.pull_request.head.sha }},sha:${{ github.event.pull_request.head.sha }},branch_name:${{ github.event.pull_request.base.ref }},clouddriver_image:${{ steps.services.outputs.clouddriver-armory }},deck_image:${{ steps.services.outputs.deck-armory }},dinghy_image:${{ steps.services.outputs.dinghy }},echo_image:${{ steps.services.outputs.echo-armory }},fiat_image:${{ steps.services.outputs.fiat-armory }},front50_image:${{ steps.services.outputs.front50-armory }},gate_image:${{ steps.services.outputs.gate-armory }},igor_image:${{ steps.services.outputs.igor-armory }},kayenta_image:${{ steps.services.outputs.kayenta-armory }},orca_image:${{ steps.services.outputs.orca-armory }},rosco_image:${{ steps.services.outputs.rosco-armory }},terraformer_image:${{ steps.services.outputs.terraformer }},pr_url:${{ github.event.pull_request.html_url }}'
crtFile: ${{ secrets.STAGING_CLIENT_CERTIFICATE }}
keyFile: ${{ secrets.STAGING_CLIENT_PRIVATE_KEY }}
- name: Watch Pipeline Execution For E2E Tests
if: steps.check_stack.outputs.changed == 'true'
uses: armory-io/spin-wait-status-action@master
with:
baseUrl: https://spinnaker-api.internal.armory.io:8443/api/v1
application: dynamo-armory-enterprise-testing
eventId: ${{ steps.trigger_tests.outputs.eventId }}
crtFile: ${{ secrets.STAGING_CLIENT_CERTIFICATE }}
keyFile: ${{ secrets.STAGING_CLIENT_PRIVATE_KEY }}
timeout: 3600000
- name: Enable automerge in PR
if: ${{ steps.check_stack.outputs.changed == 'true' && success() }}
uses: alexwilson/enable-github-automerge-action@main
with:
github-token: "${{ secrets.ASTROLABE_GITHUB_TOKEN }}"
- name: Destroy Ephemeral Spinnaker
if: ${{ steps.check_stack.outputs.changed == 'true' && !cancelled() }}
uses: armory-io/spin-trigger-pipeline-action@master
with:
baseUrl: https://spinnaker-api.internal.armory.io:8443/api/v1
source: destroy-ephemeral-spinnaker
parameters: 'namespace:${{ github.event.pull_request.head.sha }},branch_name:${{ github.event.pull_request.base.ref }}'
crtFile: ${{ secrets.STAGING_CLIENT_CERTIFICATE }}
keyFile: ${{ secrets.STAGING_CLIENT_PRIVATE_KEY }}
- name: build json with labels
if: ${{ steps.check_stack.outputs.changed == 'true' && failure() }}
uses: jsdaniell/create-json@v1.2.1
with:
name: "pr-info.json"
json: ${{ toJson(github.event.pull_request) }}
- name: Extract serviceName from pr-info.json
if: ${{ steps.check_stack.outputs.changed == 'true' && failure() }}
uses: sergeysova/jq-action@v2
id: serviceKey
with:
cmd: jq -r '[.labels[].name | select(. != "autoMerge") | select(. != "stackUpdate")][0]' pr-info.json
- name: Extract serviceType
if: ${{ steps.check_stack.outputs.changed == 'true' && failure() }}
uses: mikefarah/yq@master
id: serviceType
with:
cmd: yq '.services.["${{ steps.serviceKey.outputs.value }}"].vcs.repo.type' stack.yml
- name: Extract serviceOrg
if: ${{ steps.check_stack.outputs.changed == 'true' && failure() }}
uses: mikefarah/yq@master
id: serviceOrg
with:
cmd: yq '.services.["${{ steps.serviceKey.outputs.value }}"].vcs.repo.orgName' stack.yml
- name: Extract serviceRepo
if: ${{ steps.check_stack.outputs.changed == 'true' && failure() }}
uses: mikefarah/yq@master
id: serviceRepo
with:
cmd: yq '.services.["${{ steps.serviceKey.outputs.value }}"].vcs.repo.repoName' stack.yml
- name: Extract serviceSha
if: ${{ steps.check_stack.outputs.changed == 'true' && failure() }}
uses: mikefarah/yq@master
id: serviceSha
with:
cmd: yq '.services.["${{ steps.serviceKey.outputs.value }}"].vcs.sha' stack.yml
- name: Send Slack Notification
if: ${{ steps.check_stack.outputs.changed == 'true' && failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: eng-release-process-alerts
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: 'Error found in the e2e tests suit for PR: ${{ github.event.pull_request.html_url }} Bathymetric: https://bathymetric.dynamo-prod.eng.armory.io/?branchName=${{ github.event.pull_request.base.ref }}&selectedStackPipelineId=${{ steps.serviceType.outputs.result }}:${{ steps.serviceOrg.outputs.result }}:${{ steps.serviceRepo.outputs.result }}:${{ steps.serviceSha.outputs.result }}'
SLACK_TITLE: E2E Test Alert
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}