Skip to content

[IMP] cli: rewrite help, fix bugs, modernize codebase#227

Open
nhomar wants to merge 8 commits intomainfrom
main-study-cli-v2
Open

[IMP] cli: rewrite help, fix bugs, modernize codebase#227
nhomar wants to merge 8 commits intomainfrom
main-study-cli-v2

Conversation

@nhomar
Copy link
Member

@nhomar nhomar commented Feb 14, 2026

Rationale

This PR improves the travis2docker CLI and codebase through 8 focused commits:

Why these changes?

  1. CLI help was unusable — terse single-line descriptions with no examples, no defaults, and no grouping made the tool impossible to discover without reading source code.

  2. Two bugs caused silent failures:

    • 20-run.sh had duplicate -itP flags (hardcoded in template + CLI default)
    • --build-env-args VAR1 VAR2 silently discarded all but the first variable due to x[0] extraction
  3. README was misleading — documented a flat output structure (/1, /2) that didn't match the actual versioned directory layout (2_7/env_1_job_1), and omitted .t2d.yml support and Ed25519 SSH key recommendations.

  4. Dead CI config.travis.yml was left behind after migrating to GitHub Actions, confusing contributors.

  5. Python 2 vestiges — dead try/except encode('utf-8') blocks, universal=1 wheel config, and Python 3.5 as default version (EOL since 2020).

  6. Debug noisegit_run.py used bare print() calls that polluted stdout with no way to silence them.

  7. Help strings had wrong defaults--runs-at-the-end-script documented (default: none) but code injected "sleep 2"; --build-env-args behaves differently in DeployV mode (undocumented).

Commits

# Tag Description
1 [IMP] Rewrite all 19 CLI help strings with examples and defaults
2 [FIX] Remove duplicate -itP flags in 20-run.sh template
3 [FIX] Flatten build_env_args correctly (was dropping values)
4 [IMP] Correct README output paths, SSH keys, .t2d.yml docs
5 [REM] Delete obsolete .travis.yml (using GitHub Actions)
6 [REF] Remove Py2 vestiges, update default Python to 3.10
7 [REF] Replace debug print() with logging.debug()
8 [IMP] Document legacy image default and DeployV specifics

Supersedes

This PR supersedes the previous main-study-cli PR with improved commit messages that include proper rationale following the project's commit conventions.

Before this change, the CLI help output used terse, single-line
descriptions with no examples, no default-value documentation, and
no logical grouping. This made the tool difficult to discover and
use without reading the source code.

This commit rewrites all 19 argument help strings with:
- Clear multi-line descriptions explaining each option's purpose
- Consistent "(default: ...)" annotations on every argument
- Logical grouping by category (Docker, Paths, Git, Build, Run,
  Hooks, DeployV)
- A program-level description and usage examples in the epilog
- RawDescriptionHelpFormatter to preserve formatting

No logic changes — only cosmetic help text improvements.
Before this fix, the generated 20-run.sh contained duplicate -itP
flags: one hardcoded in the template and another injected via the
--run-extra-args CLI default ("-itP -e LANG=C.UTF-8"). This caused
Docker to receive "-itP -itP -e LANG=C.UTF-8" on every run, which
is harmless but confusing when debugging generated scripts.

The root cause was that the template hardcoded "-itP" independently
of the CLI default. Remove the hardcoded flags from the template so
the generated script only contains what --run-extra-args provides,
avoiding duplication and making the output predictable.
Before this fix, passing multiple variables in a single invocation
(e.g. --build-env-args VAR1 VAR2) silently discarded all but the
first value. The list comprehension used `x[0]` to extract only the
first element of each sub-list produced by argparse's append action.

This caused missing ARG/ENV lines in the generated Dockerfile,
leading to broken builds when multiple build-time variables were
needed. The fix changes the comprehension to properly flatten all
sub-lists: `[arg for sublist in ... for arg in sublist]`.
The README documented a flat output structure (/1, /2) that did not
match the actual code behavior. The code generates directories named
by Python version and environment/job combination (e.g. 2_7/env_1_job_1).
This confused users who couldn't find their generated scripts.

This commit:
- Correct the output path examples to match compute_dockerfile()
- Document .t2d.yml as an alternative config file name (already
  supported by the code but never mentioned in docs)
- Clarify that both SSH and HTTPS URLs are accepted
- Recommend Ed25519 SSH keys (matching set_authorized_key() which
  checks id_ed25519.pub first) and keep RSA as a legacy fallback
- Note that 10-build.sh uses --pull, so manual docker pull is
  optional
travis2docker no longer uses Travis CI for its own builds — the
project migrated to GitHub Actions (.github/workflows/) which has
been the active CI pipeline since the move to Vauxoo/travis2docker.

The .travis.yml file was left behind and is misleading: it suggests
the project still uses Travis CI, but builds have been running on
GitHub Actions for years. Removing it avoids confusion for new
contributors and eliminates a maintenance burden for dead config.
The codebase contained remnants from the Python 2 era that are
unreachable on Python 3:

- travis2docker.py: 5 try/except blocks calling .encode('utf-8')
  before text-mode file.write(). On Python 3, str.encode() returns
  bytes, which always raises TypeError on text-mode write — the
  except branch was the only path ever executing. Remove the dead
  try blocks entirely.

- setup.cfg: `universal = 1` declared the wheel as py2/py3
  compatible, but the project requires Python >=3.6. Change to
  `universal = 0` so bdist_wheel produces a py3-only wheel.

- git_run.py: remove `from __future__ import print_function`
  (implicit in Python 3).

Additionally, update the default Python version from 3.5 to 3.10
in _python_version_env(). Python 3.5 reached end-of-life in 2020
and Odoo 16+ targets 3.10+, which is the primary use case for this
tool.
The run() method used bare print() calls to dump every git command
and its argument list to stdout. This caused noisy output during
normal usage, with no way to silence it short of redirecting stdout.

Replace both print() calls with _logger.debug() so the git command
tracing is only visible when the user explicitly enables debug-level
logging (e.g. via logging.basicConfig(level=logging.DEBUG)).

Also remove the now-unnecessary `print-used` pylint disable
directive that was only needed because of these print statements.
Several CLI help strings were misleading or incomplete, causing
users to waste time debugging unexpected behavior:

- --docker-image: the default (vauxoo/odoo-80-image-shippable-auto)
  is a legacy Odoo 8.0 image that surprises users targeting modern
  Odoo versions. Add an explicit NOTE about this.

- --runs-at-the-end-script: help said "(default: none)" but the
  code in Travis2Docker.__init__() actually injects "sleep 2" when
  the argument is omitted. This mismatch caused confusion when
  containers stayed alive unexpectedly. Fix the help to show the
  true default and explain how to disable it.

- --build-env-args: in DeployV mode these variables are rendered as
  shell exports (not Docker ARG/ENV pairs), which is a non-obvious
  behavioral difference. Document this divergence.

- --deployv: the auto-constructed image name pattern from
  variables.sh was undocumented. Add the naming pattern so users
  know what to expect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant