-
Notifications
You must be signed in to change notification settings - Fork 11
287 lines (262 loc) · 10.2 KB
/
e2e.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: E2E Tests
run-name: E2E Tests (${{ inputs.version }}, ${{ inputs.environment }})
on:
workflow_dispatch:
inputs:
version:
description: "Bright CLI version (e.g.: v10.3.1)"
required: true
test-docker:
type: boolean
description: "Test Docker"
default: true
test-executables:
type: boolean
description: "Test Executables"
default: true
test-msi:
type: boolean
description: "Test MSI"
default: true
test-npm:
type: boolean
description: "Test NPM"
default: true
environment:
type: choice
default: staging
description: Environment
options:
- production
- staging
- development
test_timeout:
description: "Test timeout in seconds"
default: 3600
jobs:
executables:
if: ${{ inputs.test-executables }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
container: ubuntu:18.04
executable: bright-cli-linux-x64
node: 16
- os: ubuntu-latest
container: ubuntu:16.04
executable: bright-cli-linux-x64
node: 16
- os: ubuntu-latest
container: fedora:24
executable: bright-cli-linux-x64
node: 16
- os: ubuntu-latest
container: fedora:latest
executable: bright-cli-linux-x64
node: 20
- os: ubuntu-latest
executable: bright-cli-linux-x64
node: 20
- os: macos-11
executable: bright-cli-macos-x64
node: 20
- os: macos-latest
executable: bright-cli-macos-x64
node: 20
- os: windows-latest
executable: bright-cli-win-x64.exe
node: 20
- os: windows-2019
executable: bright-cli-win-x64.exe
node: 20
steps:
- name: Install Packages (Fedora)
if: ${{ startsWith(matrix.container, 'fedora') }}
run: |
dnf -y update \
&& dnf install -y curl tar \
&& dnf clean all \
&& rm -rf /var/cache/dnf/*
- name: Install Packages (Ubuntu)
if: startsWith(matrix.container, 'ubuntu')
run: |
apt-get update -yq \
&& apt-get install curl -yq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Executable
shell: bash
run: |
curl -fsSL https://github.com/NeuraLegion/bright-cli/releases/download/${{ inputs.version }}/${{ matrix.executable }} > ./${{ matrix.executable }}
chmod +x ./${{ matrix.executable }}
- name: Download Target
id: target
uses: ./.github/workflows/composite/todoapp
- name: Install Dependencies
uses: ./.github/workflows/composite/npm
with:
version: ${{ matrix.node }}
# https://github.com/actions/setup-node/issues/286#issuecomment-878865957
cache: ''
- name: Run Tests
run: npm run test:e2e
env:
E2E_CLI_VERSION: ${{ inputs.version }}
E2E_CLI_CMD: ${{ runner.os != 'windows' && format('./{0}', matrix.executable) || format('.\{0}', matrix.executable) }}
E2E_RUN_ID: ${{ format('{0}-{1}-{2}-{3}', github.run_number, github.run_attempt, github.job, strategy.job-index) }}
E2E_CLUSTER: ${{ vars[format('E2E_{0}_HOST', inputs.environment )] }}
E2E_PROJECT_ID: ${{ vars[format('E2E_{0}_PROJECT_ID', inputs.environment )] }}
E2E_CLUSTER_API_KEY: ${{ secrets[format('E2E_{0}_API_KEY', inputs.environment )] }}
E2E_REPEATER_TARGET_URL: ${{ format('http://localhost:{0}', steps.target.outputs.port) }}
E2E_REPEATER_TARGET_CMD: ${{ steps.target.outputs.cmd }}
E2E_TEST_TIMEOUT: ${{ inputs.test_timeout }}
msi:
if: ${{ inputs.test-msi }}
runs-on: windows-latest
steps:
- name: Download and Install Bright CLI using MSI
shell: pwsh
run: |
Invoke-WebRequest -Uri https://github.com/NeuraLegion/bright-cli/releases/download/${{ inputs.version }}/bright-cli.msi -OutFile bright-cli.msi
$lastExitCode = (Start-Process msiexec.exe `
-ArgumentList "/i bright-cli.msi /qn /norestart /l*v `"$($pwd)\install.log`"" `
-PassThru `
-Wait `
-WorkingDirectory "$pwd").ExitCode
if ($lastExitCode -ne 0) {
Write-Error "Got exit code $lastExitCode."
Get-Content "$($pwd)\install.log"
exit 1
}
Write-Host "Bright CLI installation complete"
"C:\Program Files\BrightCLI" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Get the version of Bright CLI after install
run: bright-cli.exe -v
shell: pwsh
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Target
id: target
uses: ./.github/workflows/composite/todoapp
- name: Install Dependencies
uses: ./.github/workflows/composite/npm
with:
# https://github.com/actions/setup-node/issues/286#issuecomment-878865957
cache: ''
- name: Run Tests
run: npm run test:e2e
env:
E2E_CLI_VERSION: ${{ inputs.version }}
E2E_CLI_CMD: ${{ 'bright-cli.exe' }}
E2E_RUN_ID: ${{ format('{0}-{1}-{2}-{3}', github.run_number, github.run_attempt, github.job, strategy.job-index) }}
E2E_CLUSTER: ${{ vars[format('E2E_{0}_HOST', inputs.environment )] }}
E2E_PROJECT_ID: ${{ vars[format('E2E_{0}_PROJECT_ID', inputs.environment )] }}
E2E_CLUSTER_API_KEY: ${{ secrets[format('E2E_{0}_API_KEY', inputs.environment )] }}
E2E_REPEATER_TARGET_URL: ${{ format('http://localhost:{0}', steps.target.outputs.port) }}
E2E_REPEATER_TARGET_CMD: ${{ steps.target.outputs.cmd }}
E2E_TEST_TIMEOUT: ${{ inputs.test_timeout }}
docker:
if: ${{ inputs.test-docker }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Windows can't run linux docker images: https://github.com/actions/runner-images/issues/1143
os: [ubuntu-latest, macos-latest]
steps:
- name: Install Docker (MacOS)
if: ${{ startsWith(matrix.os, 'macos') }}
uses: docker-practice/actions-setup-docker@master
timeout-minutes: 12
- name: Pull Image
run: docker pull brightsec/cli:${{ inputs.version }}
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Target
id: target
uses: ./.github/workflows/composite/todoapp
- name: Install Dependencies
uses: ./.github/workflows/composite/npm
with:
# https://github.com/actions/setup-node/issues/286#issuecomment-878865957
cache: ''
- name: Run Tests
run: npm run test:e2e
env:
E2E_CLI_VERSION: ${{ inputs.version }}
E2E_CLI_CMD: docker run --add-host host.docker.internal:host-gateway --network host brightsec/cli:${{ inputs.version }}
E2E_RUN_ID: ${{ format('{0}-{1}-{2}-{3}', github.run_number, github.run_attempt, github.job, strategy.job-index) }}
E2E_CLUSTER: ${{ vars[format('E2E_{0}_HOST', inputs.environment )] }}
E2E_PROJECT_ID: ${{ vars[format('E2E_{0}_PROJECT_ID', inputs.environment )] }}
E2E_CLUSTER_API_KEY: ${{ secrets[format('E2E_{0}_API_KEY', inputs.environment )] }}
E2E_REPEATER_TARGET_URL: ${{ format('http://host.docker.internal:{0}', steps.target.outputs.port) }}
E2E_REPEATER_TARGET_CMD: ${{ steps.target.outputs.cmd }}
E2E_TEST_TIMEOUT: ${{ inputs.test_timeout }}
npm:
if: ${{ inputs.test-npm }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
node: [16, 18, 20]
include:
- os: ubuntu-latest
container: ubuntu:16.04
node: 16
- os: ubuntu-latest
container: fedora:24
node: 16
- os: ubuntu-latest
container: fedora:latest
node: 18
- os: ubuntu-latest
container: fedora:latest
node: 20
steps:
- name: Install Packages (Fedora)
if: ${{ startsWith(matrix.container, 'fedora') }}
run: |
dnf -y update \
&& dnf install -y curl tar \
&& dnf clean all \
&& rm -rf /var/cache/dnf/*
- name: Install Packages (Ubuntu)
if: startsWith(matrix.container, 'ubuntu')
run: |
apt-get update -yq \
&& apt-get install curl -yq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Target
id: target
uses: ./.github/workflows/composite/todoapp
- name: Install Dependencies
uses: ./.github/workflows/composite/npm
with:
version: ${{ matrix.node }}
# https://github.com/actions/setup-node/issues/286#issuecomment-878865957
cache: ''
- name: Install CLI
run: npm i -g @brightsec/cli@${{ inputs.version }}
- name: Run Tests
run: npm run test:e2e
env:
E2E_CLI_VERSION: ${{ inputs.version }}
E2E_CLI_CMD: bright-cli
E2E_RUN_ID: ${{ format('{0}-{1}-{2}-{3}', github.run_number, github.run_attempt, github.job, strategy.job-index) }}
E2E_CLUSTER: ${{ vars[format('E2E_{0}_HOST', inputs.environment )] }}
E2E_PROJECT_ID: ${{ vars[format('E2E_{0}_PROJECT_ID', inputs.environment )] }}
E2E_CLUSTER_API_KEY: ${{ secrets[format('E2E_{0}_API_KEY', inputs.environment )] }}
E2E_REPEATER_TARGET_URL: ${{ format('http://localhost:{0}', steps.target.outputs.port) }}
E2E_REPEATER_TARGET_CMD: ${{ steps.target.outputs.cmd }}
E2E_TEST_TIMEOUT: ${{ inputs.test_timeout }}