Skip to content

Commit c2ca8b1

Browse files
committed
Merge branch 'main' of github.com:lando/cli into main
2 parents 093ba9d + c068dca commit c2ca8b1

File tree

6 files changed

+125
-8
lines changed

6 files changed

+125
-8
lines changed

.github/workflows/pr-runtime-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
leia-test:
1919
- examples/appname
2020
- examples/global
21+
- examples/renderer
2122
- examples/v3
2223
- examples/v4
2324
steps:

examples/renderer/.lando.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: lando-renderer
2+
services:
3+
appserver:
4+
api: 3
5+
type: lando
6+
healthcheck: healthcheck
7+
services:
8+
image: php:8.2-fpm
9+
command: docker-php-entrypoint sleep infinity
10+
volumes:
11+
- "./healthcheck.sh:/usr/local/bin/healthcheck"
12+
nginx:
13+
api: 3
14+
type: lando
15+
healthcheck: healthcheck
16+
services:
17+
image: nginx:1.22.1
18+
command: /docker-entrypoint.sh nginx -g "daemon off;"
19+
ports:
20+
- 80
21+
volumes:
22+
- ./:/usr/share/nginx/html
23+
- "./healthcheck.sh:/usr/local/bin/healthcheck"
24+
run_as_root:
25+
- echo "$(id)" > /run_as_root.txt
26+
- ln -snf /usr/share/zoneinfo/America/New_York /etc/localtime
27+
- echo "America/New_York" > /etc/timezone
28+
overrides:
29+
environment:
30+
THING: STUFF
31+
volumes:
32+
- "./test.txt:/var/www/test.txt"
33+
database:
34+
api: 3
35+
type: lando
36+
healthcheck: healthcheck
37+
services:
38+
image: mariadb:10.4
39+
command: docker-entrypoint.sh mysqld
40+
environment:
41+
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: da
42+
MARIADB_MYSQL_LOCALHOST_USER: da
43+
MARIADB_DATABASE: test
44+
MARIADB_USER: test
45+
MARIADB_PASSWORD: test
46+
MARIADB_AUTO_UPGRADE: da
47+
volumes:
48+
- "./healthcheck.sh:/usr/local/bin/healthcheck"

examples/renderer/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Renderer Example
2+
================
3+
4+
This example exists primarily to test the fallback non-TTY list renderer.
5+
6+
Start up tests
7+
--------------
8+
9+
Run the following commands to get up and running with this example.
10+
11+
```bash
12+
# Should start up successfully
13+
lando poweroff
14+
lando start
15+
```
16+
17+
Verification commands
18+
---------------------
19+
20+
Run the following commands to validate things are rolling as they should.
21+
22+
```bash
23+
# Should use the verbose renderer in a non-TTY environment
24+
lando start | grep "\[COMPLETED\]" | wc -l | grep 5
25+
```
26+
27+
Destroy tests
28+
-------------
29+
30+
Run the following commands to trash this app like nothing ever happened.
31+
32+
```bash
33+
# Should be destroyed with success
34+
lando destroy -y
35+
lando poweroff
36+
```

examples/renderer/healthcheck.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
rm -rf /healthy
5+
6+
main () {
7+
local healthfile=/tmp/healthfile
8+
9+
# if healthcheck file does not exist then create it
10+
if [ ! -f $healthfile ]; then
11+
touch $healthfile
12+
fi
13+
# append an X to the healthfile
14+
echo -n "X" >> $healthfile
15+
# run our "healthcheck"
16+
cat $healthfile | grep -w "XXXXX" && rm -rf $healthfile
17+
}
18+
19+
main
20+
21+
touch /healthy

examples/renderer/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>HAND ME DOWN!</h1>
2+
<h2>or don't</h2>

lib/cli.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,11 @@ module.exports = class Cli {
499499
// run a listr tasks list
500500
async runTaskList(tasks, {
501501
ctx = {},
502+
debugRenderer = 'debug',
503+
debugRendererOptions = {},
502504
renderer = 'default',
503-
rendererDebug = 'debug',
504505
rendererForce = false,
505506
rendererOptions = {},
506-
rendererDebugOptions = {},
507507
listrOptions = {},
508508
} = {}) {
509509
// get the bossman
@@ -517,32 +517,41 @@ module.exports = class Cli {
517517
|| this.logLevel === 'debug'
518518
|| this.logLevel === 'silly'
519519
)) {
520-
renderer = rendererDebug;
521-
rendererOptions = rendererDebugOptions;
520+
renderer = debugRenderer;
521+
rendererOptions = debugRendererOptions;
522522
}
523523

524524
// attempt to reset the renderer if its a string and has a renderer we can load
525525
if (typeof renderer === 'string' && fs.existsSync(path.resolve(__dirname, '..', 'renderers', `${renderer}.js`))) {
526526
renderer = require(path.resolve(__dirname, '..', 'renderers', renderer));
527527
}
528+
if (typeof debugRenderer === 'string' && fs.existsSync(path.resolve(__dirname, '..', 'renderers', `${debugRenderer}.js`))) {
529+
debugRenderer = require(path.resolve(__dirname, '..', 'renderers', debugRenderer));
530+
}
528531

529532
const defaults = {
530533
ctx,
531-
renderer,
532-
collectErrors: true,
533534
concurrent: true,
534-
showErrorMessage: false,
535+
collectErrors: true,
535536
exitOnError: false,
537+
fallbackRenderer: 'verbose',
538+
renderer,
536539
rendererOptions: {
537540
log: require('@lando/core-next/debug')('lando').extend('cli'),
538541
collapseSubtasks: false,
539542
suffixRetries: false,
540543
showErrorMessage: false,
541544
},
545+
showErrorMessage: false,
542546
};
543547

544548
// construct the runner
545-
const runner = new Manager(_.merge({}, defaults, {...listrOptions, rendererOptions}));
549+
const runner = new Manager(_.merge({}, defaults, {
550+
...listrOptions,
551+
fallbackRendererOptions: debugRendererOptions,
552+
rendererOptions,
553+
}));
554+
546555
// add the tasks
547556
runner.add(tasks);
548557
// run

0 commit comments

Comments
 (0)