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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,15 @@ 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

- name: Run Markdown tests
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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
29 changes: 19 additions & 10 deletions test/ci/test_hf_space_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,24 +857,33 @@ 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',
'--commit-message', 'msg', '--delete-pattern', '*']
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 = '''
Expand Down
13 changes: 13 additions & 0 deletions test/ci/test_preview_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
26 changes: 9 additions & 17 deletions test/unit/tooling/ci_workflow_selection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
});

Expand Down
3 changes: 2 additions & 1 deletion tool/ci/preview_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading