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/actions/install_unix_deps/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion .github/copy-pr-bot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Configuration file for `copy-pr-bot` GitHub App
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Run CI tools unit tests
run: |
python -m pip install pytest pyyaml==6.0.3
python -m pip install pytest pyyaml==6.0.3 pathspec==0.12.1
# Standalone CI tool tests; skip repo-root conftest.py (imports cuda.pathfinder).
python -m pytest -v --noconftest ci/tools/tests

Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ jobs:

# PR workflows run from the merge revision; check out that same revision
# so their helper scripts and configuration stay in sync.
# check_spdx.py runs `git log -1 -- <file>` to find the year each file last
# changed (copyright-year enforcement), so it needs the full commit history.
# In a shallow clone every file looks like it was introduced by the tip
# commit, so each would be judged against the tip commit's year.
# blob:none keeps all commits and trees but skips historical file contents,
# which a path-limited `git log` does not read.
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 1
fetch-depth: 0
filter: blob:none
persist-credentials: false

- name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion ci/tools/guess_latest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand Down
195 changes: 195 additions & 0 deletions ci/tools/tests/test_check_spdx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Tests for the copyright-year rule in toolshed/check_spdx.py.

The rule must give the same answer however the hook is invoked (``git commit``,
``pre-commit run --all-files``, CI), so each test builds a throwaway git repository
with controlled commit dates and runs the script against it. Years are derived from
the current year so the tests do not expire.

python -m pytest ci/tools/tests/test_check_spdx.py -v --noconftest
"""

from __future__ import annotations

import datetime
import os
import shutil
import subprocess
import sys
from pathlib import Path

import pytest

pytest.importorskip("pathspec", reason="check_spdx.py requires pathspec")

REPO = Path(__file__).resolve().parents[3]
CHECKER = REPO / "toolshed" / "check_spdx.py"
LICENSE = REPO / "LICENSE"

CURRENT_YEAR = datetime.datetime.now(tz=datetime.UTC).year
SAMPLE = "toolshed/sample.py"

CONTENT = (
"# SPDX-FileCopyrightText: Copyright (c) {years} NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n"
"# SPDX-License-Identifier: Apache-2.0\n"
"\n"
"pass\n"
)


def git(repo, *args, year=None):
env = dict(os.environ)
env.update(
GIT_AUTHOR_NAME="Test",
GIT_AUTHOR_EMAIL="test@example.com",
GIT_COMMITTER_NAME="Test",
GIT_COMMITTER_EMAIL="test@example.com",
)
if year is not None:
date = f"{year}-06-15T12:00:00+0000"
env.update(GIT_AUTHOR_DATE=date, GIT_COMMITTER_DATE=date)
subprocess.run( # noqa: S603
["git", "-c", "commit.gpgsign=false", *args], # noqa: S607
cwd=repo,
env=env,
check=True,
capture_output=True,
)


def commit(repo, relpath, years, *, year):
path = repo / relpath
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(CONTENT.format(years=years), encoding="utf-8")
git(repo, "add", relpath)
git(repo, "commit", "-m", f"add {relpath}", year=year)
return path


def run_checker(repo, *args):
# The script reads LICENSE and runs git relative to the working directory,
# as pre-commit does from the repository root.
return subprocess.run( # noqa: S603
[sys.executable, str(CHECKER), *args, SAMPLE],
cwd=repo,
capture_output=True,
text=True,
check=False,
)


@pytest.fixture
def repo(tmp_path):
git(tmp_path, "init")
shutil.copy(LICENSE, tmp_path / "LICENSE")
git(tmp_path, "add", "LICENSE")
git(tmp_path, "commit", "-m", "init", year=CURRENT_YEAR - 5)
return tmp_path


@pytest.mark.agent_authored(model="claude-sonnet-5.5")
@pytest.mark.parametrize(
("commit_age", "copyright_age", "passes"),
[
# Not modified this year, so last year's copyright is still correct.
pytest.param(1, 1, True, id="untouched-since-last-year"),
# The bug in #2273: committed this year, nothing staged, stale copyright.
pytest.param(0, 1, False, id="committed-this-year-stale-copyright"),
],
)
def test_committed_file_is_checked_against_its_last_commit_year(repo, commit_age, copyright_age, passes):
commit(repo, SAMPLE, str(CURRENT_YEAR - copyright_age), year=CURRENT_YEAR - commit_age)

result = run_checker(repo)

assert (result.returncode == 0) is passes, result.stdout + result.stderr
assert ("OUTDATED" in result.stdout) is (not passes)


@pytest.mark.agent_authored(model="claude-sonnet-5.5")
def test_staged_edit_requires_current_year_and_fix_writes_it(repo):
# The `git commit` path: the edited file is staged when the hook runs.
path = commit(repo, SAMPLE, str(CURRENT_YEAR - 3), year=CURRENT_YEAR - 2)
path.write_text(path.read_text(encoding="utf-8") + "# edited\n", encoding="utf-8")
git(repo, "add", SAMPLE)

check = run_checker(repo)
assert check.returncode == 1, check.stdout + check.stderr
assert f"(expected '{CURRENT_YEAR}')" in check.stdout

# --fix reports that it changed something, as the hook always has.
fix = run_checker(repo, "--fix")
assert fix.returncode == 1, fix.stdout + fix.stderr
assert f"Copyright (c) {CURRENT_YEAR - 3}-{CURRENT_YEAR} " in path.read_text(encoding="utf-8")

# The rewrite is stable: a second run accepts the file.
assert run_checker(repo).returncode == 0


@pytest.mark.agent_authored(model="claude-sonnet-5.5")
def test_fix_of_clean_stale_file_survives_being_committed(repo):
# Stale relative to an old commit, with nothing staged (for example a manual
# `pre-commit run --all-files`).
path = commit(repo, SAMPLE, str(CURRENT_YEAR - 3), year=CURRENT_YEAR - 2)

fix = run_checker(repo, "--fix")
assert fix.returncode == 1, fix.stdout + fix.stderr
# Not the older last-commit year: committing the fix is a change made this year.
assert f"Copyright (c) {CURRENT_YEAR - 3}-{CURRENT_YEAR} " in path.read_text(encoding="utf-8")

git(repo, "add", SAMPLE)
git(repo, "commit", "-m", "fix copyright", year=CURRENT_YEAR)

# The fix must not demand another fix once it is part of this year's history.
assert run_checker(repo).returncode == 0


@pytest.mark.parametrize(
("date", "passes"),
[
pytest.param(f"{CURRENT_YEAR - 1}-12-31T23:30:00-0800", False, id="utc-year-after-recorded-year"),
pytest.param(f"{CURRENT_YEAR}-01-01T00:30:00+1400", True, id="utc-year-before-recorded-year"),
],
)
@pytest.mark.agent_authored(model="gpt-6")
def test_committed_file_uses_utc_year_across_new_year(repo, monkeypatch, date, passes):
monkeypatch.setenv("GIT_AUTHOR_DATE", date)
monkeypatch.setenv("GIT_COMMITTER_DATE", date)
commit(repo, SAMPLE, str(CURRENT_YEAR - 1), year=None)

result = run_checker(repo)

assert (result.returncode == 0) is passes, result.stdout + result.stderr
assert ("OUTDATED" in result.stdout) is (not passes)


@pytest.mark.agent_authored(model="gpt-6")
def test_signed_last_commit_with_show_signature_enabled(repo):
ssh_keygen = shutil.which("ssh-keygen")
if ssh_keygen is None:
pytest.skip("ssh-keygen is required to create a signed commit")

signing_key = repo / "signing_key"
subprocess.run( # noqa: S603
[ssh_keygen, "-q", "-t", "ed25519", "-N", "", "-f", str(signing_key)],
check=True,
capture_output=True,
)
allowed_signers = repo / "allowed_signers"
allowed_signers.write_text(
"test@example.com " + signing_key.with_suffix(".pub").read_text(encoding="utf-8"), encoding="utf-8"
)
git(repo, "config", "gpg.format", "ssh")
git(repo, "config", "user.signingkey", str(signing_key))
git(repo, "config", "gpg.ssh.allowedSignersFile", str(allowed_signers))
git(repo, "config", "log.showSignature", "true")
path = commit(repo, SAMPLE, str(CURRENT_YEAR), year=CURRENT_YEAR)
path.write_text(path.read_text(encoding="utf-8") + "# signed edit\n", encoding="utf-8")
git(repo, "add", SAMPLE)
git(repo, "-c", "commit.gpgsign=true", "commit", "-m", "signed edit", year=CURRENT_YEAR)

result = run_checker(repo)

assert result.returncode == 0, result.stdout + result.stderr
2 changes: 1 addition & 1 deletion cuda_core/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-License-Identifier: Apache-2.0

*******************************************************
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/cuda/core/_memory/_graph_memory_resource.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion cuda_core/cuda/core/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
2 changes: 1 addition & 1 deletion cuda_core/docs/source/_templates/autosummary/cyclass.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-License-Identifier: Apache-2.0

{{ fullname | escape | underline}}
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/docs/source/release.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-License-Identifier: Apache-2.0

Release Notes
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/docs/source/release/0.3.0-notes.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-License-Identifier: Apache-2.0

.. currentmodule:: cuda.core.experimental
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/docs/source/release/0.4.0-notes.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-License-Identifier: Apache-2.0

.. currentmodule:: cuda.core.experimental
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/docs/source/release/0.5.1-notes.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
.. SPDX-License-Identifier: Apache-2.0

.. currentmodule:: cuda.core
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/tests/cython/build_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -eo pipefail

# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

UNAME=$(uname)
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/tests/helpers/layout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion cuda_core/tests/test_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down
1 change: 1 addition & 0 deletions cuda_core/tests/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,7 @@ def test_mempool_watermark_reset(memory_resource_factory, kind):
mr.close()


@pytest.mark.thread_unsafe(reason="CUDA legacy-default-stream mempool teardown/sync race (gh-3350)")
@pytest.mark.agent_authored(model="claude-opus-5-5")
def test_mempool_trim(memory_resource_factory):
device = Device()
Expand Down
2 changes: 1 addition & 1 deletion cuda_pathfinder/cuda/pathfinder/_utils/env_vars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Centralized CUDA environment variable handling.
Expand Down
2 changes: 1 addition & 1 deletion cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import functools
Expand Down
2 changes: 1 addition & 1 deletion cuda_pathfinder/cuda/pathfinder/_utils/platform_aware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import sys
Expand Down
2 changes: 1 addition & 1 deletion cuda_pathfinder/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0


Expand Down
2 changes: 1 addition & 1 deletion cuda_pathfinder/tests/test_utils_env_vars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import os
Expand Down
2 changes: 1 addition & 1 deletion cuda_pathfinder/tests/test_utils_find_sub_dirs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

from pathlib import Path
Expand Down
Loading
Loading