Public Access
DEVX-48: fix: use heredoc syntax for multi-line $GITHUB_ENV values
Post-merge / detect-type (push) Successful in 6s
Post-merge / configure-repo (push) Successful in 7s
Post-merge / validate-commit-msg (push) Successful in 15s
Post-merge / release (push) Successful in 52s
Post-merge / vikunja (push) Successful in 14s
Post-merge / sync-wiki (push) Successful in 49s
Post-merge / badges (push) Successful in 1m8s
Post-merge / detect-type (push) Successful in 6s
Post-merge / configure-repo (push) Successful in 7s
Post-merge / validate-commit-msg (push) Successful in 15s
Post-merge / release (push) Successful in 52s
Post-merge / vikunja (push) Successful in 14s
Post-merge / sync-wiki (push) Successful in 49s
Post-merge / badges (push) Successful in 1m8s
This commit was merged in pull request #74.
This commit is contained in:
@@ -55,7 +55,12 @@ def _write_github_env(key: str, value: str) -> None:
|
|||||||
if not gh_env:
|
if not gh_env:
|
||||||
raise click.ClickException("GITHUB_ENV environment variable is not set")
|
raise click.ClickException("GITHUB_ENV environment variable is not set")
|
||||||
with open(gh_env, "a") as f: # noqa: PTH123
|
with open(gh_env, "a") as f: # noqa: PTH123
|
||||||
f.write(f"{key}={value}\n")
|
if "\n" in value:
|
||||||
|
# Multi-line values require the heredoc syntax in $GITHUB_ENV.
|
||||||
|
delimiter = "EOF"
|
||||||
|
f.write(f"{key}<<{delimiter}\n{value}\n{delimiter}\n")
|
||||||
|
else:
|
||||||
|
f.write(f"{key}={value}\n")
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
|||||||
@@ -101,6 +101,23 @@ class TestCli:
|
|||||||
assert "ASSIGNED_FILES=" in content
|
assert "ASSIGNED_FILES=" in content
|
||||||
assert "SKIP=false" in content
|
assert "SKIP=false" in content
|
||||||
|
|
||||||
|
def test_github_env_multiline_uses_heredoc(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
|
gh_file = tmp_path / "env.txt"
|
||||||
|
monkeypatch.setenv("GITHUB_ENV", str(gh_file))
|
||||||
|
for i in range(6):
|
||||||
|
(tmp_path / f"test_{i}.py").write_text("")
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(
|
||||||
|
main,
|
||||||
|
["--pattern", str(tmp_path / "test_*.py"), "--runner-index", "1", "--max-runners", "2", "--github-env"],
|
||||||
|
)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
content = gh_file.read_text()
|
||||||
|
# Multi-line values must use heredoc syntax to avoid corrupting $GITHUB_ENV
|
||||||
|
assert "ASSIGNED_FILES<<EOF" in content
|
||||||
|
assert content.count("EOF") >= 2
|
||||||
|
assert "SKIP=false" in content
|
||||||
|
|
||||||
def test_skip_if_excess(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
def test_skip_if_excess(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
gh_file = tmp_path / "env.txt"
|
gh_file = tmp_path / "env.txt"
|
||||||
monkeypatch.setenv("GITHUB_ENV", str(gh_file))
|
monkeypatch.setenv("GITHUB_ENV", str(gh_file))
|
||||||
|
|||||||
Reference in New Issue
Block a user