diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c870a27bb..56c4bf95d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1820,6 +1820,31 @@ jobs: AIMEE_BIN='./build/aimee.exe' FORCE_MODE=selfcheck \ bash scripts/aimee-thin-client-smoke.sh + # Main still requires this context from the former Windows CMake job. + # Keep it backed by the shipping thin-client build and its Winsock smoke + # tests, without duplicating that build or retiring either check name. + windows-cmake: + name: windows-cmake + needs: [change-scope, windows-build] + if: ${{ always() }} + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - name: Require Windows CMake qualification + env: + WINDOWS_RESULT: ${{ needs.windows-build.result }} + SCOPE_RESULT: ${{ needs.change-scope.result }} + DOCS_ONLY: ${{ needs.change-scope.outputs.docs_only }} + run: | + if [ "$WINDOWS_RESULT" = success ]; then + echo "Windows CMake build and thin-client smoke tests passed" + elif [ "$WINDOWS_RESULT" = skipped ] && [ "$SCOPE_RESULT" = success ] && [ "$DOCS_ONLY" = true ]; then + echo "Windows build intentionally skipped for documentation-only changes" + else + echo "::error::Windows CMake qualification did not succeed: $WINDOWS_RESULT" + exit 1 + fi + macos-build: needs: change-scope # Shared native headers/build contracts also change on testing-target PRs. diff --git a/scripts/tests/test_windows_cmake_gate.py b/scripts/tests/test_windows_cmake_gate.py new file mode 100644 index 000000000..b13a57369 --- /dev/null +++ b/scripts/tests/test_windows_cmake_gate.py @@ -0,0 +1,51 @@ +"""Exercise the required Windows context against actual dependency outcomes.""" +import os +from pathlib import Path +import subprocess +import unittest + +import yaml + +ROOT = Path(__file__).resolve().parents[2] + + +class WindowsCMakeGateTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + workflow = yaml.load((ROOT / '.github/workflows/ci.yml').read_text(), + Loader=yaml.BaseLoader) + cls.gate = workflow['jobs']['windows-cmake'] + cls.script = cls.gate['steps'][0]['run'] + + def run_gate(self, windows, scope='success', docs_only='false'): + return subprocess.run(['bash', '-c', self.script], capture_output=True, + env=dict(os.environ, WINDOWS_RESULT=windows, + SCOPE_RESULT=scope, DOCS_ONLY=docs_only)) + + def test_required_context_depends_on_the_real_windows_job(self): + self.assertEqual(self.gate['name'], 'windows-cmake') + self.assertCountEqual(self.gate['needs'], ['change-scope', 'windows-build']) + self.assertEqual(self.gate['if'], '${{ always() }}') + env = self.gate['steps'][0]['env'] + self.assertEqual(env['WINDOWS_RESULT'], '${{ needs.windows-build.result }}') + self.assertEqual(env['SCOPE_RESULT'], '${{ needs.change-scope.result }}') + self.assertEqual(env['DOCS_ONLY'], '${{ needs.change-scope.outputs.docs_only }}') + + def test_successful_windows_build_qualifies(self): + self.assertEqual(self.run_gate('success').returncode, 0) + + def test_failed_cancelled_or_unknown_build_never_qualifies(self): + for result in ('failure', 'cancelled', '', 'unknown'): + with self.subTest(result=result): + self.assertNotEqual(self.run_gate(result).returncode, 0) + + def test_skip_requires_a_successful_documentation_only_classification(self): + self.assertEqual(self.run_gate('skipped', docs_only='true').returncode, 0) + for scope, docs in (('success', 'false'), ('failure', 'true'), + ('cancelled', 'true'), ('', 'true'), ('success', '')): + with self.subTest(scope=scope, docs=docs): + self.assertNotEqual(self.run_gate('skipped', scope, docs).returncode, 0) + + +if __name__ == '__main__': + unittest.main()