feat: 添加 Nvidia-Driver-580 占位包及发布流水线 #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Static Checks | |
| permissions: | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v6 | |
| - name: Check UTF-8 text files | |
| run: | | |
| python3 - <<'PY' | |
| from pathlib import Path | |
| paths = [ | |
| Path("readme.md"), | |
| Path("docs/usage.md"), | |
| Path("docs/maintenance.md"), | |
| Path("CLAUDE.md"), | |
| Path("package_kernel_space/manifest"), | |
| Path("package_user_space/manifest"), | |
| Path("package_fake_offical_580/manifest"), | |
| Path("scripts/patch-nvidia-grid-kernel-binary.py"), | |
| ] | |
| failed = False | |
| for path in paths: | |
| try: | |
| text = path.read_text(encoding="utf-8") | |
| except UnicodeDecodeError as exc: | |
| print(f"{path}: invalid UTF-8: {exc}") | |
| failed = True | |
| continue | |
| if "???" in text or "\ufffd" in text: | |
| print(f"{path}: possible mojibake marker found") | |
| failed = True | |
| raise SystemExit(1 if failed else 0) | |
| PY | |
| - name: Check package version consistency | |
| run: | | |
| python3 - <<'PY' | |
| import re | |
| from pathlib import Path | |
| workflow = Path(".github/workflows/test_release.yml").read_text(encoding="utf-8") | |
| version_pairs = { | |
| (this_pack_nvidia_driver_version, this_pack_version) | |
| for this_pack_version, this_pack_nvidia_driver_version in re.findall( | |
| r'"this_pack_version": "([^"]+)",\n\s+"this_pack_nvidia_driver_version": "([^"]+)"', | |
| workflow, | |
| flags=re.M, | |
| ) | |
| } | |
| if not version_pairs: | |
| print("Unable to read this_pack_version and this_pack_nvidia_driver_version pairs from test_release.yml") | |
| raise SystemExit(1) | |
| expected_packages = {} | |
| for this_pack_nvidia_driver_version, this_pack_version in version_pairs: | |
| previous = expected_packages.setdefault(this_pack_nvidia_driver_version, this_pack_version) | |
| if previous != this_pack_version: | |
| print(f"{this_pack_nvidia_driver_version}: multiple package versions found: {previous}, {this_pack_version}") | |
| raise SystemExit(1) | |
| paths = [ | |
| Path("readme.md"), | |
| Path("docs/usage.md"), | |
| Path("docs/maintenance.md"), | |
| Path("CLAUDE.md"), | |
| Path(".github/workflows/test_release.yml"), | |
| Path("package_fake_offical_580/manifest"), | |
| ] | |
| failed = False | |
| for path in paths: | |
| text = path.read_text(encoding="utf-8") | |
| for this_pack_nvidia_driver_version, this_pack_version in sorted(expected_packages.items()): | |
| version_pattern = re.compile(rf'{re.escape(this_pack_nvidia_driver_version)}-\d+(?![\d.])') | |
| for match in sorted(set(version_pattern.findall(text))): | |
| if match != this_pack_version: | |
| print(f"{path}: package version {match} does not match {this_pack_nvidia_driver_version} package version {this_pack_version}") | |
| failed = True | |
| raise SystemExit(1 if failed else 0) | |
| PY | |
| - name: Check artifact naming contract | |
| run: | | |
| python3 - <<'PY' | |
| import re | |
| from pathlib import Path | |
| expression_open = "$" + "{{" | |
| contracts = { | |
| Path(".github/workflows/kernel_space.yml"): { | |
| "nvidia.ko-" + expression_open + " inputs.this_pack_version }}-" + expression_open + " env.kernel_name }}.tgz": 3, | |
| "nvidia.ko-" + expression_open + " inputs.this_pack_version }}-chroot-amd64.tgz": 3, | |
| }, | |
| Path(".github/workflows/user_space.yml"): { | |
| "nvidia.user-" + expression_open + " inputs.this_pack_version }}-" + expression_open + " inputs.manifest_platform }}.tgz": 3, | |
| }, | |
| Path(".github/workflows/fake_official_580.yml"): { | |
| "Nvidia-Driver-580.tgz": 4, | |
| }, | |
| } | |
| failed = False | |
| for path, expected_names in contracts.items(): | |
| text = path.read_text(encoding="utf-8") | |
| for name, expected_count in expected_names.items(): | |
| actual_count = text.count(name) | |
| if actual_count != expected_count: | |
| print(f"{path}: expected {expected_count} occurrences of {name}, found {actual_count}") | |
| failed = True | |
| release_workflow = Path(".github/workflows/test_release.yml").read_text(encoding="utf-8") | |
| release_asset_templates = set(re.findall( | |
| r'^\s+"package_name": (.+),$', | |
| release_workflow, | |
| flags=re.M, | |
| )) | |
| expected_release_asset_templates = { | |
| 'f"nvidia.ko-{driver[\'this_pack_version\']}-{kernel}.tgz"', | |
| 'f"nvidia.ko-{driver[\'this_pack_version\']}-chroot-amd64.tgz"', | |
| 'f"nvidia.user-{driver[\'this_pack_version\']}-x86.tgz"', | |
| '"Nvidia-Driver-580.tgz"', | |
| } | |
| if release_asset_templates != expected_release_asset_templates: | |
| print(f"Unexpected release asset templates: {sorted(release_asset_templates)}") | |
| failed = True | |
| matrix_package_name = expression_open + " matrix.package_name }}" | |
| if release_workflow.count(matrix_package_name) != 3: | |
| print("Release download, rename, and upload must use matrix.package_name") | |
| failed = True | |
| title_arg = '--title "' + expression_open + ' steps.vars.outputs.release_title }}"' | |
| if release_workflow.count(title_arg) != 2: | |
| print("Release create/edit must use the timestamp title without a repository-name prefix") | |
| failed = True | |
| legacy_filename = re.compile( | |
| r'appstore[.]driver[.]gpu[.]nvidia[.](?:user-|ko-(?!chroot-build[.]failed))' | |
| ) | |
| checked_paths = [ | |
| Path(".github/workflows/kernel_space.yml"), | |
| Path(".github/workflows/user_space.yml"), | |
| Path(".github/workflows/fake_official_580.yml"), | |
| Path(".github/workflows/AGENTS.md"), | |
| Path("readme.md"), | |
| Path("docs/usage.md"), | |
| Path("docs/maintenance.md"), | |
| Path("CLAUDE.md"), | |
| ] | |
| for path in checked_paths: | |
| if legacy_filename.search(path.read_text(encoding="utf-8")): | |
| print(f"{path}: legacy artifact filename prefix found") | |
| failed = True | |
| raise SystemExit(1 if failed else 0) | |
| PY | |
| - name: Check Python syntax | |
| run: | | |
| python3 -m py_compile scripts/patch-nvidia-grid-kernel-binary.py | |
| - name: Check shell syntax | |
| run: | | |
| find package_kernel_space/cmd package_user_space/cmd package_fake_offical_580/cmd -maxdepth 1 -type f -print0 | | |
| while IFS= read -r -d '' file; do | |
| first_line="$(head -n 1 "$file")" | |
| if [ "$first_line" = "#!/bin/bash" ] || [ "$first_line" = "#!/bin/sh" ]; then | |
| echo "bash -n $file" | |
| bash -n "$file" | |
| fi | |
| done |