Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Automates SPDX copyright header validation on all PRs to main branch using zccrs/github-actions-spdx-checker@v1.

Implementation

  • Workflow trigger: Pull requests to main branch
  • File coverage: Multiple languages (py, js, ts, java, cpp, go, rs, rb, php, sh, xml, yaml, json, CMake, Makefile)
  • Exclusions: vendor/**, node_modules/**
  • Permissions: Minimal scope (contents: read, pull-requests: read)
  • Git depth: Full history (fetch-depth: 0) for year range validation

Validation Rules

  • New files: Must have current year SPDX header
  • Modified files: Must update year range (e.g., 2023-2026)
  • Error messages: Bilingual (EN/CN)
- uses: zccrs/github-actions-spdx-checker@v1
  with:
    base: origin/main
    include: '*.py,*.js,*.ts,*.jsx,*.tsx,*.java,*.cpp,*.c,*.h,*.hpp,*.go,*.rs,*.rb,*.php,*.sh,*.xml,*.yaml,*.yml,*.json,CMakeLists.txt,Makefile'
    exclude: 'vendor/**,node_modules/**'
Original prompt

Add SPDX Header Check Workflow

Overview

需要在 .github/workflows/ 目录下创建一个新的 GitHub Actions 工作流文件,用于自动检查 Pull Request 中文件的 SPDX 版权头部。

Requirements

创建文件

创建文件:.github/workflows/spdx-check.yml

文件内容

name: SPDX Header Check

on:
  pull_request:
    branches: [main]

jobs:
  spdx-check:
    runs-on: ubuntu-latest
    steps:
      - uses: zccrs/github-actions-spdx-checker@v1
        with:
          base: origin/main
          include: '*.py,*.js,*.ts,*.jsx,*.tsx,*.java,*.cpp,*.c,*.h,*.hpp,*.go,*.rs,*.rb,*.php,*.sh,*.xml,*.yaml,*.yml,*.json,CMakeLists.txt,Makefile'
          exclude: 'vendor/**,node_modules/**'

工作流功能

  • 当有 PR 提交到 main 分支时自动触发
  • 使用 zccrs/github-actions-spdx-checker@v1 action 检查 SPDX 头部
  • 支持多种编程语言文件类型
  • 自动排除 vendor 和 node_modules 目录
  • 验证新文件包含当前年份的 SPDX 头部
  • 确保修改文件正确更新年份范围

预期结果

  • 所有后续的 Pull Request 都会自动进行 SPDX 头部检查
  • 不符合规范的文件会导致检查失败
  • 提供中英文双语错误提示

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@deepin-ci-robot
Copy link
Contributor

Hi @copilot. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Created `.github/workflows/spdx-check.yml` to automatically check SPDX copyright
headers in pull requests. The workflow:
- Triggers on pull requests to the main branch
- Uses zccrs/github-actions-spdx-checker@v1 action
- Checks multiple file types (py, js, ts, java, cpp, go, rs, etc.)
- Excludes vendor and node_modules directories
- Validates new files have current year SPDX headers
- Ensures modified files update year ranges correctly

This will help maintain consistent copyright headers across all linuxdeepin projects
and ensure compliance with SPDX standards.

Influence:
1. All future PRs to main branch will automatically check SPDX headers
2. Non-compliant files will cause workflow to fail with bilingual error messages
3. Developers must include proper SPDX headers in all new and modified files
4. Test by creating a PR with files missing SPDX headers

feat: 添加 SPDX 头部检查工作流

创建 `.github/workflows/spdx-check.yml` 以自动检查拉取请求中的 SPDX 版权头部。
此工作流:
- 在向 main 分支提交 PR 时触发
- 使用 zccrs/github-actions-spdx-checker@v1 action
- 检查多种文件类型(py, js, ts, java, cpp, go, rs 等)
- 排除 vendor 和 node_modules 目录
- 验证新文件包含当前年份的 SPDX 头部
- 确保修改的文件正确更新年份范围

这将有助于在所有 linuxdeepin 项目中保持一致的版权头部,并确保符合 SPDX 标准。

Influence:
1. 所有未来向 main 分支提交的 PR 都会自动检查 SPDX 头部
2. 不符合规范的文件会导致工作流失败并提供双语错误消息
3. 开发者必须在所有新文件和修改的文件中包含适当的 SPDX 头部
4. 通过创建缺少 SPDX 头部的文件的 PR 来测试

Co-authored-by: zccrs <13449038+zccrs@users.noreply.github.com>
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI and others added 2 commits January 16, 2026 08:20
Added actions/checkout@v5 step before the SPDX checker to ensure the repository
code is available for checking. Configured with fetch-depth: 0 to fetch full git
history, which is required for the SPDX checker to compare against the base branch
and determine which files have been added or modified.

This ensures the workflow can properly:
- Access all files in the pull request
- Compare changes against the base branch (origin/main)
- Determine new vs modified files for appropriate SPDX header validation

Influence:
1. The workflow will now function correctly when triggered
2. Files in PRs will be properly checked for SPDX headers
3. Git history is available for year range validation in modified files

fix: 为 SPDX 头部检查工作流添加检出步骤

在 SPDX 检查器之前添加 actions/checkout@v5 步骤,以确保仓库代码可用于检查。
配置 fetch-depth: 0 以获取完整的 git 历史记录,这是 SPDX 检查器比较基础分支
并确定哪些文件已添加或修改所必需的。

这确保工作流可以正确地:
- 访问拉取请求中的所有文件
- 将更改与基础分支(origin/main)进行比较
- 确定新文件与修改文件以进行适当的 SPDX 头部验证

Influence:
1. 工作流现在将在触发时正常运行
2. PR 中的文件将正确检查 SPDX 头部
3. Git 历史可用于修改文件中的年份范围验证

Co-authored-by: zccrs <13449038+zccrs@users.noreply.github.com>
Added explicit permissions block to limit GITHUB_TOKEN permissions for security.
The workflow now only has the minimal required permissions:
- contents: read - to checkout repository code
- pull-requests: read - to read PR information

This follows GitHub Actions security best practices by implementing the principle
of least privilege, ensuring the workflow only has access to what it needs.

Influence:
1. Improves workflow security posture
2. Prevents potential token misuse
3. Follows GitHub Actions security recommendations
4. Resolves CodeQL security alert about missing workflow permissions

fix: 为 SPDX 检查工作流添加明确的权限

添加明确的权限块以限制 GITHUB_TOKEN 权限以提高安全性。
工作流现在只有最小的必需权限:
- contents: read - 检出仓库代码
- pull-requests: read - 读取 PR 信息

这遵循 GitHub Actions 安全最佳实践,通过实施最小权限原则,确保工作流仅
有权访问其所需内容。

Influence:
1. 提高工作流安全性
2. 防止潜在的令牌滥用
3. 遵循 GitHub Actions 安全建议
4. 解决关于缺少工作流权限的 CodeQL 安全警报

Co-authored-by: zccrs <13449038+zccrs@users.noreply.github.com>
Copilot AI changed the title [WIP] Add SPDX header check workflow for pull requests Add SPDX header check workflow for pull requests Jan 16, 2026
Copilot AI requested a review from zccrs January 16, 2026 08:23
@zccrs zccrs closed this Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants