-
Notifications
You must be signed in to change notification settings - Fork 6
182 lines (165 loc) · 6.31 KB
/
user_acceptance_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
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
name: User Acceptance Tests
on: [pull_request, workflow_dispatch]
env:
TRON_FOLDER: demo-simulator
jobs:
user-acceptance-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cloud_provider: [aws, azure, gcp]
scenario: [happy]
steps:
- name: checkout repo
uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: 2.7
- name: pull v3 deployer image
run: docker pull ghcr.io/newrelic/deployer:latest
- name: general setup
env:
USER_CONFIG: ${{ secrets.UAT_USER_CONFIG }}
run: |
rm -rf configs $TRON_FOLDER tmp
mkdir configs $TRON_FOLDER tmp
cp ./user_acceptance_tests/deploy_configs/${{ matrix.scenario }}-${{ matrix.cloud_provider }}.deploy.config.json configs
cp -R deploy $TRON_FOLDER
cp -R engine $TRON_FOLDER
echo "$USER_CONFIG" > configs/uat-$TRON_FOLDER-${{ github.run_id }}.user.credentials.local.json
bundle install --gemfile=user_acceptance_tests/tests/Gemfile
- name: aws setup
env:
PEM_KEY: ${{ secrets.PEM_KEY }}
run: |
echo "$PEM_KEY" > configs/uat-ca.pem
chmod 400 configs/uat-ca.pem
- name: azure setup
env:
ID_RSA_PUB: ${{ secrets.UAT_AZURE_ID_RSA_PUB_FILE }}
ID_RSA: ${{ secrets.UAT_AZURE_ID_RSA_FILE }}
run: |
ssh-keygen -m PEM -t rsa -b 4096 -f $HOME/.ssh/id_rsa -q -N ""
mv $HOME/.ssh configs
- name: gcp setup
env:
UAT_GCP_PEM_FILE: ${{ secrets.UAT_GCP_PEM_FILE }}
UAT_GCP_SERVICEACCOUNT_FILE: ${{ secrets.UAT_GCP_SERVICEACCOUNT_FILE }}
run: |
echo "$UAT_GCP_PEM_FILE" > $GITHUB_WORKSPACE/configs/compute-user.pem
chmod 400 $GITHUB_WORKSPACE/configs/compute-user.pem
echo "$UAT_GCP_SERVICEACCOUNT_FILE" > $GITHUB_WORKSPACE/configs/demo-newrelic-staging-gcp-service-account.json
- name: debug ls - configs
run: ls $GITHUB_WORKSPACE/configs
- name: run deployment
id: deployment
run: |
docker run -t \
-v $GITHUB_WORKSPACE/$TRON_FOLDER:/mnt/deployer/$TRON_FOLDER \
-v $GITHUB_WORKSPACE/configs:/mnt/deployer/configs \
-v $GITHUB_WORKSPACE/tmp:/tmp \
ghcr.io/newrelic/deployer:latest \
main.rb -d /mnt/deployer/configs/${{ matrix.scenario }}-${{ matrix.cloud_provider }}.deploy.config.json -l debug \
-o /tmp/output.json
- name: debug ls - tmp
run: |
ls tmp
- name: run tests
id: test
run: ruby ./user_acceptance_tests/tests/${{ matrix.scenario }}.rb
env:
TEST_INPUT_FILE_LOCATION: tmp/output.json
- name: run teardown
if: always()
run: |
docker run -t \
-v $GITHUB_WORKSPACE/$TRON_FOLDER:/mnt/deployer/$TRON_FOLDER \
-v $GITHUB_WORKSPACE/configs:/mnt/deployer/configs \
-v $GITHUB_WORKSPACE/tmp:/tmp \
ghcr.io/newrelic/deployer:latest \
main.rb -d /mnt/deployer/configs/${{ matrix.scenario }}-${{ matrix.cloud_provider }}.deploy.config.json -t -l debug
- name: slack notification
uses: 8398a7/action-slack@v3
if: always() && github.event_name == 'push'
with:
author_name: GitHub Actions
status: custom
fields: commit,repo,ref,author,eventName,message,workflow
custom_payload: |
{
username: "GitHub Actions",
icon_emoji: ":octocat:",
attachments: [{
color: '${{ job.status }}' === 'success' ? '#43cc11' : '${{ job.status }}' === 'failure' ? '#e05d44' : '#dfb317',
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: `Build for ${process.env.AS_REPO}`
}
},
{
type: "section",
fields: [
{
type: "mrkdwn",
text: `*Commit:*\n${process.env.AS_COMMIT}`
},
{
type: "mrkdwn",
text: `*Author:*\n${process.env.AS_AUTHOR}`
},
{
type: "mrkdwn",
text: `*Branch:*\n${process.env.AS_REF}`
},
{
type: "mrkdwn",
text: `*Message:*\n${process.env.AS_MESSAGE}`
},
{
type: "mrkdwn",
text: `*Type:*\n${process.env.AS_EVENT_NAME}`
},
{
type: "mrkdwn",
text: "*PR:*\n${{ github.event.pull_request.html_url }}"
},
{
type: "mrkdwn",
text: `*Workflow:*\n${ process.env.AS_WORKFLOW }`
}
]
},
{
type: "section",
text: {
type: "mrkdwn",
text: [
"*Result:*",
`• ${ ${{ steps.test.outcome == 'success' }} === true ? '✅' : '❌' } Test (${{ matrix.cloud_provider }}, ${{ matrix.scenario }}): ${{ steps.test.outcome }}`
].join('\n')
}
},
{
type: "context",
elements: [
{
type: "image",
image_url: "https://avatars2.githubusercontent.com/in/15368",
alt_text: "Github Actions"
},
{
type: "mrkdwn",
text: "This message was created automatically by GitHub Actions."
}
]
}
]
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}