From e09cd13904604893529a142ed5683f416695a79f Mon Sep 17 00:00:00 2001 From: abhijeet-dhumal Date: Thu, 9 Apr 2026 21:11:53 +0530 Subject: [PATCH] chore: add CI and community hygiene Signed-off-by: abhijeet-dhumal --- .github/PULL_REQUEST_TEMPLATE.md | 19 ++++- .github/workflows/check-pr-title.yaml | 38 +++++++-- .github/workflows/docs.yaml | 69 ++++++++++++++++ .github/workflows/publish.yaml | 80 +++++++++++++++++++ .../workflows/welcome-new-contributors.yaml | 54 +++++++++++++ .gitignore | 6 +- Makefile | 63 ++++++++++++--- 7 files changed, 305 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/docs.yaml create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/welcome-new-contributors.yaml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 54a602c..468f59e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,11 @@ ## Description - + + +## Related Issue + + +Fixes # ## Type of Change @@ -11,11 +16,17 @@ ## Checklist +- [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) guide - [ ] Tests pass locally (`make test-python`) - [ ] Linting passes (`make verify`) - [ ] Documentation updated (if applicable) -- [ ] Commit messages follow conventional format +- [ ] My commits are signed off (`git commit -s`) + +## Testing -## Related Issues + - +```bash +make verify +make test-python +``` diff --git a/.github/workflows/check-pr-title.yaml b/.github/workflows/check-pr-title.yaml index 414a685..52aad58 100644 --- a/.github/workflows/check-pr-title.yaml +++ b/.github/workflows/check-pr-title.yaml @@ -1,15 +1,28 @@ name: Check PR Title on: - pull_request: - types: [opened, edited, synchronize] + pull_request_target: + branches: + - main + types: + - edited + - opened + - reopened + - synchronize + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + pull-requests: read jobs: check: + name: Check PR Title runs-on: ubuntu-latest steps: - - name: Check conventional commit format - uses: amannn/action-semantic-pull-request@v5 + - uses: amannn/action-semantic-pull-request@v6.1.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -18,8 +31,23 @@ jobs: fix revert chore + scopes: | + ci + docs + deps + agents + core + trainer + optimizer + hub + examples + benchmarks requireScope: false + ignoreLabels: | + do-not-merge/work-in-progress + dependencies + area/release subjectPattern: ^[a-z].+$ subjectPatternError: | - PR title must start with lowercase letter. + PR title must start with a lowercase letter. Example: "feat: add training job tool" diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..d2598a3 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,69 @@ +name: Documentation + +on: + pull_request: + paths: + - "docs/**" + - "kubeflow_mcp/**" + - ".readthedocs.yaml" + - ".github/workflows/docs.yaml" + - "pyproject.toml" + push: + branches: [main] + paths: + - "docs/**" + - "kubeflow_mcp/**" + - ".readthedocs.yaml" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + name: Build Documentation + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Build documentation + run: | + uv sync --extra docs + uv run sphinx-build -b html docs/source docs/_build/html + + - name: Upload documentation artifact + uses: actions/upload-artifact@v4 + with: + name: documentation + path: docs/_build/html + retention-days: 7 + + linkcheck: + runs-on: ubuntu-latest + name: Check Links + continue-on-error: true + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Check links + run: | + uv sync --extra docs + uv run sphinx-build -b linkcheck docs/source docs/_build/linkcheck || true diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..db141db --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,80 @@ +name: Publish to PyPI + +on: + release: + types: [published] + workflow_dispatch: + inputs: + test_pypi: + description: 'Publish to Test PyPI instead' + required: false + default: false + type: boolean + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Install dependencies + run: uv sync --extra dev + + - name: Run tests + run: make test-python + + - name: Build package + run: uv build + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + publish-test-pypi: + needs: build + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.test_pypi == 'true' }} + runs-on: ubuntu-latest + environment: + name: test-pypi + permissions: + id-token: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Publish to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + publish-pypi: + needs: build + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + environment: + name: pypi + permissions: + id-token: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + diff --git a/.github/workflows/welcome-new-contributors.yaml b/.github/workflows/welcome-new-contributors.yaml new file mode 100644 index 0000000..b1221d3 --- /dev/null +++ b/.github/workflows/welcome-new-contributors.yaml @@ -0,0 +1,54 @@ +name: Welcome new contributors + +on: + pull_request_target: + types: + - opened + issues: + types: + - opened + +permissions: + issues: write + pull-requests: write + +jobs: + welcome: + runs-on: ubuntu-latest + steps: + - uses: actions/first-interaction@v3 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + issue_message: | + 🎉 **Welcome to the Kubeflow MCP Server!** 🎉 + + Thanks for opening your first issue! We're happy to have you as part of our community 🚀 + + **Here's what happens next:** + + - Our team will review your issue soon! + - If you'd like to contribute to this issue, check out our [Contributing Guide](https://github.com/kubeflow/mcp-server/blob/main/CONTRIBUTING.md) + + **Join the community:** + - **Slack**: Join [#kubeflow-ml-experience](https://www.kubeflow.org/docs/about/community/#slack-channels) on CNCF Slack + - **Meetings**: Attend the [Training WG](https://bit.ly/2PWVCkV) bi-weekly meetings + + Feel free to ask questions in the comments if you need any help! + Thanks again for contributing to Kubeflow! 🙏 + + pr_message: | + 🎉 **Welcome to the Kubeflow MCP Server!** 🎉 + + Thanks for opening your first PR! We're happy to have you as part of our community 🚀 + + **Here's what happens next:** + + - Please check out our [Contributing Guide](https://github.com/kubeflow/mcp-server/blob/main/CONTRIBUTING.md) if you haven't already + - Our team will review your PR soon! + + **Join the community:** + - **Slack**: Join [#kubeflow-ml-experience](https://www.kubeflow.org/docs/about/community/#slack-channels) on CNCF Slack + - **Meetings**: Attend the [Training WG](https://bit.ly/2PWVCkV) bi-weekly meetings + + Feel free to ask questions in the comments if you need any help! + Thanks again for contributing to Kubeflow! 🙏 diff --git a/.gitignore b/.gitignore index d82ac62..0f4020d 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,9 @@ __debug_bin # Testing .pytest_cache/ .coverage +.coverage.* +coverage.xml +coverage.json htmlcov/ .tox/ .nox/ @@ -70,6 +73,3 @@ benchmark-results.json # Docs build output docs/_build/ - -# Test artifacts -coverage.json diff --git a/Makefile b/Makefile index 0aefd62..7a82006 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,70 @@ +# Copyright The Kubeflow Authors. +# +# 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. + SHELL = /usr/bin/env bash -o pipefail .SHELLFLAGS = -ec +.PHONY: help uv install-dev verify format test-python test test-cov clean + PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) help: ## Display this help. - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +##@ Setup -.PHONY: uv -uv: ## Install UV +uv: ## Install uv @command -v uv &> /dev/null || { \ curl -LsSf https://astral.sh/uv/install.sh | sh; \ - echo "✅ uv has been installed."; \ + echo "uv has been installed."; \ } -.PHONY: verify -verify: ## Run linting, formatting and type checking +install-dev: uv ## Install all development dependencies + @uv sync --all-extras + @uv run pre-commit install + +##@ Quality + +verify: ## Run linting and formatting checks @uv lock --check @uv run ruff check . @uv run ruff format --check . -.PHONY: test-python -test-python: ## Run Python unit tests +format: ## Auto-format and fix lint issues + @uv run ruff check --fix . + @uv run ruff format . + +##@ Testing + +test-python: ## Run unit tests @uv sync --all-extras @uv run pytest --cov=kubeflow_mcp --cov-report=$(or $(report),term) -.PHONY: install-dev -install-dev: uv ## Install dependencies and tools - @echo "Syncing dependencies with uv..." +test: ## Run all tests (unit + integration) + @uv sync --all-extras + @uv run pytest tests/ kubeflow_mcp/ -v --tb=short + +test-cov: ## Run tests with HTML coverage report @uv sync --all-extras - @echo "Environment is ready." + @uv run pytest --cov=kubeflow_mcp --cov-report=term-missing --cov-report=html + @echo "Coverage report: htmlcov/index.html" + +##@ Cleanup + +clean: ## Remove all build and cache artifacts + rm -rf .pytest_cache .ruff_cache .coverage htmlcov + rm -rf dist build *.egg-info + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true + find . -type f -name "*.pyc" -delete 2>/dev/null || true + @echo "Cleaned build artifacts"