Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Make launcher CI pipeline failure handling explicit
thehobbit85f8bb8b1bbcb7
diff --git a/.github/scripts/tests/test_swift_test_jobs.py b/.github/scripts/tests/test_swift_test_jobs.pynew file mode 100644index 00000000..f9b93781--- /dev/null+++ b/.github/scripts/tests/test_swift_test_jobs.py@@ -0,0 +1,67 @@+"""Run the Swift CI steps with a plain bash runner so failures never depend on runner defaults."""+import os+from pathlib import Path+import re+import subprocess+import tempfile+import unittest++WORKFLOW = Path(__file__).resolve().parents[2] / 'workflows/tests.yml'+STEPS = (+ ('launcher', 'Release build', 'frontend', 'launcher-build.log'),+ ('launcher', 'Tests', 'frontend', 'launcher-tests.log'),+ ('engine-checks', 'iOS shell package (frontend-ios, swift test)', 'frontend-ios', 'shell-package-tests.log'),+)+++def step_script(job, name):+ lines = WORKFLOW.read_text().splitlines()+ start = lines.index(f' {job}:') + 1+ end = next((i for i in range(start, len(lines)) if re.match(r' [a-z][a-z-]*:', lines[i])), len(lines))+ step = lines.index(f' - name: {name}', start, end)+ body = lines.index(' run: |', step, end) + 1+ stop = next((i for i in range(body, end) if lines[i] and not lines[i].startswith(' ')), end)+ return '\n'.join(line[10:] for line in lines[body:stop])+++class SwiftTestJobs(unittest.TestCase):+ def run_step(self, step, swift_status, broken_log=False):+ job, name, directory, log_name = step+ with tempfile.TemporaryDirectory(prefix='nx-swift-ci-') as folder:+ root = Path(folder)+ cwd = root / directory+ cwd.mkdir()+ if broken_log:+ (root / 'logs' / log_name).mkdir(parents=True)+ # Exercise the real workflow body without installing Swift or inheriting pipefail.+ fake_swift = f'swift() {{ echo "synthetic swift $*"; return {swift_status}; }}\n'+ env = {key: value for key, value in os.environ.items() if key not in ('SHELLOPTS', 'BASHOPTS', 'BASH_ENV')}+ env['BASH_ENV'] = '/dev/null'+ result = subprocess.run(['/bin/bash', '-e', '-c', fake_swift + step_script(job, name)],+ cwd=cwd, env=env, capture_output=True, text=True)+ log = root / 'logs' / log_name+ return result, log.read_text() if log.is_file() else None++ def test_a_swift_failure_fails_each_step_and_keeps_the_log(self):+ for step in STEPS:+ with self.subTest(step=step[:2]):+ result, log = self.run_step(step, 7)+ self.assertEqual(result.returncode, 7, result.stdout + result.stderr)+ self.assertIn('synthetic swift', log)++ def test_successful_swift_commands_succeed_and_keep_the_log(self):+ for step in STEPS:+ with self.subTest(step=step[:2]):+ result, log = self.run_step(step, 0)+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertIn('synthetic swift', log)++ def test_a_log_write_failure_fails_each_step(self):+ for step in STEPS:+ with self.subTest(step=step[:2]):+ result, _ = self.run_step(step, 0, broken_log=True)+ self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)+++if __name__ == '__main__':+ unittest.main()diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex c3d12715..1996b30d 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -299,6 +299,7 @@ jobs:if: ${{ github.event_name != 'pull_request' }}working-directory: frontendrun: |+ set -o pipefailmkdir -p ../logsswift build -c release 2>&1 | tee ../logs/launcher-build.log# The opt-in tests (a real games folder, the README screenshots, the visual QA capture) skip without their variables; the process@@ -306,6 +307,7 @@ jobs:- name: Testsworking-directory: frontendrun: |+ set -o pipefailmkdir -p ../logsswift test 2>&1 | tee ../logs/launcher-tests.log- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2