CI: Support repository variable override for ZTS OS selection

Allow restricting ZTS OS targets by setting the vars.ZTS_OS_OVERRIDE
repository variable (e.g. '["debian13"]') to reduce shared runner
contention when running the full OS matrix is unnecessary. When unset,
the existing ci_type-based OS selection is used unchanged.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #18342
This commit is contained in:
Ameer Hamza 2026-03-20 00:21:45 +05:00 committed by GitHub
parent 3ee08abd2f
commit 4627c57f27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 13 deletions

View File

@ -3,13 +3,16 @@
"""
Determine the CI type based on the change list and commit message.
Prints "quick" if (explicity required by user):
Output format: "<type> <source>" where source is "manual" (from
ZFS-CI-Type commit tag) or "auto" (from file change heuristics).
Prints "quick manual" if:
- the *last* commit message contains 'ZFS-CI-Type: quick'
or if (heuristics):
or "quick auto" if (heuristics):
- the files changed are not in the list of specified directories, and
- all commit messages do not contain 'ZFS-CI-Type: (full|linux|freebsd)'
Otherwise prints "full".
Otherwise prints "full auto" (or "<type> manual" if explicitly requested).
"""
import sys
@ -58,9 +61,10 @@ if __name__ == '__main__':
head, base = sys.argv[1:3]
def output_type(type, reason):
print(f'{prog}: will run {type} CI: {reason}', file=sys.stderr)
print(type)
def output_type(type, source, reason):
print(f'{prog}: will run {type} CI ({source}): {reason}',
file=sys.stderr)
print(f'{type} {source}')
sys.exit(0)
# check last (HEAD) commit message
@ -70,7 +74,8 @@ if __name__ == '__main__':
for line in last_commit_message_raw.stdout.decode().splitlines():
if line.strip().lower() == 'zfs-ci-type: quick':
output_type('quick', f'requested by HEAD commit {head}')
output_type('quick', 'manual',
f'requested by HEAD commit {head}')
# check all commit messages
all_commit_message_raw = subprocess.run([
@ -84,11 +89,14 @@ if __name__ == '__main__':
if line.startswith('ZFS-CI-Commit:'):
commit_ref = line.lstrip('ZFS-CI-Commit:').rstrip()
if line.strip().lower() == 'zfs-ci-type: freebsd':
output_type('freebsd', f'requested by commit {commit_ref}')
output_type('freebsd', 'manual',
f'requested by commit {commit_ref}')
if line.strip().lower() == 'zfs-ci-type: linux':
output_type('linux', f'requested by commit {commit_ref}')
output_type('linux', 'manual',
f'requested by commit {commit_ref}')
if line.strip().lower() == 'zfs-ci-type: full':
output_type('full', f'requested by commit {commit_ref}')
output_type('full', 'manual',
f'requested by commit {commit_ref}')
# check changed files
changed_files_raw = subprocess.run([
@ -104,9 +112,10 @@ if __name__ == '__main__':
for r in FULL_RUN_REGEX:
if r.match(f):
output_type(
'full',
'full', 'auto',
f'changed file "{f}" matches pattern "{r.pattern}"'
)
# catch-all
output_type('quick', 'no changed file matches full CI patterns')
output_type('quick', 'auto',
'no changed file matches full CI patterns')

View File

@ -35,12 +35,13 @@ jobs:
id: os
run: |
ci_type="default"
ci_source="auto"
# determine CI type when running on PR
if ${{ github.event_name == 'pull_request' }}; then
head=${{ github.event.pull_request.head.sha }}
base=${{ github.event.pull_request.base.sha }}
ci_type=$(python3 .github/workflows/scripts/generate-ci-type.py $head $base)
read ci_type ci_source <<< "$(python3 .github/workflows/scripts/generate-ci-type.py $head $base)"
fi
case "$ci_type" in
@ -59,6 +60,19 @@ jobs:
;;
esac
# Repository-level override for OS selection.
# Set vars.ZTS_OS_OVERRIDE in repo settings to restrict targets
# (e.g. '["debian13"]' or '["debian13", "fedora42"]').
# Manual ZFS-CI-Type in commit messages bypasses the override.
if [ -n "${{ vars.ZTS_OS_OVERRIDE }}" ] && [ "$ci_source" != "manual" ]; then
override='${{ vars.ZTS_OS_OVERRIDE }}'
if echo "$override" | jq -e 'type == "array"' >/dev/null 2>&1; then
os_selection="$override"
else
echo "::warning::Invalid ZTS_OS_OVERRIDE, using default"
fi
fi
if ${{ github.event.inputs.fedora_kernel_ver != '' }}; then
# They specified a custom kernel version for Fedora.
# Use only Fedora runners.