π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
ci: add path filters to skip CI on docs/non-code changes (#3445)
Edgar Ribac90e3d732e10
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.ymlindex aac93cc87..49aff4cf3 100644--- a/.github/workflows/docs.yml+++ b/.github/workflows/docs.yml@@ -1,4 +1,9 @@on:+ pull_request:+ branches: [main]+ paths:+ - 'docs/**'+ - '*.rst'workflow_call:inputs:python-version:@@ -39,7 +44,7 @@ jobs:- name: Checkout repositoryuses: actions/checkout@v4with:- ref: ${{ inputs.ref }}+ ref: ${{ github.event.pull_request.head.sha || inputs.ref }}- name: Restore cacheif: inputs.cache-path != ''diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 33336c7a1..bcf52971c 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -4,9 +4,17 @@ on:push:branches:- main+ paths:+ - '*.toml'+ - 'pixi.toml'+ - 'pyproject.toml'pull_request:branches:- main+ paths:+ - '*.toml'+ - 'pixi.toml'+ - 'pyproject.toml'permissions:contents: readdiff --git a/.github/workflows/pr_test_cpu.yml b/.github/workflows/pr_test_cpu.ymlindex 3ddce6cbe..831639235 100644--- a/.github/workflows/pr_test_cpu.yml+++ b/.github/workflows/pr_test_cpu.yml@@ -4,6 +4,12 @@ on:pull_request:branches: [main]types: [opened, reopened, synchronize, ready_for_review]+ paths-ignore:+ - 'docs/**'+ - '*.md'+ - 'LICENSE'+ - 'COPYRIGHT'+ - '.github/workflows/**'workflow_dispatch:permissions:@@ -85,19 +91,8 @@ jobs:needs: [pre-tests]uses: ./.github/workflows/tutorials.yml- docs:- needs: [pre-tests]- uses: ./.github/workflows/docs.yml- with:- python-version: '["3.11"]'- cache-path: weights/- cache-key: model-weights-${{ needs.pre-tests.outputs.hash }}- cache-restore-keys: |- model-weights-${{ needs.pre-tests.outputs.hash }}- model-weights--collector:- needs: [tests, tutorials, typecheck, docs]+ needs: [tests, tutorials, typecheck]if: always()runs-on: ubuntu-lateststeps:diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.ymlindex ef19e4130..5c5c5d616 100644--- a/.github/workflows/pypi-release.yml+++ b/.github/workflows/pypi-release.yml@@ -1,8 +1,6 @@name: PyPI Releaseon:- push:- branches: [main]release:types: [published]workflow_dispatch:diff --git a/.github/workflows/scheduled_test_cpu.yml b/.github/workflows/scheduled_test_cpu.ymlindex 09529a07d..d17ca89d5 100644--- a/.github/workflows/scheduled_test_cpu.yml+++ b/.github/workflows/scheduled_test_cpu.yml@@ -3,6 +3,11 @@ name: Tests on CPU (scheduled)on:push:branches: [main]+ paths-ignore:+ - 'docs/**'+ - '*.md'+ - 'LICENSE'+ - 'COPYRIGHT'schedule:- cron: '0 4 * * *'workflow_call:@@ -15,8 +20,56 @@ concurrency:cancel-in-progress: truejobs:+ check-skip:+ # For scheduled runs, check if only documentation files changed+ # If so, skip the expensive test runs+ runs-on: ubuntu-latest+ outputs:+ should-skip: ${{ steps.check.outputs.should-skip }}+ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ fetch-depth: 2 # Need at least 2 commits to compare++ - name: Check if only docs changed+ id: check+ run: |+ # For non-schedule events, always run tests+ if [[ "${{ github.event_name }}" != "schedule" ]]; then+ echo "should-skip=false" >> "$GITHUB_OUTPUT"+ echo "Not a scheduled run, will proceed with tests"+ exit 0+ fi++ # For scheduled runs, check if only documentation files changed+ # Get the last commit on main+ LAST_COMMIT=$(git rev-parse HEAD)++ # Get list of changed files in the last commit+ CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r $LAST_COMMIT)++ # Check if all changed files are in paths-ignore patterns+ SHOULD_SKIP="true"+ for file in $CHANGED_FILES; do+ # Check if file matches any ignore pattern+ if [[ ! "$file" =~ ^docs/ ]] && \+ [[ ! "$file" =~ \.md$ ]] && \+ [[ "$file" != "LICENSE" ]] && \+ [[ "$file" != "COPYRIGHT" ]]; then+ SHOULD_SKIP="false"+ break+ fi+ done++ echo "should-skip=$SHOULD_SKIP" >> "$GITHUB_OUTPUT"+ echo "Changed files: $CHANGED_FILES"+ echo "Should skip: $SHOULD_SKIP"+pre-tests:runs-on: ubuntu-latest+ needs: [check-skip]+ if: needs.check-skip.outputs.should-skip == 'false'outputs:hash: ${{ steps.hashid.outputs.weights-hash }}steps:@@ -45,7 +98,8 @@ jobs:run: echo "weights-hash=${{ hashFiles('.github/download-models-weights.py') }}" >> "$GITHUB_OUTPUT"tests-cpu-ubuntu:- needs: [pre-tests]+ needs: [check-skip, pre-tests]+ if: needs.check-skip.outputs.should-skip == 'false'strategy:fail-fast: falsematrix:@@ -64,7 +118,8 @@ jobs:model-weights-tests-cpu-windows:- needs: [pre-tests]+ needs: [check-skip, pre-tests]+ if: needs.check-skip.outputs.should-skip == 'false'strategy:fail-fast: falsematrix:@@ -89,7 +144,8 @@ jobs:model-weights-tests-cpu-mac:- needs: [pre-tests]+ needs: [check-skip, pre-tests]+ if: needs.check-skip.outputs.should-skip == 'false'strategy:fail-fast: falsematrix:@@ -116,7 +172,8 @@ jobs:model-weights-coverage:- needs: [pre-tests]+ needs: [check-skip, pre-tests]+ if: needs.check-skip.outputs.should-skip == 'false'uses: ./.github/workflows/coverage.ymlwith:cache-path: weights/@@ -126,13 +183,18 @@ jobs:model-weights-typing:+ needs: [check-skip]+ if: needs.check-skip.outputs.should-skip == 'false'uses: ./.github/workflows/typecheck.ymltutorials:+ needs: [check-skip]+ if: needs.check-skip.outputs.should-skip == 'false'uses: ./.github/workflows/tutorials.ymldocs:- needs: [pre-tests]+ needs: [check-skip, pre-tests]+ if: needs.check-skip.outputs.should-skip == 'false'uses: ./.github/workflows/docs.ymlwith:python-version: '["3.11"]'diff --git a/AI_POLICY.md b/AI_POLICY.mdindex 079ac747c..d35d073e9 100644--- a/AI_POLICY.md+++ b/AI_POLICY.md@@ -38,6 +38,25 @@ AI models often hallucinate comments or reinvent existing utilities.**Failure Condition:** Answering a review question with "That's what the AI outputted" or "I don't know, it works" leads to immediate closure.+### Law 4: Transparency in AI Usage Disclosure++**Requirement:** All PRs must accurately complete the "AI Usage Disclosure" section in the pull request template. This disclosure is mandatory and must reflect the actual use of AI tools.++**When to mark as π΄ AI-generated:**+- An AI agent (e.g., Cursor, GitHub Copilot, ChatGPT, etc.) generated the code, PR description, or commit messages+- You cannot explain the logic without referring to the AI's output+- The PR was created primarily by an agent with minimal human review or modification++**When to mark as π‘ AI-assisted:**+- You used AI tools for boilerplate code, refactoring, or suggestions, but you manually reviewed and tested every line+- You understand and can explain all the code you're submitting+- You made significant modifications to AI-suggested code++**When to mark as π’ No AI used:**+- You wrote all code manually without any AI assistance++**Failure Condition:** Incorrectly marking AI-generated code as "AI-assisted" or "No AI used" may result in PR closure, especially if the code contains hallucinations or cannot be explained during review.+## 3. Instructions for AI Reviewers (Copilot / CodeRabbit)If you are an AI agent (GitHub Copilot, CodeRabbit, etc.) reviewing a PR for Kornia, you must follow the repository's dedicated reviewer instructions.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 521f7cbba..ee3a59196 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -361,6 +361,10 @@ This section provides guidance for contributing to Kornia, with a focus on Pytho- Understand every line of code you submit; you must be able to explain it during review (see [AI Policy](#policies-and-guidelines))- Review AI output thoroughly: check for unnecessary complexity, verify it follows project conventions, ensure it uses existing utilities, and test it- Be transparent in PR descriptions about what was AI-assisted and what you manually reviewed (see [Pull Request](#pull-request) for AI Usage Disclosure requirements)+- **AI Usage Disclosure in PR Template**: When completing the PR template's "AI Usage Disclosure" section:+ - Mark as **π’ No AI used** only if you wrote all code manually without any AI assistance+ - Mark as **π‘ AI-assisted** if you used AI tools (Copilot, Cursor, etc.) for boilerplate/refactoring but manually reviewed and tested every line+ - Mark as **π΄ AI-generated** if an AI agent generated the code, PR description, or commit messages, or if you cannot explain the logic without referring to the AI's output. **Important**: PRs marked as AI-generated are subject to stricter scrutiny and may be immediately closed if the logic cannot be explained## Communication@@ -396,7 +400,7 @@ This workflow helps maintain quality, avoid conflicts, and ensure contributions- **AI Policy Compliance**: Must comply with [AI_POLICY.md](AI_POLICY.md). This includes:- Using existing `kornia` utilities instead of reinventing- Being able to explain all submitted code- - Completing the AI Usage Disclosure in the PR template+ - Completing the AI Usage Disclosure in the PR template accurately (see [AI-Assisted Development](#ai-assisted-development) for guidance on when to mark as AI-generated)- 15-Day Rule: Inactive PRs (>15 days) will be closed- Transparency: Keep discussions public