diff --git a/.github/repo-file-sync.yml b/.github/repo-file-sync.yml new file mode 100644 index 0000000..a9a7e9e --- /dev/null +++ b/.github/repo-file-sync.yml @@ -0,0 +1,28 @@ +# Static community files synced to all active repos. +# OWNERS files are handled separately by the workflow (per-repo content). +# https://github.com/BetaHuhn/repo-file-sync-action + +group: + - files: + - source: LICENSE + dest: LICENSE + - source: CODE_OF_CONDUCT.md + dest: CODE_OF_CONDUCT.md + - source: SECURITY.md + dest: SECURITY.md + repos: + - Project-HAMi/HAMi + - Project-HAMi/HAMi-core + - Project-HAMi/volcano-vgpu-device-plugin + - Project-HAMi/dcu-vgpu-device-plugin + - Project-HAMi/dcu-exporter + - Project-HAMi/dcu-dcgm + - Project-HAMi/ascend-device-plugin + - Project-HAMi/HAMi-WebUI + - Project-HAMi/k8s-dra-driver + - Project-HAMi/HAMi-DRA + - Project-HAMi/hami-vnpu-core + - Project-HAMi/biren-device-plugin + - Project-HAMi/mock-device-plugin + - Project-HAMi/ai-benchmark + - Project-HAMi/KAI-resource-isolator diff --git a/.github/workflows/sync-community.yml b/.github/workflows/sync-community.yml new file mode 100644 index 0000000..15e9b82 --- /dev/null +++ b/.github/workflows/sync-community.yml @@ -0,0 +1,60 @@ +name: Sync Community Files + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + sync-static: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: BetaHuhn/repo-file-sync-action@8b92be3375cf1d1b0cd579af488a9255572e4619 # v1 + with: + GH_PAT: ${{ secrets.ORG_PAT }} + CONFIG_PATH: .github/repo-file-sync.yml + + sync-generated: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: pip install pyyaml + - run: python3 sync-owners.py + - name: Push OWNERS and CONTRIBUTING.md to repos + env: + GH_TOKEN: ${{ secrets.ORG_PAT }} + run: | + for dir in generated/*/; do + repo=$(basename "$dir") + for file in OWNERS CONTRIBUTING.md; do + sha=$(gh api "repos/Project-HAMi/$repo/contents/$file" --jq .sha 2>/dev/null) || true + echo "=== $repo / $file ===" + if [ -n "$sha" ]; then + gh api "repos/Project-HAMi/$repo/contents/$file" \ + -X PUT \ + -f message="sync: update $file from .project" \ + -f content="$(base64 -w0 "$dir/$file")" \ + -f sha="$sha" \ + -f branch=main + else + gh api "repos/Project-HAMi/$repo/contents/$file" \ + -X PUT \ + -f message="sync: create $file from .project" \ + -f content="$(base64 -w0 "$dir/$file")" \ + -f branch=main + fi + done + done diff --git a/.gitignore b/.gitignore index 8bbe9a8..3e2305e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Thumbs.db .vscode/ *~ *.swp +generated/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..63314a5 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# HAMi Community Code of Conduct + +Please refer to our [HAMi Community Code of Conduct](https://github.com/Project-HAMi/community/blob/main/CODE-OF-CONDUCT.md). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5a0ea59 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,157 @@ +# Contributing + +Welcome to HAMi! + +- [Contributing](#contributing) +- [Before you get started](#before-you-get-started) + - [Code of Conduct](#code-of-conduct) + - [Community Expectations](#community-expectations) + - [AI Assistance Notice](#ai-assistance-notice) +- [Getting started](#getting-started) +- [Your First Contribution](#your-first-contribution) + - [Find something to work on](#find-something-to-work-on) + - [Find a good first topic](#find-a-good-first-topic) + - [Work on an issue](#work-on-an-issue) + - [File an Issue](#file-an-issue) +- [Contributor Workflow](#contributor-workflow) + - [Creating Pull Requests](#creating-pull-requests) + - [Code Review](#code-review) + +# Before you get started + +## Code of Conduct + +Please make sure to read and observe our [Code of Conduct](/CODE_OF_CONDUCT.md). + +## Community Expectations + +HAMi is a community project driven by its community which strives to promote a healthy, friendly and productive environment. + +## AI Assistance Notice + +> [!IMPORTANT] +> +> If you are using **any kind of AI assistance** to contribute to HAMi, +> it must be disclosed in the pull request. + +If you are using any kind of AI assistance while contributing to HAMi, +**this must be disclosed in the pull request**, along with the extent to +which AI assistance was used (e.g. docs only vs. code generation). +If PR responses are being generated by an AI, you must still disclose +it. This requires special care: you must fully understand the reviewer's +point and critically review any AI-generated text to ensure it is accurate +and directly addresses the feedback. Never paste AI output verbatim. +Failure to engage thoughtfully with reviews may result in your PR being +closed. As a small exception, trivial tab-completion doesn't need to be +disclosed, so long as it is limited to single keywords or short phrases. + +An example disclosure: + +> This PR was written primarily by Claude Code. + +Or a more detailed disclosure: + +> I consulted ChatGPT to understand the codebase but the solution +> was fully authored manually by myself. + +Failure to disclose this is first and foremost rude to the human operators +on the other end of the pull request, but it also makes it difficult to +determine how much scrutiny to apply to the contribution. + +In a perfect world, AI assistance would produce equal or higher quality +work than any human. That isn't the world we live in today, and in many cases +AI-generated code can contain subtle bugs or not adhere to project-specific +best practices. I say this despite being a fan of and using them successfully +myself (with heavy supervision)! + +When using AI assistance, we expect contributors to understand the code +that is produced and be able to answer critical questions about it. It +isn't a maintainer's job to review a PR so broken that it requires +significant rework to be acceptable. + +Please be respectful to maintainers and disclose AI assistance. + +# Getting started + +- Fork the repository on GitHub +- Make your changes in your forked repository +- Submit a Pull Request (PR) + +# Your First Contribution + +We will help you contribute in different areas such as filing issues, developing features, fixing critical bugs and +getting your work reviewed and merged. + +If you have questions about the development process, +feel free to [file an issue](https://github.com/Project-HAMi/.project/issues/new/choose). + +## Find something to work on + +We are always in need of help, whether it's fixing documentation, reporting bugs, or writing code. +Look for places where best coding practices aren't followed, code refactoring is needed, or tests are missing. +Here's how you can get started. + +### Find a good first topic + +There are [multiple repositories](https://github.com/Project-HAMi/) within the HAMi organization. +Each repository has beginner-friendly issues marked as "good first issues". +For example, [Project-HAMi/.project](https://github.com/Project-HAMi/.project) has +[help wanted](https://github.com/Project-HAMi/.project/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) and +[good first issue](https://github.com/Project-HAMi/.project/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) +labels for issues that should not require deep knowledge of the system. +We can help new contributors who wish to work on such issues. + +Another good way to contribute is to find documentation improvements, such as fixing missing or broken links. +Please see [Contributing](#contributing) below for the workflow. + +#### Work on an issue + +When you are willing to take on an issue, simply reply to the issue and a maintainer will assign it to you. + +### File an Issue + +While we encourage everyone to contribute code, we also appreciate when someone reports an issue. +Issues should be filed under the appropriate HAMi sub-repository. + +*Example:* A HAMi issue should be opened in [Project-HAMi/.project](https://github.com/Project-HAMi/.project/issues). + +Please follow the provided submission guidelines when opening an issue. + +# Contributor Workflow + +Please never hesitate to ask questions or submit a pull request. + +This is a rough outline of what a contributor's workflow looks like: + +- Create a topic branch from where you want to base the contribution (usually master) +- Make commits of logical units +- Push changes in your topic branch to your personal fork of the repository +- Submit a pull request to [Project-HAMi/.project](https://github.com/Project-HAMi/.project) + +## Creating Pull Requests + +Pull requests are often called simply "PRs". +HAMi generally follows the standard [GitHub pull request](https://help.github.com/articles/about-pull-requests/) process. +To submit a proposed change, please develop the code/fix and add new test cases. +Before submitting a pull request, run these local verifications to predict whether continuous integration will pass or fail: + +* Run and pass `make verify` + +## Issue and PR Lifecycle + +To keep the project manageable, we apply the following policy to all open issues and pull requests: + +- If a maintainer or contributor leaves a comment or review requesting a response, the author has **two weeks** to reply. +- If there is no response within two weeks, the issue or PR will be closed. +- Closing is not permanent. If the issue is still relevant or the PR is still needed, it can be reopened or submitted again at any time. + +This policy helps us keep the backlog focused and avoids letting stale work block active contributors. + +## Code Review + +To make it easier for your PR to receive reviews, consider that reviewers will need you to: + +* Follow [good coding guidelines](https://github.com/golang/go/wiki/CodeReviewComments) +* Write [good commit messages](https://chris.beams.io/posts/git-commit/) +* Break large changes into a logical series of smaller patches which individually make easily understandable changes, and in aggregate solve a broader issue +* Separate cosmetics from functional changes. Cosmetic changes (reindentation, whitespace, comment wording, style fixes) must not be mixed with logic changes in the same commit — split them into their own commit. If the cosmetics are unrelated to the PR's purpose, they belong in a separate PR entirely. This keeps diffs reviewable: reviewers should not have to filter out formatting noise to find what actually changed. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..c6be2ad --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,11 @@ +# Security Policy + +## Reporting a Vulnerability + +To report a security vulnerability, please use the GitHub Security Advisory +["Report a Vulnerability"](https://github.com/Project-HAMi/HAMi/security/advisories/new) tab. + +We will acknowledge your report within 5 business days and send a more detailed +response within 10 business days indicating the next steps. + +Please do not file public issues for security vulnerabilities. diff --git a/maintainers.yaml b/maintainers.yaml index 3ab8be0..92e8554 100644 --- a/maintainers.yaml +++ b/maintainers.yaml @@ -1,17 +1,142 @@ -# Maintainer roster for hami +# Maintainer roster for Project-HAMi # Documentation: https://github.com/cncf/automation/tree/main/utilities/dot-project - +# Each project_id maps to a repo; per-repo OWNERS files are generated from this file. maintainers: - - project_id: "hami" + - project_id: "HAMi" org: "Project-HAMi" teams: - name: "project-maintainers" members: - archlitchi - - nimbus318 + - DSFans2014 + - fouof + - wawa0210 - shouren + - name: "reviewers" + members: + - archlitchi + - chaunceyjiang + - DSFans2014 + - fouof + - lengrongfu + - mesutoezdil + - ouyangluwei163 - wawa0210 - - william-wang + + - project_id: "HAMi-core" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + - name: "reviewers" + members: + - archlitchi + - chaunceyjiang + + - project_id: "volcano-vgpu-device-plugin" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + - name: "reviewers" + members: + - archlitchi + - SataQiu + - sailorvii + + - project_id: "ascend-device-plugin" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + - name: "reviewers" + members: + - archlitchi + - DSFans2014 + + - project_id: "k8s-dra-driver" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + - shouren + + - project_id: "HAMi-DRA" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + - fouof + - calvin0327 + + - project_id: "KAI-resource-isolator" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi - name: "reviewers" - members: [] + members: + - archlitchi + + - project_id: "dcu-vgpu-device-plugin" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + + - project_id: "dcu-exporter" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + + - project_id: "dcu-dcgm" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + + - project_id: "HAMi-WebUI" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + + - project_id: "hami-vnpu-core" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + + - project_id: "biren-device-plugin" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + + - project_id: "mock-device-plugin" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi + + - project_id: "ai-benchmark" + org: "Project-HAMi" + teams: + - name: "project-maintainers" + members: + - archlitchi diff --git a/sync-owners.py b/sync-owners.py new file mode 100644 index 0000000..3e8d29d --- /dev/null +++ b/sync-owners.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +"""Generate per-repo OWNERS and CONTRIBUTING.md from maintainers.yaml.""" +import yaml +from pathlib import Path + +SCRIPT_DIR = Path(__file__).resolve().parent +MAINTAINERS_FILE = SCRIPT_DIR / "maintainers.yaml" +CONTRIBUTING_TMPL = SCRIPT_DIR / "CONTRIBUTING.md" +GENERATED_DIR = SCRIPT_DIR / "generated" + + +ROLE_MAP = {"project-maintainers": "approvers", "reviewers": "reviewers"} + + +def gen_owners(teams): + lines = [] + for team_name, role_name in ROLE_MAP.items(): + members = teams.get(team_name, []) + if members: + lines.append(f"{role_name}:") + for m in members: + lines.append(f" - {m}") + return "\n".join(lines) + "\n" + + +def main(): + with open(MAINTAINERS_FILE) as f: + data = yaml.safe_load(f) + + contributing_tmpl = CONTRIBUTING_TMPL.read_text() + GENERATED_DIR.mkdir(exist_ok=True) + + for entry in data.get("maintainers", []): + repo = entry["project_id"] + org = entry["org"] + teams = {t["name"]: t.get("members", []) for t in entry.get("teams", [])} + + counts = {role: len(teams.get(name, [])) for name, role in ROLE_MAP.items()} + owners = gen_owners(teams) + + repo_dir = GENERATED_DIR / repo + repo_dir.mkdir(exist_ok=True) + if owners.strip(): + (repo_dir / "OWNERS").write_text(owners) + else: + print(f" {repo}: WARNING - no approvers or reviewers, skipping OWNERS") + (repo_dir / "CONTRIBUTING.md").write_text( + contributing_tmpl.replace("Project-HAMi/.project", f"{org}/{repo}") + ) + + print(f" {repo}: " + ", ".join(f"{r}={c}" for r, c in counts.items())) + + +if __name__ == "__main__": + main()