-
Notifications
You must be signed in to change notification settings - Fork 74
218 lines (191 loc) · 8.57 KB
/
e2e-dp-us.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: End to end testing (US) (inactive)
on:
workflow_dispatch:
# push:
# branches: [main]
# pull_request:
# branches: [main]
# workflow_run:
# workflows: ["Release"]
# types: [requested]
jobs:
get-test-definition-files:
name: Get Test Definition Files
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-test-definition-files.outputs.result }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
repository: newrelic/open-install-library
path: open-install-library
- name: Get Test Definition Files
id: get-test-definition-files
uses: actions/github-script@v3
with:
script: |
const fs = require("fs");
const fsp = fs.promises;
const path = require("path");
// readdir recursive directory search
const { readdir } = fsp;
async function getFiles(dir) {
const dirents = await readdir(dir, { withFileTypes: true });
const files = await Promise.all(
dirents.map((dirent) => {
const res = path.join(dir, dirent.name);
return dirent.isDirectory() ? getFiles(res) : res;
})
);
return Array.prototype.concat(...files);
}
const testDefinitions = await getFiles(`${process.env.GITHUB_WORKSPACE}/open-install-library/test/definitions/smoke`);
const outputTestFilesMap = testDefinitions
.map((testDefinitionFile) => {
return {
testDefinitionFile,
testDisplayName: testDefinitionFile.split("/").pop(),
testDefinitionSuffix: `/test/definitions/smoke/${testDefinitionFile.split("/").pop()}`
};
});
const output = {
include: outputTestFilesMap,
};
console.log(output);
return output;
validate:
name: ${{ matrix.testDisplayName }}
needs: [get-test-definition-files]
if: ${{ fromJSON(needs.get-test-definition-files.outputs.matrix).include[0] }} # Avoids empty matrix validation error
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.get-test-definition-files.outputs.matrix) }}
fail-fast: false
env:
MATRIX: ${{ toJSON(matrix) }}
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Add GOBIN to PATH
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash
- name: Checkout Repo
uses: actions/checkout@v3
- name: Checkout Repo
uses: actions/checkout@v3
with:
repository: newrelic/open-install-library
path: open-install-library
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v2
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
- name: Install PGP private key
shell: bash
env:
PGP_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }}
run: echo "$PGP_PRIVATE_KEY" | gpg --batch --import
- name: Compile all distros
continue-on-error: true
# Creating the Snapcraft directories ahead of the snapshot is a workaround
# to deal with a race condition with parallel builds between distros.
#
# https://github.com/goreleaser/goreleaser/issues/1715#issuecomment-667002748
run: |
mkdir -p $HOME/.cache/snapcraft/download
mkdir -p $HOME/.cache/snapcraft/stage-packages
make snapshot
# Inject newrelic cli path to any of the smoke tests
- name: Add newrelic cli path to smoke tests
id: add-newrelic-cli-path-smoke-tests
uses: actions/github-script@v6
continue-on-error: false
env:
TEST_DEFINITION_FILE: ${{ matrix.testDefinitionFile }}
with:
script: |
const fs = require('fs');
const fsp = fs.promises;
const path = require('path');
// readdir recursive directory search
const { resolve } = path;
const { readdir } = fsp;
const newrelic_cli_linux_amd64_source_path = `${process.env.GITHUB_WORKSPACE}/dist/newrelic_linux_amd64_v1/newrelic`;
const newrelic_cli_linux_amd64_docker_path = `/mnt/deployer/dist/newrelic_linux_amd64_v1/newrelic`;
console.log(`Using cli linux source path ${newrelic_cli_linux_amd64_source_path}`);
if (!fs.existsSync(newrelic_cli_linux_amd64_source_path)) {
throw new Error(`The newrelic cli amd64 source does NOT exist ${newrelic_cli_linux_amd64_source_path}`);
}
const newrelic_cli_linux_arm64_source_path = `${process.env.GITHUB_WORKSPACE}/dist/newrelic_linux_arm64/newrelic`;
const newrelic_cli_linux_arm64_docker_path = `/mnt/deployer/dist/newrelic_linux_arm64/newrelic`;
console.log(`Using cli linux source path ${newrelic_cli_linux_arm64_source_path}`);
if (!fs.existsSync(newrelic_cli_linux_arm64_source_path)) {
throw new Error(`The newrelic cli arm64 source does NOT exist ${newrelic_cli_linux_arm64_source_path}`);
}
const newrelic_cli_windows_source_path = `${process.env.GITHUB_WORKSPACE}/dist/newrelic_windows_amd64_v1/newrelic.exe`;
const newrelic_cli_windows_docker_path = `/mnt/deployer/dist/newrelic_windows_amd64_v1/newrelic.exe`;
console.log(`Using cli windows source path ${newrelic_cli_windows_source_path}`);
if (!fs.existsSync(newrelic_cli_windows_source_path)) {
throw new Error(`The newrelic cli windows source does NOT exist ${newrelic_cli_windows_source_path}`);
}
// Get testDefinitionFile from MATRIX env var
const testDefinitionFile = process.env.TEST_DEFINITION_FILE;
console.log(`Detected Deploy Config: ${JSON.stringify(testDefinitionFile, null, 2)}`)
const jsonData = require(testDefinitionFile);
var isUpdated = false
var isWindows = false
var isArm64 = false
if (jsonData.resources) {
jsonData.resources.forEach(resource => {
if (resource.is_windows) {
isWindows = true;
}
if (!!resource.ami_name && resource.ami_name.toLowerCase().includes("arm64")) {
isArm64 = true;
}
});
}
if (jsonData.instrumentations) {
if (jsonData.instrumentations.resources) {
jsonData.instrumentations.resources.forEach(resource => {
if (resource.params) {
isUpdated = true;
resource.params.newrelic_cli_path = `${newrelic_cli_linux_amd64_docker_path}`;
if (isWindows) {
resource.params.newrelic_cli_path = `${newrelic_cli_windows_docker_path}`;
}
else if (isArm64) {
resource.params.newrelic_cli_path = `${newrelic_cli_linux_arm64_docker_path}`;
}
}
});
}
}
if (isUpdated) {
// Write file back to workspace
let jsonContent = JSON.stringify(jsonData, null, 2);
console.log("Updated Deploy Config File: ", testDefinitionFile);
console.log("Deploy Config content: ", jsonContent);
const outputPath = `${testDefinitionFile}`;
fs.writeFileSync(outputPath, jsonContent);
}
return testDefinitionFile;
- name: Install npm dependencies for deployer test runner
working-directory: ${{ github.workspace }}/.github/scripts
run: npm install
- name: Execute test
working-directory: ${{ github.workspace }}/.github/scripts
run: node main.js
env:
TEST_DEFINITION_URL: https://raw.githubusercontent.com/newrelic/open-install-library/main${{ matrix.testDefinitionSuffix }}
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER_PLATFORM_US_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER_PLATFORM_US_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.DEPLOYER_PLATFORM_US_AWS_REGION }}
SQS_URL: ${{ secrets.DEPLOYER_PLATFORM_US_SQS_URL }}
DYNAMO_TABLE: ${{ secrets.DEPLOYER_PLATFORM_US_DYNAMO_TABLE }}
- name: Report any error
if: steps.deployerRun.outputs.exit_status != 0
run: exit 1