Skip to content

🤖 Fix CI E2E harness bugs and shell compatibility issues#555

Merged
sffc merged 1 commit into
mainfrom
fix-harness-ci
Jun 26, 2026
Merged

🤖 Fix CI E2E harness bugs and shell compatibility issues#555
sffc merged 1 commit into
mainfrom
fix-harness-ci

Conversation

@sffc

@sffc sffc commented Jun 26, 2026

Copy link
Copy Markdown
Member

This PR fixes several issues in the E2E test harness that were causing CI failures and preventing some tests from running:

  1. EXIT Trap Exit Code Pollution: Fixes the EXIT trap in generateDataAndRun.sh to append || true to the kill command, preventing exit code pollution when the monitor is already dead.
  2. Shell Compatibility (NVM Loading): Replaces source with . in all NVM loading commands in python generators and genData100.sh to ensure compatibility with dash (the default /bin/sh in Ubuntu CI). This finally enables list_fmt, rdt_fmt, segmenter, and datetime_fmt tests to run in CI (they were silently failing to generate data before).
  3. Logging Format Bug: Fixes mismatched format string bugs in message_fmt2.py and datetime_fmt.py logging calls to prevent TypeErrors during error reporting.
  4. Cleanup: Removes dead code in relativedatetime_fmt.py and fixes a redundant assignment typo in list_fmt.py.

These fixes stabilize the CI harness and ensure all tests are actually executed.

This commit fixes several issues in the E2E test harness that were causing CI failures and preventing some tests from running:
1. Fixes the EXIT trap in generateDataAndRun.sh to append '|| true' to the kill command, preventing exit code pollution when the monitor is already dead.
2. Replaces 'source' with '.' in all NVM loading commands in python generators and genData100.sh to ensure compatibility with 'dash' (the default /bin/sh in Ubuntu CI).
3. Fixes a mismatched format string bug in message_fmt2.py and datetime_fmt.py logging calls to prevent TypeErrors during error reporting.
4. Removes dead code in relativedatetime_fmt.py and fixes a redundant assignment typo in list_fmt.py.

Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 26, 2026 04:13

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the source command with . for sourcing nvm.sh across multiple scripts and generator files, fixes several logging format strings, removes redundant code, and cleans up a duplicate assignment. The review feedback recommends using the NVM_DIR environment variable with a fallback instead of hardcoding ~/.nvm/nvm.sh to support custom NVM installation paths (particularly in CI environments). Additionally, it is suggested to use logging.exception instead of logging.error in datetime_fmt.py to automatically capture tracebacks during file-saving failures.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +167 to 168
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; npm ci; node generators/datetime_gen.js %s %s' % (
nvm_version, nvm_version, '-run_limit', self.run_limit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Instead of hardcoding ~/.nvm/nvm.sh, use the NVM_DIR environment variable (with a fallback to ~/.nvm). In CI, NVM_DIR is configured to $HOME/.config/nvm (see generateDataAndRun.sh line 56), so hardcoding ~/.nvm/nvm.sh will fail to locate NVM.

Suggested change
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; npm ci; node generators/datetime_gen.js %s %s' % (
nvm_version, nvm_version, '-run_limit', self.run_limit)
generate_command = '. "${NVM_DIR:-$HOME/.nvm}/nvm.sh"; nvm install %s; nvm use %s --silent; npm ci; node generators/datetime_gen.js %s %s' % (
nvm_version, nvm_version, '-run_limit', self.run_limit)

Comment on lines +37 to 38
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Instead of hardcoding ~/.nvm/nvm.sh, use the NVM_DIR environment variable (with a fallback to ~/.nvm) to support custom NVM installation paths (such as $HOME/.config/nvm used in CI).

Suggested change
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))
generate_command = '. "${NVM_DIR:-$HOME/.nvm}/nvm.sh"; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

Comment on lines +46 to 47
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Instead of hardcoding ~/.nvm/nvm.sh, use the NVM_DIR environment variable (with a fallback to ~/.nvm) to support custom NVM installation paths (such as $HOME/.config/nvm used in CI).

Suggested change
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))
generate_command = '. "${NVM_DIR:-$HOME/.nvm}/nvm.sh"; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

Comment on lines +38 to 39
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Instead of hardcoding ~/.nvm/nvm.sh, use the NVM_DIR environment variable (with a fallback to ~/.nvm) to support custom NVM installation paths (such as $HOME/.config/nvm used in CI).

Suggested change
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))
generate_command = '. "${NVM_DIR:-$HOME/.nvm}/nvm.sh"; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

self.saveJsonFile(dt_verify_path, verify_obj, indent=2)
except BaseException as err:
logging.error('!!! %s: Failure to save file %s', err, )
logging.error('!!! %s: Failure to save files: %s and %s', err, dt_test_path, dt_verify_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using logging.exception is preferred over logging.error when logging from within an except block. It automatically captures and logs the traceback, which is extremely helpful for debugging failures in CI.

Suggested change
logging.error('!!! %s: Failure to save files: %s and %s', err, dt_test_path, dt_verify_path)
logging.exception('Failure to save files: %s and %s', dt_test_path, dt_verify_path)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to stabilize the CI E2E test harness by fixing shell/NVM loading issues, preventing CI-exit-status pollution, and correcting logging-format bugs that can crash generators during error reporting.

Changes:

  • Adjusts NVM initialization commands to improve shell compatibility in multiple Node-based data generators and helper scripts.
  • Fixes EXIT trap behavior in the harness script to avoid altering the script’s final exit code.
  • Corrects Python logging format-string mismatches and removes/cleans up minor generator code issues.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
testgen/generators/segmenter.py Updates NVM load command used to run the Node-based segmenter generator.
testgen/generators/relativedatetime_fmt.py Removes dead code and updates NVM load command for the Node-based relative datetime generator.
testgen/generators/message_fmt2.py Fixes logging format string mismatch during schema validation error reporting.
testgen/generators/list_fmt.py Updates NVM load command and fixes a redundant assignment typo.
testgen/generators/datetime_fmt.py Fixes a logging format bug and updates NVM load command for Node-based generation.
generateDataAndRun.sh Prevents EXIT-trap kill failure from polluting the script’s exit status.
genData100.sh Replaces source with . for NVM loading in the helper script.
Comments suppressed due to low confidence (1)

testgen/generators/segmenter.py:42

  • subprocess.run(..., shell=True) uses /bin/sh by default (typically dash on Ubuntu CI), but nvm expects a bash-compatible shell. Also, hard-coding ~/.nvm/nvm.sh can break CI because generateDataAndRun.sh can set NVM_DIR to a different location (e.g. $HOME/.config/nvm). Run under bash explicitly, respect $NVM_DIR, and use check=True so failures don’t get silently ignored.
        generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
                           (nvm_version, nvm_version, ' '.join(exec_list))

        logging.debug('Running this command: %s', generate_command)
        result = subprocess.run(generate_command, shell=True)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to +41
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

logging.debug('Running this command: %s', generate_command)
result = result = subprocess.run(generate_command, shell=True)
result = subprocess.run(generate_command, shell=True)
Comment on lines 166 to 170
nvm_version = icu_nvm_versions[self.icu_version]
generate_command = 'source ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; npm ci; node generators/datetime_gen.js %s %s' % (
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; npm ci; node generators/datetime_gen.js %s %s' % (
nvm_version, nvm_version, '-run_limit', self.run_limit)

result = subprocess.run(generate_command, shell=True)
Comment on lines 45 to 49
nvm_version = icu_nvm_versions[self.icu_version]
generate_command = 'source ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
generate_command = '. ~/.nvm/nvm.sh; nvm install %s; nvm use %s --silent; %s' %\
(nvm_version, nvm_version, ' '.join(exec_list))

result = subprocess.run(generate_command, shell=True)
@sffc

sffc commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

The other code review comments are good but they are all pre-existing.

@sffc sffc merged commit ef12038 into main Jun 26, 2026
11 checks passed
@sffc sffc deleted the fix-harness-ci branch June 26, 2026 04:54
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.

2 participants