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
2 changes: 1 addition & 1 deletion .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ jobs:
# CI_ADMISSION_SEED_DERIVED_DATA=0 turns it off.
- name: Adopt the nightly DerivedData seed
id: seed-derived-data
if: steps.reuse-products.outputs.hit != 'true' && steps.persistent-restore.outputs.hit != 'true' && github.event_name == 'pull_request' && vars.CI_ADMISSION_SEED_DERIVED_DATA != '0' && (inputs.cache_backend != 'default' && inputs.cache_backend || vars.CI_CACHE_BACKEND || 'r2') == 'r2'
if: steps.reuse-products.outputs.hit != 'true' && steps.persistent-restore.outputs.hit != 'true' && github.event_name == 'pull_request' && (vars.CI_ADMISSION_SEED_DERIVED_DATA || '1') != '0' && (inputs.cache_backend != 'default' && inputs.cache_backend || vars.CI_CACHE_BACKEND || 'r2') == 'r2'
continue-on-error: true
timeout-minutes: 8
env:
Expand Down
17 changes: 16 additions & 1 deletion tests/test_seed_derived_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Compile admission may start from the nightly seed's DerivedData, never be judged by it."""
import json
import os
import re
from pathlib import Path
import sys
import tarfile
Expand Down Expand Up @@ -225,9 +226,23 @@ def test_adoption_is_optional_and_limited_to_pull_requests(self):
_, adopt = named(admission, "Adopt the nightly DerivedData seed")
self.assertIs(adopt.get("continue-on-error"), True)
self.assertIn("github.event_name == 'pull_request'", adopt["if"])
self.assertIn("vars.CI_ADMISSION_SEED_DERIVED_DATA != '0'", adopt["if"])
# An unset repository variable is null, and Actions compares null with
# '0' as the numbers 0 and 0. A bare `vars.X != '0'` is therefore false
# while X is unset, which turned adoption off everywhere. Unset has to
# mean on, so the kill switch gets a non-zero default first.
self.assertIn("(vars.CI_ADMISSION_SEED_DERIVED_DATA || '1') != '0'", adopt["if"])
self.assertIn("timeout-minutes", adopt)

def test_no_workflow_compares_a_bare_variable_with_zero(self):
bare = re.compile(r"vars\.[A-Z0-9_]+\s*[!=]=\s*'0'")
offenders = [
f"{path.name}:{number}"
for path in sorted((ROOT / ".github/workflows").glob("*.yml"))
for number, line in enumerate(path.read_text().splitlines(), 1)
if bare.search(line)
]
self.assertEqual(offenders, [], "an unset variable is null, which equals '0'; give it a default first")


if __name__ == "__main__":
unittest.main()
Loading