diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13f5a2e80..1a92e658c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -594,6 +594,7 @@ jobs: run: flutter pub get - name: Isolate system temp with a LiteRT-LM cache canary + id: litert_canary_seed shell: bash run: bash tool/ci/litert_lm_temp_canary.sh seed @@ -601,7 +602,7 @@ jobs: run: xargs dart test -p vm -j 1 --exclude-tags local-only < tool/ci/markdown_test_suites.txt - name: Check the LiteRT-LM cache canary - if: ${{ !cancelled() }} + if: ${{ !cancelled() && steps.litert_canary_seed.outcome == 'success' }} shell: bash run: bash tool/ci/litert_lm_temp_canary.sh check @@ -675,6 +676,7 @@ jobs: "llama.cpp-$ref/models/templates" - name: Isolate system temp with a LiteRT-LM cache canary + id: litert_canary_seed shell: bash run: bash tool/ci/litert_lm_temp_canary.sh seed @@ -703,7 +705,7 @@ jobs: run: dart test -p vm -j 1 --exclude-tags local-only ${{ needs.changes.outputs.coverage == 'true' && '--coverage=coverage' || '' }} --file-reporter=json:.dart_tool/test_events.jsonl ${{ steps.shard.outputs.files }} - name: Check the LiteRT-LM cache canary - if: ${{ !cancelled() }} + if: ${{ !cancelled() && steps.litert_canary_seed.outcome == 'success' }} shell: bash run: bash tool/ci/litert_lm_temp_canary.sh check @@ -1245,6 +1247,7 @@ jobs: --output .dart_tool/test_models/stories15M.gguf - name: Isolate system temp with a LiteRT-LM cache canary + id: litert_canary_seed shell: bash run: bash tool/ci/litert_lm_temp_canary.sh seed @@ -1266,7 +1269,7 @@ jobs: run: dart test -p vm -j 1 --exclude-tags local-only --file-reporter=json:.dart_tool/test_events.jsonl ${{ steps.shard.outputs.files }} - name: Check the LiteRT-LM cache canary - if: ${{ !cancelled() && (steps.shard.outcome == 'success' || steps.shard.outcome == 'failure') }} + if: ${{ !cancelled() && steps.litert_canary_seed.outcome == 'success' }} shell: bash run: bash tool/ci/litert_lm_temp_canary.sh check diff --git a/test/ci/test_hf_space_deploy.py b/test/ci/test_hf_space_deploy.py index 2662561de..0dce3b06f 100644 --- a/test/ci/test_hf_space_deploy.py +++ b/test/ci/test_hf_space_deploy.py @@ -857,8 +857,13 @@ def test_cli_redacts_unhandled_sdk_initialization_traceback(self): from test_hf_space_deploy import ROOT +class FatalSdkError(BaseException): + pass + +failure = FatalSdkError if sys.argv[1] == 'FatalSdkError' else RuntimeError + def make_client(**kwargs): - raise RuntimeError('SDK initialization failed https://inert.invalid/asset?sig=AUDIT_INIT') + raise failure('SDK initialization failed https://inert.invalid/asset?sig=AUDIT_INIT') script = ROOT / 'tool/ci/hf_space_deploy.py' sys.argv = [str(script), '--repo', 'org/space', '--folder', 'build', @@ -866,15 +871,19 @@ def make_client(**kwargs): with mock.patch.dict(sys.modules, {'huggingface_hub': mock.Mock(HfApi=make_client)}): runpy.run_path(str(script), run_name='__main__') ''' - result = subprocess.run( - [sys.executable, '-B', '-c', runner], cwd=Path(__file__).parent, - env={**os.environ, 'HF_TOKEN': 'mock-token'}, - capture_output=True, text=True, timeout=15) - self.assertEqual(result.returncode, 1, result.stderr) - self.assertIn('Traceback (most recent call last)', result.stderr) - self.assertIn('RuntimeError: SDK initialization failed', result.stderr) - self.assertNotIn('AUDIT_INIT', result.stderr) - self.assertNotIn('AUDIT_INIT', result.stdout) + for failure in ('RuntimeError', 'FatalSdkError'): + with self.subTest(failure=failure): + result = subprocess.run( + [sys.executable, '-B', '-c', runner, failure], + cwd=Path(__file__).parent, + env={**os.environ, 'HF_TOKEN': 'mock-token'}, + capture_output=True, text=True, timeout=15) + self.assertEqual(result.returncode, 1, result.stderr) + self.assertIn('Traceback (most recent call last)', result.stderr) + self.assertIn(f'{failure}: SDK initialization failed', result.stderr) + for stream in (result.stdout, result.stderr): + self.assertNotIn('inert.invalid', stream) + self.assertNotIn('AUDIT_INIT', stream) def test_cli_redacts_an_interrupted_upload(self): runner = ''' diff --git a/test/ci/test_preview_sweep.py b/test/ci/test_preview_sweep.py index e40a2b81d..181535f0e 100644 --- a/test/ci/test_preview_sweep.py +++ b/test/ci/test_preview_sweep.py @@ -54,6 +54,19 @@ def test_only_exact_ids_for_closed_prs_are_listed(self): ]) api.delete_repo.assert_not_called() + def test_matrix_is_capped_at_the_oldest_256_closed_prs(self): + api = Mock() + numbers = range(260, 0, -1) + api.list_spaces.return_value = [ + SimpleNamespace(id=f'leehack/llamadart-chat-pr-{number}') + for number in numbers + ] + responses = [self.response(200, number=number) for number in numbers] + with patch.object(sweep.subprocess, 'run', side_effect=responses): + self.assertEqual(sweep.list_closed_previews(api), + [str(number) for number in range(1, 257)]) + api.delete_repo.assert_not_called() + def test_empty_matrix_is_written_to_workflow_output(self): api = Mock() api.list_spaces.return_value = [] diff --git a/test/unit/tooling/ci_workflow_selection_test.dart b/test/unit/tooling/ci_workflow_selection_test.dart index d3b2844b4..7808b3b1e 100644 --- a/test/unit/tooling/ci_workflow_selection_test.dart +++ b/test/unit/tooling/ci_workflow_selection_test.dart @@ -2288,23 +2288,15 @@ runs: expect(seed, greaterThanOrEqualTo(0), reason: job); expect(tests, greaterThan(seed), reason: job); expect(check, greaterThan(tests), reason: job); - expect((steps[seed] as Map).containsKey('if'), isFalse, reason: job); - if (job == 'test-other-os') { - final shard = steps[seed + 1] as Map; - expect(shard['id'], 'shard'); - expect(shard['name'], 'Select shard test files'); - // The shard step starts only after the canary is seeded successfully. - for (final step in [steps[seed] as Map, shard]) { - expect(step.containsKey('if'), isFalse); - expect(step.containsKey('continue-on-error'), isFalse); - } - expect( - steps[check]['if'], - r"${{ !cancelled() && (steps.shard.outcome == 'success' || steps.shard.outcome == 'failure') }}", - ); - } else { - expect(steps[check]['if'], r'${{ !cancelled() }}', reason: job); - } + final seedStep = steps[seed] as Map; + expect(seedStep['id'], 'litert_canary_seed', reason: job); + expect(seedStep.containsKey('if'), isFalse, reason: job); + expect(seedStep.containsKey('continue-on-error'), isFalse, reason: job); + expect( + steps[check]['if'], + r"${{ !cancelled() && steps.litert_canary_seed.outcome == 'success' }}", + reason: job, + ); } }); diff --git a/tool/ci/preview_sweep.py b/tool/ci/preview_sweep.py index 7dcb1e0f7..7f20546c5 100644 --- a/tool/ci/preview_sweep.py +++ b/tool/ci/preview_sweep.py @@ -56,7 +56,8 @@ def list_closed_previews(api): candidates[match[1]] = space.id except Exception as error: raise SweepFailed('list_spaces', NAMESPACE, error) from None - return [number for number, space in candidates.items() if pr_is_closed(number, space)] + closed = [number for number, space in candidates.items() if pr_is_closed(number, space)] + return sorted(closed, key=int)[:256] def delete_closed_preview(api, number):