Skip to content

Commit d765c42

Browse files
pellecchialuigiLuigi Pellecchia
andauthored
Fix tmt ssh issue (#257)
* Fix ssh-key propagation in testrun. Use safer trim function in frontend to consider null values. Signed-off-by: Luigi Pellecchia <lpellecc@redhat.com> * Fix fast-fail version --------- Signed-off-by: Luigi Pellecchia <lpellecc@redhat.com> Co-authored-by: Luigi Pellecchia <lpellecc@redhat.com>
1 parent c54f830 commit d765c42

File tree

4 files changed

+94
-71
lines changed

4 files changed

+94
-71
lines changed

.github/workflows/build.yaml

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@ jobs:
1313
lint:
1414
name: Lint Python and JavaScript
1515
runs-on: ubuntu-latest
16-
16+
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20-
20+
2121
- name: Set up Python
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: '3.11'
25-
25+
2626
- name: Install Python lint dependencies
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install flake8
30-
30+
3131
- name: Run flake8
3232
run: flake8 api/ db/
33-
33+
3434
- name: Set up Node.js
3535
uses: actions/setup-node@v4
3636
with:
3737
node-version: '20'
38-
38+
3939
- name: Install Prettier
4040
run: npm install --no-save prettier
41-
41+
4242
- name: Run Prettier
4343
run: npx prettier --check app/src/app
4444

4545
apache_deployment:
4646
runs-on: ubuntu-latest
4747
steps:
48-
48+
4949
- name: Checkout
5050
uses: actions/checkout@v4
5151

@@ -63,7 +63,7 @@ jobs:
6363
6464
- name: Make deploy/apache/run.sh executable
6565
run: chmod +x deploy/apache/run.sh
66-
66+
6767
- name: Run the deployment
6868
run: |
6969
cd deploy/apache && sudo ./run.sh
@@ -77,13 +77,23 @@ jobs:
7777
echo "Test App is running"
7878
curl -vf http://localhost:9056
7979
80-
- name: Install cypress-fail-fast plugin
81-
run: npm install --save-dev cypress-fail-fast
80+
- uses: actions/setup-node@v4
81+
with:
82+
node-version: '20'
83+
cache: 'npm'
84+
cache-dependency-path: app/package-lock.json
85+
86+
# Pin cypress-fail-fast here (CI only, --no-save); v7.x matches Cypress 14; v8+ needs Cypress 15+
87+
- name: Install app dependencies and cypress-fail-fast (CI only)
88+
run: |
89+
npm ci
90+
npm install --no-save cypress-fail-fast@7.1.1
8291
working-directory: ./app
8392

8493
- name: Cypress E2E Testing Chrome
8594
uses: cypress-io/github-action@v6
8695
with:
96+
install: false
8797
browser: chrome
8898
working-directory: ./app
8999
spec: 'cypress/**/*.cy.js'
@@ -107,11 +117,11 @@ jobs:
107117
with:
108118
name: apache-error.log
109119
path: /var/log/apache2/error.log
110-
120+
111121
build_and_test:
112122
runs-on: ubuntu-latest
113123
steps:
114-
124+
115125
- name: Checkout
116126
uses: actions/checkout@v4
117127

@@ -128,18 +138,18 @@ jobs:
128138
echo "BASIL_TESTING=1" >> "$GITHUB_ENV"
129139
TEMPDIR=$(mktemp -d)
130140
echo "TEST_RUNS_BASE_DIR=$TEMPDIR" >> $GITHUB_ENV
131-
141+
132142
- name: Install Podman (if needed)
133143
run: |
134144
sudo apt update
135145
sudo apt install -y podman
136146
137147
- name: Install PostgreSQL client tools
138148
run: sudo apt-get update && sudo apt-get install -y postgresql-client
139-
149+
140150
- name: Make run_demo.sh executable
141151
run: chmod +x ./run_demo.sh
142-
152+
143153
- name: Run demo environment
144154
run: |
145155
sudo ./run_demo.sh \
@@ -183,20 +193,20 @@ jobs:
183193
uses: actions/setup-python@v5
184194
with:
185195
python-version: '3.11'
186-
196+
187197
- name: Install python dependencies
188198
run: |
189199
pip install --upgrade pip
190200
pip install -r requirements.txt
191-
192-
- name: API unit testing
201+
202+
- name: API unit testing
193203
run: |
194204
pytest -v ./api/test --cov=api --cov-branch --cov-report=term --cov-report=html
195-
205+
196206
- name: Create tarball of coverage report
197207
run: |
198208
tar -czf api-htmlcov.tar.gz htmlcov
199-
209+
200210
- name: Upload coverage report artifact
201211
uses: actions/upload-artifact@v4
202212
with:
@@ -211,14 +221,23 @@ jobs:
211221
curl -vf http://localhost:$BASIL_API_PORT/apis
212222
curl -vf http://localhost:$BASIL_API_PORT/libraries
213223
curl -vf http://localhost:$BASIL_API_PORT/version
214-
215-
- name: Install cypress-fail-fast plugin
216-
run: npm install --save-dev cypress-fail-fast
224+
225+
- uses: actions/setup-node@v4
226+
with:
227+
node-version: '20'
228+
cache: 'npm'
229+
cache-dependency-path: app/package-lock.json
230+
231+
- name: Install app dependencies and cypress-fail-fast (CI only)
232+
run: |
233+
npm ci
234+
npm install --no-save cypress-fail-fast@7.1.1
217235
working-directory: ./app
218236

219237
- name: Cypress E2E Testing Chrome
220238
uses: cypress-io/github-action@v6
221239
with:
240+
install: false
222241
browser: chrome
223242
working-directory: ./app
224243
spec: 'cypress/**/*.cy.js'
@@ -250,13 +269,13 @@ jobs:
250269
} > "podman-logs/${cname}.log"
251270
done
252271
ls -lh podman-logs
253-
272+
254273
- name: Copy /var/tmp/tmt from basil-api-latest container
255274
if: failure()
256275
run: |
257276
sudo podman cp basil-api-latest:/var/test-runs ./tmt-logs
258277
tar -czf tmt-logs.tar.gz ./tmt-logs
259-
278+
260279
- name: Upload tmt logs as artifact
261280
uses: actions/upload-artifact@v4
262281
if: failure()

api/testrun.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ def __init__(self, id, unit_test=False):
176176
del db_config["environment_vars"]
177177
del db_config["context_vars"]
178178

179+
# Plugins (e.g. tmt connect) expect ssh_key_id; as_dict() exposes the FK as "ssh_key"
180+
if db_config.get("ssh_key") is not None:
181+
db_config["ssh_key_id"] = db_config["ssh_key"]
182+
179183
for k, v in db_config.items():
180184
if isinstance(v, dict):
181185
if k in self.config.keys():

app/src/app/Mapping/Form/TestRunConfigForm.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
293293
}, [testRunConfig])
294294

295295
React.useEffect(() => {
296-
if (titleValue.trim() === '') {
296+
if (Constants._trim(titleValue) === '') {
297297
setValidatedTitleValue('error')
298298
} else {
299299
setValidatedTitleValue('success')
@@ -303,7 +303,7 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
303303
}, [titleValue])
304304

305305
React.useEffect(() => {
306-
if (guestValue.trim() === '') {
306+
if (Constants._trim(guestValue) === '') {
307307
setValidatedGuestValue('error')
308308
} else {
309309
setValidatedGuestValue('success')
@@ -313,7 +313,7 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
313313
}, [guestValue])
314314

315315
React.useEffect(() => {
316-
if (guestPortValue.trim() === '') {
316+
if (Constants._trim(guestPortValue) === '') {
317317
setValidatedGuestPortValue('error')
318318
} else {
319319
setValidatedGuestPortValue('success')
@@ -323,7 +323,7 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
323323
}, [guestPortValue])
324324

325325
React.useEffect(() => {
326-
if (provisionTypeValue.trim() === '') {
326+
if (Constants._trim(provisionTypeValue) === '') {
327327
setValidatedProvisionTypeValue('error')
328328
} else {
329329
setValidatedProvisionTypeValue('success')
@@ -343,7 +343,7 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
343343
}, [refValue, envVarsValue, contextVarsValue])
344344

345345
React.useEffect(() => {
346-
if (sshKeyValue.trim() === '') {
346+
if (Constants._trim(sshKeyValue) === '') {
347347
setValidatedSSHKeyValue('error')
348348
} else {
349349
setValidatedSSHKeyValue('success')
@@ -360,25 +360,25 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
360360
}, [pluginValue, pluginPresetValue])
361361

362362
React.useEffect(() => {
363-
if (gitlabCIUrlValue.trim() === '') {
363+
if (Constants._trim(gitlabCIUrlValue) === '') {
364364
setValidatedGitlabCIUrlValue('error')
365365
} else {
366366
setValidatedGitlabCIUrlValue('success')
367367
}
368368

369-
if (gitlabCIProjectIdValue.trim() === '') {
369+
if (Constants._trim(gitlabCIProjectIdValue) === '') {
370370
setValidatedGitlabCIProjectIdValue('error')
371371
} else {
372372
setValidatedGitlabCIProjectIdValue('success')
373373
}
374374

375-
if (gitlabCITriggerTokenValue.trim() === '') {
375+
if (Constants._trim(gitlabCITriggerTokenValue) === '') {
376376
setValidatedGitlabCITriggerTokenValue('error')
377377
} else {
378378
setValidatedGitlabCITriggerTokenValue('success')
379379
}
380380

381-
if (gitlabCIPrivateTokenValue.trim() === '') {
381+
if (Constants._trim(gitlabCIPrivateTokenValue) === '') {
382382
setValidatedGitlabCIPrivateTokenValue('error')
383383
} else {
384384
setValidatedGitlabCIPrivateTokenValue('success')
@@ -389,13 +389,13 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
389389
}, [gitlabCIJobValue, gitlabCIPrivateTokenValue, gitlabCIProjectIdValue, gitlabCIStageValue, gitlabCITriggerTokenValue, gitlabCIUrlValue])
390390

391391
React.useEffect(() => {
392-
if (githubActionsUrlValue.trim() === '') {
392+
if (Constants._trim(githubActionsUrlValue) === '') {
393393
setValidatedGithubActionsUrlValue('error')
394394
} else {
395395
setValidatedGithubActionsUrlValue('success')
396396
}
397397

398-
if (githubActionsPrivateTokenValue.trim() === '') {
398+
if (Constants._trim(githubActionsPrivateTokenValue) === '') {
399399
setValidatedGithubActionsPrivateTokenValue('error')
400400
} else {
401401
setValidatedGithubActionsPrivateTokenValue('success')
@@ -406,25 +406,25 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
406406
}, [githubActionsJobValue, githubActionsUrlValue, githubActionsWorkflowIdValue, githubActionsPrivateTokenValue])
407407

408408
React.useEffect(() => {
409-
if (testingFarmArchValue.trim() === '') {
409+
if (Constants._trim(testingFarmArchValue) === '') {
410410
setValidatedTestingFarmArchValue('error')
411411
} else {
412412
setValidatedTestingFarmArchValue('success')
413413
}
414414

415-
if (testingFarmComposeValue.trim() === '') {
415+
if (Constants._trim(testingFarmComposeValue) === '') {
416416
setValidatedTestingFarmComposeValue('error')
417417
} else {
418418
setValidatedTestingFarmComposeValue('success')
419419
}
420420

421-
if (testingFarmPrivateTokenValue.trim() === '') {
421+
if (Constants._trim(testingFarmPrivateTokenValue) === '') {
422422
setValidatedTestingFarmPrivateTokenValue('error')
423423
} else {
424424
setValidatedTestingFarmPrivateTokenValue('success')
425425
}
426426

427-
if (testingFarmUrlValue.trim() === '') {
427+
if (Constants._trim(testingFarmUrlValue) === '') {
428428
setValidatedTestingFarmUrlValue('error')
429429
} else {
430430
setValidatedTestingFarmUrlValue('success')
@@ -435,19 +435,19 @@ export const TestRunConfigForm: React.FunctionComponent<TestRunConfigFormProps>
435435
}, [testingFarmArchValue, testingFarmComposeValue, testingFarmUrlValue, testingFarmPrivateTokenValue])
436436

437437
React.useEffect(() => {
438-
if (lavaJobValue.trim() === '') {
438+
if (Constants._trim(lavaJobValue) === '') {
439439
setValidatedLavaJobValue('error')
440440
} else {
441441
setValidatedLavaJobValue('success')
442442
}
443443

444-
if (lavaPrivateTokenValue.trim() === '') {
444+
if (Constants._trim(lavaPrivateTokenValue) === '') {
445445
setValidatedLavaPrivateTokenValue('error')
446446
} else {
447447
setValidatedLavaPrivateTokenValue('success')
448448
}
449449

450-
if (lavaUrlValue.trim() === '') {
450+
if (Constants._trim(lavaUrlValue) === '') {
451451
setValidatedLavaUrlValue('error')
452452
} else {
453453
setValidatedLavaUrlValue('success')

0 commit comments

Comments
 (0)