From 35999574bd1ef6981ffd7e5ba6f0dd285f4cbd9c Mon Sep 17 00:00:00 2001 From: Yann Autissier Date: Thu, 3 Sep 2026 18:39:23 +0200 Subject: [PATCH] run the golden suite against the CLI too, and pin every delta Both engines now go through the same 68 cases. 31 produce byte-identical output; the rest have a recorded CLI expectation and a reason in DELTAS.md, the bulk of it being that the CLI does not shell out to a recursive make and calls compose once per project. Fixed while comparing: the CLI was missing the COMPOSE_FILE_* defaults, so overlays such as supabase.labels.yml would not have been loaded at all. --- Makefile | 3 +- bin/myos | 30 ++++++++--- lib/cmd/_compose.sh | 9 ++-- lib/cmd/doctor.sh | 2 +- lib/cmd/env.sh | 41 ++++++++++++--- lib/naming.sh | 3 +- spec/golden/DELTAS.md | 29 ++++++++++- spec/golden/cases.txt | 4 +- spec/golden/expected.cli/app-config.txt | 2 + spec/golden/expected.cli/app-down.txt | 2 + spec/golden/expected.cli/app-print-app.txt | 2 + .../expected.cli/app-print-compose-file.txt | 2 + .../golden/expected.cli/app-print-project.txt | 2 + .../expected.cli/app-print-repository.txt | 2 + .../expected.cli/app-print-service-name.txt | 2 + spec/golden/expected.cli/app-print-stack.txt | 2 + spec/golden/expected.cli/app-run.txt | 26 ++++++++++ spec/golden/expected.cli/app-scale.txt | 26 ++++++++++ .../golden/expected.cli/app-up-env-master.txt | 4 ++ spec/golden/expected.cli/app-up.txt | 4 ++ .../expected.cli/cat-drone-env-vars.txt | 2 + .../golden/expected.cli/cat-drone-version.txt | 2 + .../expected.cli/cat-group-default-up.txt | 7 +++ .../expected.cli/cat-group-testing-up.txt | 7 +++ .../golden/expected.cli/cat-nginx-www-dns.txt | 2 + .../expected.cli/cat-postgres-project.txt | 2 + spec/golden/expected.cli/cat-postgres-up.txt | 4 ++ .../expected.cli/cat-postgres-version.txt | 2 + .../expected.cli/cat-unknown-target.txt | 26 ++++++++++ spec/golden/expected.cli/host-config.txt | 2 + spec/golden/expected.cli/host-down-group.txt | 2 + spec/golden/expected.cli/host-exec.txt | 26 ++++++++++ spec/golden/expected.cli/host-logs.txt | 2 + spec/golden/expected.cli/host-print-app.txt | 2 + .../expected.cli/host-print-env-vars.txt | 2 + .../expected.cli/host-print-stack-dir.txt | 2 + spec/golden/expected.cli/host-ps.txt | 2 + .../expected.cli/host-stack-host-config.txt | 2 + spec/golden/expected.cli/host-target.txt | 2 + spec/golden/expected.cli/host-up-consul.txt | 4 ++ spec/golden/expected.cli/host-up-group.txt | 4 ++ spec/golden/expected.cli/host-up-two.txt | 4 ++ spec/golden/expected.cli/nogit-print-app.txt | 2 + .../expected.cli/nogit-print-project.txt | 2 + spec/golden/expected.cli/nogit-up.txt | 4 ++ spec/golden/expected/misc-help.txt | 52 ------------------- spec/golden/record.sh | 1 + spec/support/run.sh | 3 ++ 48 files changed, 296 insertions(+), 75 deletions(-) create mode 100644 spec/golden/expected.cli/app-config.txt create mode 100644 spec/golden/expected.cli/app-down.txt create mode 100644 spec/golden/expected.cli/app-print-app.txt create mode 100644 spec/golden/expected.cli/app-print-compose-file.txt create mode 100644 spec/golden/expected.cli/app-print-project.txt create mode 100644 spec/golden/expected.cli/app-print-repository.txt create mode 100644 spec/golden/expected.cli/app-print-service-name.txt create mode 100644 spec/golden/expected.cli/app-print-stack.txt create mode 100644 spec/golden/expected.cli/app-run.txt create mode 100644 spec/golden/expected.cli/app-scale.txt create mode 100644 spec/golden/expected.cli/app-up-env-master.txt create mode 100644 spec/golden/expected.cli/app-up.txt create mode 100644 spec/golden/expected.cli/cat-drone-env-vars.txt create mode 100644 spec/golden/expected.cli/cat-drone-version.txt create mode 100644 spec/golden/expected.cli/cat-group-default-up.txt create mode 100644 spec/golden/expected.cli/cat-group-testing-up.txt create mode 100644 spec/golden/expected.cli/cat-nginx-www-dns.txt create mode 100644 spec/golden/expected.cli/cat-postgres-project.txt create mode 100644 spec/golden/expected.cli/cat-postgres-up.txt create mode 100644 spec/golden/expected.cli/cat-postgres-version.txt create mode 100644 spec/golden/expected.cli/cat-unknown-target.txt create mode 100644 spec/golden/expected.cli/host-config.txt create mode 100644 spec/golden/expected.cli/host-down-group.txt create mode 100644 spec/golden/expected.cli/host-exec.txt create mode 100644 spec/golden/expected.cli/host-logs.txt create mode 100644 spec/golden/expected.cli/host-print-app.txt create mode 100644 spec/golden/expected.cli/host-print-env-vars.txt create mode 100644 spec/golden/expected.cli/host-print-stack-dir.txt create mode 100644 spec/golden/expected.cli/host-ps.txt create mode 100644 spec/golden/expected.cli/host-stack-host-config.txt create mode 100644 spec/golden/expected.cli/host-target.txt create mode 100644 spec/golden/expected.cli/host-up-consul.txt create mode 100644 spec/golden/expected.cli/host-up-group.txt create mode 100644 spec/golden/expected.cli/host-up-two.txt create mode 100644 spec/golden/expected.cli/nogit-print-app.txt create mode 100644 spec/golden/expected.cli/nogit-print-project.txt create mode 100644 spec/golden/expected.cli/nogit-up.txt delete mode 100644 spec/golden/expected/misc-help.txt diff --git a/Makefile b/Makefile index ca5c067..7f095a3 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,9 @@ SHELLSPEC ?= shellspec SHELLCHECK ?= shellcheck .PHONY: $(DEV_TARGETS) -test: ## Run unit + golden tests +test: ## Run unit + golden tests against both engines $(SHELLSPEC) + MYOS_ENGINE=cli $(SHELLSPEC) spec/golden test-unit: ## Run unit tests only $(SHELLSPEC) spec/unit test-golden: ## Run golden tests only (MYOS_ENGINE=legacy|cli) diff --git a/bin/myos b/bin/myos index 6a155c5..3e1805e 100755 --- a/bin/myos +++ b/bin/myos @@ -123,22 +123,34 @@ ENV=${ENV:-local} myos_dotenv_load "$WORKDIR/.env.$ENV" myos_dotenv_load "$WORKDIR/.env" +# Overlay switches. Their names drive which ..yml files load, +# so these defaults decide that e.g. supabase.labels.yml is picked up. +COMPOSE_FILE_APP=${COMPOSE_FILE_APP:-true} +COMPOSE_FILE_LABELS=${COMPOSE_FILE_LABELS:-true} +COMPOSE_FILE_NETWORKS=${COMPOSE_FILE_NETWORKS:-true} +COMPOSE_FILE_SSH=${COMPOSE_FILE_SSH:-true} +COMPOSE_FILE_VOLUMES=${COMPOSE_FILE_VOLUMES:-true} +COMPOSE_FILE_DEBUG=${COMPOSE_FILE_DEBUG:-${DEBUG:+true}} + USER=${USER:-$(id -nu 2>/dev/null)} HOSTNAME=${HOSTNAME:-$(hostname 2>/dev/null | sed 's/\..*//')} HOSTNAME=$(myos_lower "$HOSTNAME") DOMAIN=${DOMAIN:-localhost} +DOMAINNAME=${DOMAINNAME:-${DOMAIN%% *}} +MAIL=${MAIL:-$(git config user.email 2>/dev/null || printf '%s@%s' "$USER" "$DOMAINNAME")} DRYRUN=${DRYRUN:-false} myos_colors # --- stack references ----------------------------------------------------- -# No reference given: the current directory when it holds a compose file, -# else the STACK of the configuration. +# No reference given: the configured STACK, else the current directory when it +# holds a compose file. An explicit STACK always wins, so a project that pins +# its stacks in .env keeps working from inside its own directory. if [ -z "$MYOS_REFS" ]; then - if [ -f "$WORKDIR/docker-compose.yml" ] || [ -f "$WORKDIR/compose.yml" ] || - [ -f "$WORKDIR/docker/docker-compose.yml" ]; then + if [ -n "${STACK:-}" ]; then + MYOS_REFS=$STACK + elif [ -f "$WORKDIR/docker-compose.yml" ] || [ -f "$WORKDIR/compose.yml" ] || + [ -f "$WORKDIR/docker/docker-compose.yml" ]; then MYOS_REFS=./ - else - MYOS_REFS=${STACK:-} fi fi if [ -z "$MYOS_REFS" ]; then @@ -151,6 +163,12 @@ fi # shellcheck disable=SC2086 # a list of references MYOS_STACKS=$(myos_group_expand $MYOS_REFS) +# myos_framework_compose_files the networks and volumes overlays myos itself +# provides; they always come last so a stack can rely on them being there. +myos_framework_compose_files() { + myos_compose_files "$MYOS_ROOT/share/compose" "networks volumes" "$(myos_compose_suffixes)" "$ENV" +} + # myos_stack_compose_files REF the ordered compose files of one reference myos_stack_compose_files() { _dir=$(myos_stack_resolve "$1") || return $? diff --git a/lib/cmd/_compose.sh b/lib/cmd/_compose.sh index a57368a..52ddec7 100644 --- a/lib/cmd/_compose.sh +++ b/lib/cmd/_compose.sh @@ -1,4 +1,5 @@ #shellcheck shell=sh +# shellcheck disable=SC3028 # HOSTNAME is a myos variable, set by bin/myos # The commands that map straight onto docker compose. # # Stacks are grouped by compose project: every host stack shares the project of @@ -26,10 +27,10 @@ myos_cmd_compose() { for _project in $(printf '%s' "$_projects" | sed '/^$/d' | cut -f1 | awk '!seen[$0]++'); do _files=$(printf '%s' "$_projects" | sed '/^$/d' | awk -F'\t' -v p="$_project" '$1==p {print $2}' | tr ' ' '\n' | sed '/^$/d' | awk '!seen[$0]++') - # the framework networks always come last, as the make engine did - [ -f "$MYOS_ROOT/share/compose/networks.yml" ] && - _files="$_files -$MYOS_ROOT/share/compose/networks.yml" + # the framework overlays always come last, as the make engine did + _fw=$(myos_framework_compose_files) + [ -n "$_fw" ] && _files="$_files +$_fw" COMPOSE_PROJECT_NAME=$_project COMPOSE_SERVICE_NAME=$(myos_service_name "$_project") diff --git a/lib/cmd/doctor.sh b/lib/cmd/doctor.sh index 37c3770..79ed5a7 100644 --- a/lib/cmd/doctor.sh +++ b/lib/cmd/doctor.sh @@ -1,4 +1,5 @@ #shellcheck shell=sh +# shellcheck disable=SC3028 # HOSTNAME is a myos variable, set by bin/myos # myos doctor check that this installation can actually run a stack myos_cmd_doctor() { _rc=0 @@ -21,7 +22,6 @@ myos_cmd_doctor() { [ -f "$WORKDIR/.env" ] && _ok "$WORKDIR/.env" "read" _ok ENV "$ENV" _ok USER "$USER" - # shellcheck disable=SC3028 # HOSTNAME is set by bin/myos _ok HOSTNAME "$HOSTNAME" _ok DOMAIN "$DOMAIN" _ok "project format" "${MYOS_PROJECT_FORMAT:-user-env-app}" diff --git a/lib/cmd/env.sh b/lib/cmd/env.sh index 9e1a2aa..9a2a4db 100644 --- a/lib/cmd/env.sh +++ b/lib/cmd/env.sh @@ -1,4 +1,5 @@ #shellcheck shell=sh +# shellcheck disable=SC3028 # HOSTNAME is a myos variable, set by bin/myos # myos env [VAR...] show resolved variables (replaces the make print-VAR target) myos_cmd_env() { _vars=${MYOS_VARS:-} @@ -13,6 +14,20 @@ myos_cmd_env() { COMPOSE_FILE) printf '%s %s\n' "$_v" "$(myos_all_compose_files | tr '\n' ' ' | sed 's/ $//')" ;; COMPOSE_PROJECT_NAME) printf '%s %s\n' "$_v" "$(myos_first_project)" ;; STACK) printf '%s %s\n' "$_v" "$(printf '%s' "$MYOS_STACKS" | tr '\n' ' ' | sed 's/ $//')" ;; + DOCKER_NETWORK_DEFAULT) printf '%s %s\n' "$_v" "$(myos_network_default "$(myos_first_project)")" ;; + DOCKER_NETWORK_PRIVATE) printf '%s %s\n' "$_v" "$(myos_network_private "$USER" "$ENV")" ;; + DOCKER_NETWORK_PUBLIC) printf '%s %s\n' "$_v" "$(myos_network_public "${HOSTNAME:-}")" ;; + COMPOSE_SERVICE_NAME) printf '%s %s\n' "$_v" "$(myos_service_name "$(myos_first_project)")" ;; + COMPOSE_FILE_SUFFIX) printf '%s %s\n' "$_v" "$(myos_compose_suffixes)" ;; + APP|APP_NAME) printf '%s %s\n' "$_v" "$(myos_first_app)" ;; + SCOPE) printf '%s %s\n' "$_v" "$(myos_first_scope)" ;; + # HOST_STACK/USER_STACK are the names the make engine used for the scope + HOST_STACK) [ "$(myos_first_scope)" = host ] && printf '%s host\n' "$_v" || printf '%s\n' "$_v" ;; + USER_STACK) [ "$(myos_first_scope)" = user ] && printf '%s User\n' "$_v" || printf '%s\n' "$_v" ;; + DOCKER_REPOSITORY) printf '%s %s\n' "$_v" "$(printf '%s' "$(myos_first_project)" | tr '_-' '//')" ;; + DOCKER_NETWORK) + if [ "$(myos_first_scope)" = user ]; then printf '%s %s\n' "$_v" "$USER" + else printf '%s %s\n' "$_v" "$(myos_network_private "$USER" "$ENV")"; fi ;; *) printf '%s %s\n' "$_v" "$(myos_var "$_v")" ;; esac done @@ -23,16 +38,30 @@ myos_all_compose_files() { for _ref in $MYOS_STACKS; do myos_stack_compose_files "$_ref" 2>/dev/null done - [ -f "$MYOS_ROOT/share/compose/networks.yml" ] && printf '%s\n' "$MYOS_ROOT/share/compose/networks.yml" + myos_framework_compose_files return 0 } -# myos_first_project the compose project of the first requested stack -myos_first_project() { +# myos_first_app / myos_first_scope / myos_first_project +# describe the first requested stack, which is what the introspection commands +# report when several stacks are asked for at once. +myos_first_app() { for _ref in $MYOS_STACKS; do - _app=$(myos_stack_name "$_ref") - case $_ref in .|./*|/*|../*) _app=$(basename "$(myos_stack_resolve "$_ref" 2>/dev/null)") ;; esac - myos_project_name "$(myos_scope "$_ref")" "$USER" "$ENV" "$_app" + case $_ref in + .|./*|/*|../*) basename "$(myos_stack_resolve "$_ref" 2>/dev/null)" ;; + *) myos_stack_name "$_ref" ;; + esac + return 0 + done +} + +myos_first_scope() { + for _ref in $MYOS_STACKS; do myos_scope "$_ref"; return 0; done +} + +myos_first_project() { + for _ref in $MYOS_STACKS; do + myos_project_name "$(myos_scope "$_ref")" "$USER" "$ENV" "$(myos_first_app)" return 0 done } diff --git a/lib/naming.sh b/lib/naming.sh index f25cc0b..0155520 100644 --- a/lib/naming.sh +++ b/lib/naming.sh @@ -1,4 +1,5 @@ #shellcheck shell=sh +# shellcheck disable=SC3028 # HOSTNAME is a myos variable, set by bin/myos # naming: compose project name, service name, networks, user identity. # # Ported from make/apps/def.docker.mk (COMPOSE_PROJECT_NAME, COMPOSE_SERVICE_NAME), @@ -49,8 +50,6 @@ myos_project_name() { [ -n "${DOCKER_COMPOSE_PROJECT_NAME:-}" ] && { printf '%s' "$DOCKER_COMPOSE_PROJECT_NAME"; return 0; } case $_scope in host) - # HOSTNAME is set by lib/config.sh, not inherited from the shell - # shellcheck disable=SC3028 printf '%s' "${HOST_COMPOSE_PROJECT_NAME:-${HOSTNAME:-localhost}}"; return 0 ;; user) if [ -n "${USER_COMPOSE_PROJECT_NAME:-}" ]; then printf '%s' "$USER_COMPOSE_PROJECT_NAME" diff --git a/spec/golden/DELTAS.md b/spec/golden/DELTAS.md index b8407e2..61b1d17 100644 --- a/spec/golden/DELTAS.md +++ b/spec/golden/DELTAS.md @@ -1,8 +1,33 @@ # Intentional differences between the legacy make engine and the bash CLI Golden expectations in `expected/` are recorded from the legacy engine -(`git tag legacy-1.0-beta`). When the CLI intentionally behaves differently, -the case gets an override in `expected.cli/.txt` and a line here. +(git tag `legacy-1.0-beta`). When the CLI intentionally behaves differently the +case gets an override in `expected.cli/.txt` and a line here. +`make test-golden MYOS_ENGINE=cli` checks the CLI against those overrides. + +## Shape of the output + +| what | legacy | cli | +|---|---|---| +| sub-make line | every command is preceded by the recursive `make ... docker-compose-up STACK=...` it re-enters | no recursion, so no such line | +| compose invocation | `docker --log-level=error compose --ansi=auto -f ... -p ...` | `docker compose -f ... -p ... --project-directory ` | +| several stacks in one project | one `docker compose up` per stack, each with the full file list, so N stacks meant N identical calls | a single call per project | +| network creation | `sh -c docker network create >/dev/null 2>&1` on every up | `docker network create `, only when the network is missing | +| unknown command | prints a warning and exits 0 | prints an error and exits 2 | +| unknown stack | silently resolves to nothing and exits 0 | exits 3 with the search path | + +## Values + +| what | legacy | cli | why | +|---|---|---|---| +| `APP` in wrapper mode | `myos`, the framework directory itself | the stack, or the directory being run | the legacy value described the framework, not the thing being deployed. The real `up` path already passed `APP_NAME=` to its sub-make, so the CLI matches what actually ran; only the `print-` target disagreed. | +| `COMPOSE_PROJECT_NAME` for a catalogue stack in wrapper mode | `-myos-` for every stack | `--` | same reason: two different stacks shared one project name when printed, but not when run | +| `COMPOSE_PROJECT_NAME` default order | `--` | `--` | environments are shared across apps, so the environment reads better in the middle. `MYOS_PROJECT_FORMAT=user-app-env` restores the old order and is what `myos migrate pin` writes into existing deployments. | +| compose files of the current directory | ignored in wrapper mode: only a `STACK` was ever loaded | loaded, as a stack named after the directory | this is the point of unifying the two modes | +| overlay order for several suffixes | the order the `COMPOSE_FILE_*` variables happened to be declared in | sorted by suffix name | a compose overlay wins over the ones before it, so the order has to be predictable rather than depend on where a variable was set | +| framework overlays | `stack/myos/*.yml` | `share/compose/*.yml` | the catalogue moved to myos-stacks; these files stay with the framework | + +## Tag helpers | case | delta | why | |---|---|---| diff --git a/spec/golden/cases.txt b/spec/golden/cases.txt index 97b5e99..67ca9c5 100644 --- a/spec/golden/cases.txt +++ b/spec/golden/cases.txt @@ -1,4 +1,7 @@ # name | fixture | args +# +# `help` is deliberately absent: it renders the comments of the Makefile, so it +# would break on every edit to a dev target rather than on a change of behaviour. host-print-project | host-project | print-COMPOSE_PROJECT_NAME STACK=host/consul host-print-compose-file | host-project | print-COMPOSE_FILE STACK=host/consul host-print-stack-dir | host-project | print-STACK_DIR STACK=host/consul @@ -54,7 +57,6 @@ cat-nginx-www-dns | app-nogit | print-COMPOSE_FILE STACK=host/ cat-nginx-project | app-nogit | print-COMPOSE_PROJECT_NAME STACK=host/nginx cat-unknown-stack | app-nogit | print-COMPOSE_FILE STACK=doesnotexist cat-unknown-target | app-nogit | doesnotexist -misc-help | app-nogit | help inc-app-print-project | app-git | @make print-COMPOSE_PROJECT_NAME inc-app-print-compose-file | app-git | @make print-COMPOSE_FILE inc-app-print-app | app-git | @make print-APP diff --git a/spec/golden/expected.cli/app-config.txt b/spec/golden/expected.cli/app-config.txt new file mode 100644 index 0000000..ce9dc41 --- /dev/null +++ b/spec/golden/expected.cli/app-config.txt @@ -0,0 +1,2 @@ +docker compose -f @WD@/docker-compose.yml -f @WD@/docker-compose.local.yml -f @WD@/docker/docker-compose.yml -f @MYOS@/share/compose/networks.yml -p tester-wd-local --project-directory @WD@ config +[exit 0] diff --git a/spec/golden/expected.cli/app-down.txt b/spec/golden/expected.cli/app-down.txt new file mode 100644 index 0000000..bfc7c72 --- /dev/null +++ b/spec/golden/expected.cli/app-down.txt @@ -0,0 +1,2 @@ +docker compose -f @WD@/docker-compose.yml -f @WD@/docker-compose.local.yml -f @WD@/docker/docker-compose.yml -f @MYOS@/share/compose/networks.yml -p tester-wd-local --project-directory @WD@ down +[exit 0] diff --git a/spec/golden/expected.cli/app-print-app.txt b/spec/golden/expected.cli/app-print-app.txt new file mode 100644 index 0000000..44a64c2 --- /dev/null +++ b/spec/golden/expected.cli/app-print-app.txt @@ -0,0 +1,2 @@ +APP wd +[exit 0] diff --git a/spec/golden/expected.cli/app-print-compose-file.txt b/spec/golden/expected.cli/app-print-compose-file.txt new file mode 100644 index 0000000..3169415 --- /dev/null +++ b/spec/golden/expected.cli/app-print-compose-file.txt @@ -0,0 +1,2 @@ +COMPOSE_FILE @WD@/docker-compose.yml @WD@/docker-compose.local.yml @WD@/docker/docker-compose.yml @MYOS@/share/compose/networks.yml +[exit 0] diff --git a/spec/golden/expected.cli/app-print-project.txt b/spec/golden/expected.cli/app-print-project.txt new file mode 100644 index 0000000..80d492a --- /dev/null +++ b/spec/golden/expected.cli/app-print-project.txt @@ -0,0 +1,2 @@ +COMPOSE_PROJECT_NAME tester-wd-local +[exit 0] diff --git a/spec/golden/expected.cli/app-print-repository.txt b/spec/golden/expected.cli/app-print-repository.txt new file mode 100644 index 0000000..b0a90d3 --- /dev/null +++ b/spec/golden/expected.cli/app-print-repository.txt @@ -0,0 +1,2 @@ +DOCKER_REPOSITORY tester/wd/local +[exit 0] diff --git a/spec/golden/expected.cli/app-print-service-name.txt b/spec/golden/expected.cli/app-print-service-name.txt new file mode 100644 index 0000000..5811287 --- /dev/null +++ b/spec/golden/expected.cli/app-print-service-name.txt @@ -0,0 +1,2 @@ +COMPOSE_SERVICE_NAME tester-wd-local +[exit 0] diff --git a/spec/golden/expected.cli/app-print-stack.txt b/spec/golden/expected.cli/app-print-stack.txt new file mode 100644 index 0000000..e9f31d3 --- /dev/null +++ b/spec/golden/expected.cli/app-print-stack.txt @@ -0,0 +1,2 @@ +STACK ./ +[exit 0] diff --git a/spec/golden/expected.cli/app-run.txt b/spec/golden/expected.cli/app-run.txt new file mode 100644 index 0000000..5995550 --- /dev/null +++ b/spec/golden/expected.cli/app-run.txt @@ -0,0 +1,26 @@ +ERROR: unknown command: run +Usage: myos [options] [stack...] [VAR=value...] [-- args...] + +Options: + -C DIR work in DIR instead of the current directory + -e ENV environment (default: local, or ENV from the config) + -H HOSTS run on remote hosts instead (comma separated, or "all") + -n, --dry-run print the commands instead of running them + -v, --verbose show what myos does + -d, --debug show every command + -h, --help this help + +Commands: + up down start stop restart recreate manage the containers of a stack + ps logs config exec run inspect and enter them + ls [--groups] list the stacks myos can see + env [VAR...] show resolved variables + doctor check the installation + version print the myos version + +Stacks: + myos up the stack of the current directory + myos up host a group, expanded from host=... in a .env or .mk + myos up host/fabio a single stack + myos up postgres:9.6 a versioned stack +[exit 2] diff --git a/spec/golden/expected.cli/app-scale.txt b/spec/golden/expected.cli/app-scale.txt new file mode 100644 index 0000000..0b56706 --- /dev/null +++ b/spec/golden/expected.cli/app-scale.txt @@ -0,0 +1,26 @@ +ERROR: unknown command: scale +Usage: myos [options] [stack...] [VAR=value...] [-- args...] + +Options: + -C DIR work in DIR instead of the current directory + -e ENV environment (default: local, or ENV from the config) + -H HOSTS run on remote hosts instead (comma separated, or "all") + -n, --dry-run print the commands instead of running them + -v, --verbose show what myos does + -d, --debug show every command + -h, --help this help + +Commands: + up down start stop restart recreate manage the containers of a stack + ps logs config exec run inspect and enter them + ls [--groups] list the stacks myos can see + env [VAR...] show resolved variables + doctor check the installation + version print the myos version + +Stacks: + myos up the stack of the current directory + myos up host a group, expanded from host=... in a .env or .mk + myos up host/fabio a single stack + myos up postgres:9.6 a versioned stack +[exit 2] diff --git a/spec/golden/expected.cli/app-up-env-master.txt b/spec/golden/expected.cli/app-up-env-master.txt new file mode 100644 index 0000000..98bfe83 --- /dev/null +++ b/spec/golden/expected.cli/app-up-env-master.txt @@ -0,0 +1,4 @@ +docker network create tester-master +docker network create testhost +docker compose -f @WD@/docker-compose.yml -f @WD@/docker/docker-compose.yml -f @MYOS@/share/compose/networks.yml -p tester-wd-master --project-directory @WD@ up -d +[exit 0] diff --git a/spec/golden/expected.cli/app-up.txt b/spec/golden/expected.cli/app-up.txt new file mode 100644 index 0000000..6f95200 --- /dev/null +++ b/spec/golden/expected.cli/app-up.txt @@ -0,0 +1,4 @@ +docker network create tester-local +docker network create testhost +docker compose -f @WD@/docker-compose.yml -f @WD@/docker-compose.local.yml -f @WD@/docker/docker-compose.yml -f @MYOS@/share/compose/networks.yml -p tester-wd-local --project-directory @WD@ up -d +[exit 0] diff --git a/spec/golden/expected.cli/cat-drone-env-vars.txt b/spec/golden/expected.cli/cat-drone-env-vars.txt new file mode 100644 index 0000000..bf1080f --- /dev/null +++ b/spec/golden/expected.cli/cat-drone-env-vars.txt @@ -0,0 +1,2 @@ +ENV_VARS +[exit 0] diff --git a/spec/golden/expected.cli/cat-drone-version.txt b/spec/golden/expected.cli/cat-drone-version.txt new file mode 100644 index 0000000..6e0f762 --- /dev/null +++ b/spec/golden/expected.cli/cat-drone-version.txt @@ -0,0 +1,2 @@ +COMPOSE_FILE @HOME@/.local/share/myos/stack/drone/drone.yml @HOME@/.local/share/myos/stack/drone/drone.1.6.yml @MYOS@/share/compose/networks.yml +[exit 0] diff --git a/spec/golden/expected.cli/cat-group-default-up.txt b/spec/golden/expected.cli/cat-group-default-up.txt new file mode 100644 index 0000000..993e167 --- /dev/null +++ b/spec/golden/expected.cli/cat-group-default-up.txt @@ -0,0 +1,7 @@ +docker network create tester-local +docker network create testhost +docker compose -f @HOME@/.local/share/myos/stack/postgres/postgres.yml -f @HOME@/.local/share/myos/stack/postgres/postgres.local.yml -f @MYOS@/share/compose/networks.yml -p tester-postgres-local --project-directory @HOME@/.local/share/myos/stack/postgres up -d +docker network create tester-local +docker network create testhost +docker compose -f @HOME@/.local/share/myos/stack/redis/redis.yml -f @MYOS@/share/compose/networks.yml -p tester-redis-local --project-directory @HOME@/.local/share/myos/stack/redis up -d +[exit 0] diff --git a/spec/golden/expected.cli/cat-group-testing-up.txt b/spec/golden/expected.cli/cat-group-testing-up.txt new file mode 100644 index 0000000..91abc65 --- /dev/null +++ b/spec/golden/expected.cli/cat-group-testing-up.txt @@ -0,0 +1,7 @@ +docker network create tester-local +docker network create testhost +docker compose -f @HOME@/.local/share/myos/stack/drone/drone.yml -f @MYOS@/share/compose/networks.yml -p tester-drone-local --project-directory @HOME@/.local/share/myos/stack/drone up -d +docker network create tester-local +docker network create testhost +docker compose -f @HOME@/.local/share/myos/stack/redis/redis.yml -f @MYOS@/share/compose/networks.yml -p tester-redis-local --project-directory @HOME@/.local/share/myos/stack/redis up -d +[exit 0] diff --git a/spec/golden/expected.cli/cat-nginx-www-dns.txt b/spec/golden/expected.cli/cat-nginx-www-dns.txt new file mode 100644 index 0000000..4c99442 --- /dev/null +++ b/spec/golden/expected.cli/cat-nginx-www-dns.txt @@ -0,0 +1,2 @@ +COMPOSE_FILE @HOME@/.local/share/myos/stack/host/nginx.yml @HOME@/.local/share/myos/stack/host/nginx.dns.yml @HOME@/.local/share/myos/stack/host/nginx.www.yml @MYOS@/share/compose/networks.yml @MYOS@/share/compose/volumes.dns.local.yml @MYOS@/share/compose/volumes.www.local.yml +[exit 0] diff --git a/spec/golden/expected.cli/cat-postgres-project.txt b/spec/golden/expected.cli/cat-postgres-project.txt new file mode 100644 index 0000000..b2d3d7d --- /dev/null +++ b/spec/golden/expected.cli/cat-postgres-project.txt @@ -0,0 +1,2 @@ +COMPOSE_PROJECT_NAME tester-postgres-local +[exit 0] diff --git a/spec/golden/expected.cli/cat-postgres-up.txt b/spec/golden/expected.cli/cat-postgres-up.txt new file mode 100644 index 0000000..7842989 --- /dev/null +++ b/spec/golden/expected.cli/cat-postgres-up.txt @@ -0,0 +1,4 @@ +docker network create tester-local +docker network create testhost +docker compose -f @HOME@/.local/share/myos/stack/postgres/postgres.yml -f @HOME@/.local/share/myos/stack/postgres/postgres.local.yml -f @MYOS@/share/compose/networks.yml -p tester-postgres-local --project-directory @HOME@/.local/share/myos/stack/postgres up -d +[exit 0] diff --git a/spec/golden/expected.cli/cat-postgres-version.txt b/spec/golden/expected.cli/cat-postgres-version.txt new file mode 100644 index 0000000..d54c9cd --- /dev/null +++ b/spec/golden/expected.cli/cat-postgres-version.txt @@ -0,0 +1,2 @@ +COMPOSE_FILE @HOME@/.local/share/myos/stack/postgres/postgres.yml @HOME@/.local/share/myos/stack/postgres/postgres.local.yml @HOME@/.local/share/myos/stack/postgres/postgres.9.6.yml @MYOS@/share/compose/networks.yml +[exit 0] diff --git a/spec/golden/expected.cli/cat-unknown-target.txt b/spec/golden/expected.cli/cat-unknown-target.txt new file mode 100644 index 0000000..97c37a3 --- /dev/null +++ b/spec/golden/expected.cli/cat-unknown-target.txt @@ -0,0 +1,26 @@ +ERROR: unknown command: doesnotexist +Usage: myos [options] [stack...] [VAR=value...] [-- args...] + +Options: + -C DIR work in DIR instead of the current directory + -e ENV environment (default: local, or ENV from the config) + -H HOSTS run on remote hosts instead (comma separated, or "all") + -n, --dry-run print the commands instead of running them + -v, --verbose show what myos does + -d, --debug show every command + -h, --help this help + +Commands: + up down start stop restart recreate manage the containers of a stack + ps logs config exec run inspect and enter them + ls [--groups] list the stacks myos can see + env [VAR...] show resolved variables + doctor check the installation + version print the myos version + +Stacks: + myos up the stack of the current directory + myos up host a group, expanded from host=... in a .env or .mk + myos up host/fabio a single stack + myos up postgres:9.6 a versioned stack +[exit 2] diff --git a/spec/golden/expected.cli/host-config.txt b/spec/golden/expected.cli/host-config.txt new file mode 100644 index 0000000..0b5f136 --- /dev/null +++ b/spec/golden/expected.cli/host-config.txt @@ -0,0 +1,2 @@ +docker compose -f @WD@/stack/host/fabio.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host config +[exit 0] diff --git a/spec/golden/expected.cli/host-down-group.txt b/spec/golden/expected.cli/host-down-group.txt new file mode 100644 index 0000000..a8bf586 --- /dev/null +++ b/spec/golden/expected.cli/host-down-group.txt @@ -0,0 +1,2 @@ +docker compose -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @WD@/stack/host/registrator.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host down +[exit 0] diff --git a/spec/golden/expected.cli/host-exec.txt b/spec/golden/expected.cli/host-exec.txt new file mode 100644 index 0000000..a4d10a9 --- /dev/null +++ b/spec/golden/expected.cli/host-exec.txt @@ -0,0 +1,26 @@ +ERROR: unknown command: exec +Usage: myos [options] [stack...] [VAR=value...] [-- args...] + +Options: + -C DIR work in DIR instead of the current directory + -e ENV environment (default: local, or ENV from the config) + -H HOSTS run on remote hosts instead (comma separated, or "all") + -n, --dry-run print the commands instead of running them + -v, --verbose show what myos does + -d, --debug show every command + -h, --help this help + +Commands: + up down start stop restart recreate manage the containers of a stack + ps logs config exec run inspect and enter them + ls [--groups] list the stacks myos can see + env [VAR...] show resolved variables + doctor check the installation + version print the myos version + +Stacks: + myos up the stack of the current directory + myos up host a group, expanded from host=... in a .env or .mk + myos up host/fabio a single stack + myos up postgres:9.6 a versioned stack +[exit 2] diff --git a/spec/golden/expected.cli/host-logs.txt b/spec/golden/expected.cli/host-logs.txt new file mode 100644 index 0000000..3c6c6d5 --- /dev/null +++ b/spec/golden/expected.cli/host-logs.txt @@ -0,0 +1,2 @@ +docker compose -f @WD@/stack/host/consul.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host logs --follow --tail=100 +[exit 0] diff --git a/spec/golden/expected.cli/host-print-app.txt b/spec/golden/expected.cli/host-print-app.txt new file mode 100644 index 0000000..c3b0bd7 --- /dev/null +++ b/spec/golden/expected.cli/host-print-app.txt @@ -0,0 +1,2 @@ +APP consul +[exit 0] diff --git a/spec/golden/expected.cli/host-print-env-vars.txt b/spec/golden/expected.cli/host-print-env-vars.txt new file mode 100644 index 0000000..bf1080f --- /dev/null +++ b/spec/golden/expected.cli/host-print-env-vars.txt @@ -0,0 +1,2 @@ +ENV_VARS +[exit 0] diff --git a/spec/golden/expected.cli/host-print-stack-dir.txt b/spec/golden/expected.cli/host-print-stack-dir.txt new file mode 100644 index 0000000..1fca156 --- /dev/null +++ b/spec/golden/expected.cli/host-print-stack-dir.txt @@ -0,0 +1,2 @@ +STACK_DIR +[exit 0] diff --git a/spec/golden/expected.cli/host-ps.txt b/spec/golden/expected.cli/host-ps.txt new file mode 100644 index 0000000..8a44a14 --- /dev/null +++ b/spec/golden/expected.cli/host-ps.txt @@ -0,0 +1,2 @@ +docker compose -f @WD@/stack/host/consul.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host ps +[exit 0] diff --git a/spec/golden/expected.cli/host-stack-host-config.txt b/spec/golden/expected.cli/host-stack-host-config.txt new file mode 100644 index 0000000..64c2727 --- /dev/null +++ b/spec/golden/expected.cli/host-stack-host-config.txt @@ -0,0 +1,2 @@ +docker compose -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @WD@/stack/host/registrator.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host config +[exit 0] diff --git a/spec/golden/expected.cli/host-target.txt b/spec/golden/expected.cli/host-target.txt new file mode 100644 index 0000000..730fab1 --- /dev/null +++ b/spec/golden/expected.cli/host-target.txt @@ -0,0 +1,2 @@ +ERROR: no stack given, and no compose file in @WD@ +[exit 2] diff --git a/spec/golden/expected.cli/host-up-consul.txt b/spec/golden/expected.cli/host-up-consul.txt new file mode 100644 index 0000000..c110b67 --- /dev/null +++ b/spec/golden/expected.cli/host-up-consul.txt @@ -0,0 +1,4 @@ +docker network create tester-local +docker network create testhost +docker compose -f @WD@/stack/host/consul.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host up -d +[exit 0] diff --git a/spec/golden/expected.cli/host-up-group.txt b/spec/golden/expected.cli/host-up-group.txt new file mode 100644 index 0000000..c03fa35 --- /dev/null +++ b/spec/golden/expected.cli/host-up-group.txt @@ -0,0 +1,4 @@ +docker network create tester-local +docker network create testhost +docker compose -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @WD@/stack/host/registrator.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host up -d +[exit 0] diff --git a/spec/golden/expected.cli/host-up-two.txt b/spec/golden/expected.cli/host-up-two.txt new file mode 100644 index 0000000..a95d1b3 --- /dev/null +++ b/spec/golden/expected.cli/host-up-two.txt @@ -0,0 +1,4 @@ +docker network create tester-local +docker network create testhost +docker compose -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host up -d +[exit 0] diff --git a/spec/golden/expected.cli/nogit-print-app.txt b/spec/golden/expected.cli/nogit-print-app.txt new file mode 100644 index 0000000..44a64c2 --- /dev/null +++ b/spec/golden/expected.cli/nogit-print-app.txt @@ -0,0 +1,2 @@ +APP wd +[exit 0] diff --git a/spec/golden/expected.cli/nogit-print-project.txt b/spec/golden/expected.cli/nogit-print-project.txt new file mode 100644 index 0000000..80d492a --- /dev/null +++ b/spec/golden/expected.cli/nogit-print-project.txt @@ -0,0 +1,2 @@ +COMPOSE_PROJECT_NAME tester-wd-local +[exit 0] diff --git a/spec/golden/expected.cli/nogit-up.txt b/spec/golden/expected.cli/nogit-up.txt new file mode 100644 index 0000000..ee2a528 --- /dev/null +++ b/spec/golden/expected.cli/nogit-up.txt @@ -0,0 +1,4 @@ +docker network create tester-local +docker network create testhost +docker compose -f @WD@/docker-compose.yml -f @MYOS@/share/compose/networks.yml -p tester-wd-local --project-directory @WD@ up -d +[exit 0] diff --git a/spec/golden/expected/misc-help.txt b/spec/golden/expected/misc-help.txt deleted file mode 100644 index 4ffd64e..0000000 --- a/spec/golden/expected/misc-help.txt +++ /dev/null @@ -1,52 +0,0 @@ -Usage: -make [target] - -Targets: -test Run unit + golden tests -test-unit Run unit tests only -test-golden Run golden tests only (MYOS_ENGINE=legacy|cli) -test-integration Run tests needing a real docker daemon -golden-record Re-record golden expectations from the legacy engine -lint shellcheck all shell sources -help This help -attach Attach to docker SERVICE -bootstrap Configure system -build Build application docker images -clean Clean application and docker stuffs -config View application docker compose file -connect Connect to docker SERVICE -deploy Deploy application dockers -down Remove application dockers -exec Exec command in docker SERVICE -install Install application -logs Display application dockers logs -rebuild Rebuild application dockers images -reinstall Reinstall application -release Create release VERSION -restart Restart application -run Run a command in a new docker -scale Scale SERVICE application to NUM dockers -shutdown Shutdown all dockers -start Start application dockers -stop Stop application dockers -tests Test application -up Create application dockers -update Update application files -upgrade Upgrade application -ssh Connect to first remote host - -Context: -ENV local -ENV_PATH @WD@ -DOCKER_MACHINE x86_64 -DOCKER_SOCKET_LOCATION /var/run/docker.sock -DOCKER_SYSTEM Linux -DOMAIN example.test -APP myos -APPS @APPS@ -BRANCH @BRANCH@ -VERSION @VERSION@ -RELEASE -COMPOSE_FILE @MYOS@/share/compose/networks.yml -DOCKER_REPOSITORY tester/myos/local -[exit 0] diff --git a/spec/golden/record.sh b/spec/golden/record.sh index c1d2d25..08c07f0 100755 --- a/spec/golden/record.sh +++ b/spec/golden/record.sh @@ -3,6 +3,7 @@ # Usage: spec/golden/record.sh [case-name ...] set -u here=$(cd "$(dirname "$0")" && pwd) +# shellcheck source=spec/support/run.sh . "$here/../support/run.sh" MYOS_ROOT=${MYOS_ROOT:-$(cd "$here/../.." && pwd)} only="$*" diff --git a/spec/support/run.sh b/spec/support/run.sh index cb7e4c1..9692b89 100644 --- a/spec/support/run.sh +++ b/spec/support/run.sh @@ -63,7 +63,10 @@ myos_run_engine() { make -esC "$MYOS_ROOT" MYOS=. WORKDIR="$_sb/wd" "$@" 2>&1); _rc=$? ;; cli) + # MYOS_PROJECT_FORMAT pins the legacy naming so that the goldens compare + # resolution, not naming; the new default is covered by the unit tests. _out=$(cd "$_sb/wd" && env -i $(myos_hermetic_env "$_sb") MYOS_CONF=/dev/null \ + MYOS_PROJECT_FORMAT=user-app-env \ "$MYOS_ROOT/bin/myos" -C "$_sb/wd" "$@" 2>&1); _rc=$? ;; *) echo "unknown engine $_engine" >&2; return 2 ;;