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 .agents/skills/update-docs/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Write the smallest update that tells users exactly what changed and what they ne
- **No superlatives.** Say what the feature does, not how great it is.
- **Code examples use `shell` language** for copyable commands, with no `$` prompt prefix.
- **Use `text` fences** for transcripts, logs, or shell sessions that should not be copied verbatim.
- **Include the SPDX header as YAML comments in frontmatter** if creating a new page.
- **Include the SPDX license identifier as a YAML comment in frontmatter** if creating a new page. Do not add an `SPDX-FileCopyrightText` line.
- **Match existing Fern frontmatter format** if creating a new page, including `sidebar-title`, `keywords`, and `position` when they are relevant. Use frontmatter `slug` only for folder-discovered pages or absolute URL overrides.
- **Use `sidebar-title` for short nav labels**. For explicit navigation entries, keep relative `slug` values in `docs/index.yml` instead of page frontmatter.
- **Keep explicit `page:` entries in `docs/index.yml`**. Fern still requires them. If the page defines `sidebar-title`, set `page:` to that value. Otherwise set `page:` to the page frontmatter `title`.
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/branch-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,30 @@ jobs:
license-headers:
name: License Headers
runs-on: ubuntu-24.04
timeout-minutes: 30
container:
image: ghcr.io/ai-openshell/openshell/ci:82e753ba3ffdfb40c118e7cb416ced7f350381d5@sha256:d816f3b4b2de675928e2ecfd26ec6b937be35fe9986542c87d440bc3de5a29de
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Install tools
run: mise install --locked

# Keep include and exclude in step with scripts/update_license_headers.py.
- name: Check license headers
run: mise run license:check
uses: ai-openshell/workflows/spdx-check@8f4d5a0f393e5c30ad4d09810357a062031c4fc4
with:
include: >-
*.rs *.proto *.py *.sh *.toml *.yaml *.yml *.rego
*.ts *.tsx *.mts *.cts *.mjs *.css *.in *.service *.tpl
Dockerfile* */Dockerfile* scripts/bin/openshell
scripts/keycloak-realm.json
sdk/conformance/oauth-client-credentials.json
sdk/conformance/oidc-token-bundle.json
exclude: >-
target/* e2e/rust/target/* plans/* architecture/plans/*
.cache/* .venv/* python/openshell/_proto/*
.github/* .agents/* .claude/* :(glob)**/node_modules/**
.gitlab-ci.yml */.gitlab-ci.yml
base: ${{ github.event.merge_group.base_sha || github.event.pull_request.base.sha }}

cargo-deny:
name: Cargo Deny
Expand Down
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ Follow `CONTRIBUTING.md` and `create-github-pr`. Authors without target-reposito

Create PRs with `gh pr create`, which enables "Allow edits by maintainers" by default; never pass `--no-maintainer-edit`. Review Readiness fails a ready PR from a personal fork when that setting is off. Fix a PR that lacks it with `gh api -X PATCH repos/OWNER/REPO/pulls/NUMBER -F maintainer_can_modify=true`.

## License Headers

- Start new source files with only `SPDX-License-Identifier: Apache-2.0`, even when neighboring files also carry an `SPDX-FileCopyrightText` line. Never add a copyright line, and never remove an existing one.

## Commits

- Always use [Conventional Commits](https://www.conventionalcommits.org/) format for commit messages
Expand Down
10 changes: 8 additions & 2 deletions STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

## License Headers

All source files must include SPDX copyright headers.
All source files must include an SPDX license identifier:

```text
# SPDX-License-Identifier: Apache-2.0
```

Do not add an `SPDX-FileCopyrightText` line to new files, and do not remove one from an existing file.

```bash
# Add/update headers
# Add missing headers
mise run license:update

# Check headers
Expand Down
4 changes: 1 addition & 3 deletions docs/CONTRIBUTING.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ PRs that touch `docs/**` or `fern/**` are validated by `.github/workflows/branch

- Published docs use Fern MDX under `docs/`.
- Every page starts with YAML frontmatter. Use `title` and `description` on every page, then add page-level metadata like `sidebar-title`, `keywords`, and `position` when the page needs them.
- Include the SPDX license header as YAML comments inside frontmatter:
- Include the SPDX license identifier as a YAML comment inside frontmatter:

```text
---
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
title: "Page Title"
---
Expand All @@ -72,7 +71,6 @@ PRs that touch `docs/**` or `fern/**` are validated by `.github/workflows/branch

```yaml
---
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
title: "Page Title"
sidebar-title: "Short Nav Title"
Expand Down
37 changes: 6 additions & 31 deletions scripts/update_license_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import argparse
import os
import re
import subprocess
import sys
from pathlib import Path
Expand All @@ -29,9 +28,6 @@
# Configuration
# ---------------------------------------------------------------------------

COPYRIGHT_TEXT = (
"Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved."
)
LICENSE_ID = "Apache-2.0"

# Map file extensions to their line-comment prefix.
Expand Down Expand Up @@ -102,18 +98,10 @@


def make_header(comment: str) -> str:
"""Return the two-line SPDX header for a given comment prefix."""
"""Return the SPDX license header for a given comment prefix."""
if comment == "/*":
return (
"/*\n"
f" * SPDX-FileCopyrightText: {COPYRIGHT_TEXT}\n"
f" * SPDX-License-Identifier: {LICENSE_ID}\n"
" */\n"
)
return (
f"{comment} SPDX-FileCopyrightText: {COPYRIGHT_TEXT}\n"
f"{comment} SPDX-License-Identifier: {LICENSE_ID}\n"
)
return f"/*\n * SPDX-License-Identifier: {LICENSE_ID}\n */\n"
return f"{comment} SPDX-License-Identifier: {LICENSE_ID}\n"


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -251,20 +239,11 @@ def discover_files(root: Path) -> list[Path]:
# ---------------------------------------------------------------------------

SPDX_MARKER = "SPDX-License-Identifier"
SPDX_COPYRIGHT_RE = re.compile(
r"SPDX-FileCopyrightText: Copyright \(c\) \d{4}(?:-\d{4})? "
r"NVIDIA CORPORATION & AFFILIATES\. All rights reserved\."
)


def has_header(lines: list[str]) -> bool:
"""Check if the complete NVIDIA SPDX header is in the first 10 lines."""
header_lines = lines[:10]
has_license = any(
f"{SPDX_MARKER}: {LICENSE_ID}" in line for line in header_lines
)
has_copyright = any(SPDX_COPYRIGHT_RE.search(line) for line in header_lines)
return has_license and has_copyright
"""Check if the SPDX license identifier is in the first 10 lines."""
return any(f"{SPDX_MARKER}: {LICENSE_ID}" in line for line in lines[:10])


def find_insertion_point(lines: list[str], path: Path) -> int:
Expand Down Expand Up @@ -335,11 +314,7 @@ def process_file(path: Path, root: Path, *, check: bool, verbose: bool) -> bool:
if check:
print(f" MISSING: {rel} ({sidecar.name})")
return False
sidecar.write_text(
f"SPDX-FileCopyrightText: {COPYRIGHT_TEXT}\n"
f"SPDX-License-Identifier: {LICENSE_ID}\n",
encoding="utf-8",
)
sidecar.write_text(f"{SPDX_MARKER}: {LICENSE_ID}\n", encoding="utf-8")
if verbose:
print(f" added: {rel} ({sidecar.name})")
return True
Expand Down
60 changes: 60 additions & 0 deletions scripts/update_license_headers_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SPDX-License-Identifier: Apache-2.0

"""Tests for scripts/update_license_headers.py."""

from __future__ import annotations

import importlib.util
import sys
from pathlib import Path

_SPEC = importlib.util.spec_from_file_location(
"update_license_headers", Path(__file__).with_name("update_license_headers.py")
)
assert _SPEC is not None and _SPEC.loader is not None
headers = importlib.util.module_from_spec(_SPEC)
sys.modules[_SPEC.name] = headers
_SPEC.loader.exec_module(headers)

NVIDIA_COPYRIGHT = (
"# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & "
"AFFILIATES. All rights reserved."
)


def test_license_identifier_alone_is_compliant() -> None:
assert headers.has_header(["# SPDX-License-Identifier: Apache-2.0", "x = 1"])


def test_existing_copyright_header_stays_compliant() -> None:
assert headers.has_header(
[NVIDIA_COPYRIGHT, "# SPDX-License-Identifier: Apache-2.0"]
)


def test_missing_license_identifier_is_not_compliant() -> None:
assert not headers.has_header([NVIDIA_COPYRIGHT, "x = 1"])


def test_inserted_header_has_no_copyright() -> None:
result = headers.insert_header("x = 1\n", "#", Path("a.py"))
assert result == "# SPDX-License-Identifier: Apache-2.0\n\nx = 1\n"


def test_inserted_block_comment_header_has_no_copyright() -> None:
result = headers.insert_header("a {}\n", "/*", Path("a.css"))
assert result == "/*\n * SPDX-License-Identifier: Apache-2.0\n */\n\na {}\n"


def test_written_sidecar_has_no_copyright(tmp_path: Path) -> None:
target = tmp_path / "data.json"
target.write_text("{}\n", encoding="utf-8")
headers.SIDECAR_LICENSE_FILES.add("data.json")
try:
assert headers.process_file(target, tmp_path, check=False, verbose=False)
finally:
headers.SIDECAR_LICENSE_FILES.discard("data.json")
sidecar = tmp_path / "data.json.license"
assert (
sidecar.read_text(encoding="utf-8") == "SPDX-License-Identifier: Apache-2.0\n"
)
4 changes: 2 additions & 2 deletions tasks/license.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# License header check and update tasks

["license:check"]
description = "Check that all source files have SPDX license headers"
description = "Check that all source files have SPDX license identifiers"
run = "uv run python scripts/update_license_headers.py --check"
hide = true

["license:update"]
description = "Add or update SPDX license headers on all source files"
description = "Add SPDX license identifiers to source files that lack one"
run = "uv run python scripts/update_license_headers.py"
hide = true
4 changes: 2 additions & 2 deletions tasks/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ run_windows = "echo Skipping test:postgres-runner: the Unix PostgreSQL test runn
hide = true

["test:python-scripts"]
description = "Test the release, RPM, and E2E gateway config tooling"
run = "uv run --no-project --with pytest --with pyyaml pytest -o \"python_files=*_test.py\" tasks/scripts/release_formula_test.py tasks/scripts/release_tooling_test.py deploy/rpm/ e2e/configs/gateway/"
description = "Test the release, RPM, E2E gateway config, and license header tooling"
run = "uv run --no-project --with pytest --with pyyaml pytest -o \"python_files=*_test.py\" tasks/scripts/release_formula_test.py tasks/scripts/release_tooling_test.py deploy/rpm/ e2e/configs/gateway/ scripts/update_license_headers_test.py"
hide = true

["test:python"]
Expand Down
Loading