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 Tony Hutter
parent 20b8936c1a
commit 2c861ebcde
2 changed files with 36 additions and 13 deletions
+21 -12
View File
@@ -3,13 +3,16 @@
""" """
Determine the CI type based on the change list and commit message. 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' - 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 - the files changed are not in the list of specified directories, and
- all commit messages do not contain 'ZFS-CI-Type: (full|linux|freebsd)' - 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 import sys
@@ -58,9 +61,10 @@ if __name__ == '__main__':
head, base = sys.argv[1:3] head, base = sys.argv[1:3]
def output_type(type, reason): def output_type(type, source, reason):
print(f'{prog}: will run {type} CI: {reason}', file=sys.stderr) print(f'{prog}: will run {type} CI ({source}): {reason}',
print(type) file=sys.stderr)
print(f'{type} {source}')
sys.exit(0) sys.exit(0)
# check last (HEAD) commit message # check last (HEAD) commit message
@@ -70,7 +74,8 @@ if __name__ == '__main__':
for line in last_commit_message_raw.stdout.decode().splitlines(): for line in last_commit_message_raw.stdout.decode().splitlines():
if line.strip().lower() == 'zfs-ci-type: quick': 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 # check all commit messages
all_commit_message_raw = subprocess.run([ all_commit_message_raw = subprocess.run([
@@ -84,11 +89,14 @@ if __name__ == '__main__':
if line.startswith('ZFS-CI-Commit:'): if line.startswith('ZFS-CI-Commit:'):
commit_ref = line.lstrip('ZFS-CI-Commit:').rstrip() commit_ref = line.lstrip('ZFS-CI-Commit:').rstrip()
if line.strip().lower() == 'zfs-ci-type: freebsd': 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': 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': 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 # check changed files
changed_files_raw = subprocess.run([ changed_files_raw = subprocess.run([
@@ -104,9 +112,10 @@ if __name__ == '__main__':
for r in FULL_RUN_REGEX: for r in FULL_RUN_REGEX:
if r.match(f): if r.match(f):
output_type( output_type(
'full', 'full', 'auto',
f'changed file "{f}" matches pattern "{r.pattern}"' f'changed file "{f}" matches pattern "{r.pattern}"'
) )
# catch-all # catch-all
output_type('quick', 'no changed file matches full CI patterns') output_type('quick', 'auto',
'no changed file matches full CI patterns')
+15 -1
View File
@@ -35,12 +35,13 @@ jobs:
id: os id: os
run: | run: |
ci_type="default" ci_type="default"
ci_source="auto"
# determine CI type when running on PR # determine CI type when running on PR
if ${{ github.event_name == 'pull_request' }}; then if ${{ github.event_name == 'pull_request' }}; then
head=${{ github.event.pull_request.head.sha }} head=${{ github.event.pull_request.head.sha }}
base=${{ github.event.pull_request.base.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 fi
case "$ci_type" in case "$ci_type" in
@@ -59,6 +60,19 @@ jobs:
;; ;;
esac 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 if ${{ github.event.inputs.fedora_kernel_ver != '' }}; then
# They specified a custom kernel version for Fedora. # They specified a custom kernel version for Fedora.
# Use only Fedora runners. # Use only Fedora runners.