diff --git a/CHANGELOG.md b/CHANGELOG.md index 98415cbf..54f5d168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,6 +116,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 values now always override the runtime configuration, which overrides the process environment, whatever case each one uses. Unix hosts keep case-sensitive names. +- Use the shell exit status in GitHub Action outputs when a signal stops the CLI. - Count Codex input tokens once. Codex reports cached tokens as part of `input_tokens`, and skill-up added them again, so a run with a high cache hit rate showed close to twice its real input. Codex `input_tokens` in diff --git a/action/main.py b/action/main.py index 686855e8..394c0a8c 100644 --- a/action/main.py +++ b/action/main.py @@ -503,6 +503,9 @@ def main(): flush=True) result = subprocess.run(argv, env=run_env, cwd=target_dir) exit_code = result.returncode + if exit_code < 0: + # Python represents signal termination as -N; shells report 128 + N. + exit_code = 128 - exit_code try: with open(os.path.join(output_dir, "skill-up-exit-code"), "w") as f: f.write(str(exit_code)) diff --git a/action/main_test.py b/action/main_test.py index 8d745b6e..45d111f3 100644 --- a/action/main_test.py +++ b/action/main_test.py @@ -16,6 +16,26 @@ class ActionConfigurationContractTest(unittest.TestCase): + def test_main_reports_shell_status_after_signal(self): + inputs = ACTION.parse_inputs([]) + with tempfile.TemporaryDirectory() as workspace: + output = pathlib.Path(workspace) / "outputs" + with ( + mock.patch.object(ACTION, "parse_inputs", return_value=inputs), + mock.patch.object(ACTION.shutil, "which", return_value="/bin/skill-up"), + mock.patch.object(ACTION, "_run"), + mock.patch.object(ACTION, "get_skill_up_version", return_value=None), + mock.patch.object(ACTION, "command_supports_explicit_provider", return_value=False), + mock.patch.object(ACTION.subprocess, "run", return_value=SimpleNamespace(returncode=-15)), + mock.patch.dict(ACTION.os.environ, {"GITHUB_WORKSPACE": workspace, "GITHUB_OUTPUT": str(output)}, clear=True), + self.assertRaises(SystemExit) as exit_context, + ): + ACTION.main() + self.assertEqual(exit_context.exception.code, 143) + self.assertIn("exit-code=143", output.read_text().splitlines()) + marker = pathlib.Path(workspace) / "skill-up-workspace" / "skill-up-exit-code" + self.assertEqual(marker.read_text(), "143") + def test_main_composes_opencode_argv_and_environment(self): inputs = SimpleNamespace( engine="opencode",