Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/publish-pal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ jobs:
# that AltStore.json on main lists the same build (D-26). The release must exist already: the tool finds it
# by the version's tag and never creates one (D-19). The permissions come from the project, never from the
# encrypted variants (owner decision, 20-08): each bundle's CODE_SIGN_ENTITLEMENTS and INFOPLIST_FILE, held to
# project.pbxproj by test_workflows.py.
# project.pbxproj by test_workflows.py. The runner's /bin/bash is 3.2, where an empty array under `set -u` is
# unbound, so the dry-run flag expands only when it is set.
python3 "$PAL_PUBLISH_TOOL_PATH" publish \
--adp "$RUNNER_TEMP/adp" \
--repo "$GITHUB_REPOSITORY" \
Expand All @@ -213,7 +214,7 @@ jobs:
--info-plist App/Info.plist \
--info-plist ShareExtension/Info.plist \
--work "$RUNNER_TEMP/pal-publish" \
"${dry_run[@]}"
${dry_run[@]+"${dry_run[@]}"}
{
if [[ "$DRY_RUN" != "false" ]]; then
echo "### AltStore PAL $VERSION: dry run"
Expand Down
26 changes: 26 additions & 0 deletions actions-tool/tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,32 @@ def test_dry_run_is_passed_through(self):
self.assertRegex(self.run_text(self.job, "Publish to AltStore PAL"), r'"\$DRY_RUN" (==|!=) "?(true|false)"?')
self.assertNotIn("dry_run", json.dumps(self.process))

def test_the_publish_step_runs_in_the_runners_bash_with_and_without_dry_run(self):
# The macOS runner's /bin/bash is 3.2, where "${array[@]}" of an empty array under `set -u` stops the step
# with "unbound variable" before the tool runs: the 3.1.0 publish with dry_run off failed that way.
step = step_named(self.job, "Publish to AltStore PAL")
bash = "/bin/bash" if pathlib.Path("/bin/bash").exists() else shutil.which("bash")
with tempfile.TemporaryDirectory() as directory:
folder = pathlib.Path(directory)
tool = folder / "pal_publish.py"
arguments = folder / "arguments.json"
tool.write_text("import json, sys\n"
f"open({str(arguments)!r}, 'w').write(json.dumps(sys.argv[1:]))\n", encoding="utf-8")
for dry_run, expected in (("false", False), ("true", True)):
with self.subTest(dry_run=dry_run):
summary = folder / f"summary-{dry_run}.md"
result = subprocess.run(
[bash, "-e", "-c", step["run"]], capture_output=True, text=True, timeout=30,
env={"PATH": os.environ.get("PATH", ""), "PAL_PUBLISH_TOOL_PATH": str(tool),
"RUNNER_TEMP": str(folder), "GITHUB_REPOSITORY": "EhPanda-Team/EhPanda",
"RELEASE_NOTES_DIR": "./ReleaseNotes", "MARKETPLACE_ID": "1", "ADP_ID": "adp",
"VERSION": "3.1.0", "DRY_RUN": dry_run, "GITHUB_STEP_SUMMARY": str(summary)})
self.assertEqual(result.returncode, 0, result.stderr)
passed = json.loads(arguments.read_text(encoding="utf-8"))
self.assertEqual(passed[0], "publish")
self.assertEqual("--dry-run" in passed, expected)
self.assertIn("dry run" if expected else "published", summary.read_text(encoding="utf-8"))

def test_gh_gets_the_job_token_only(self):
step = step_named(self.job, "Publish to AltStore PAL")
self.assertEqual(step["env"]["GH_TOKEN"], "${{ github.token }}")
Expand Down
Loading