Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2f19d56
Initial plan
Copilot Nov 20, 2025
8cc3634
Add GitHub Action workflow to block strict version pins without archi…
Copilot Nov 20, 2025
d0e5840
Add comprehensive documentation for strict version pin workflow
Copilot Nov 20, 2025
c2684be
Fix CI errors: add pull-requests write permission and move README out…
Copilot Nov 20, 2025
45517b7
Remove codeowner names from README documentation
Copilot Nov 20, 2025
67cc772
Add .github/scripts/** to cspell ignorePaths
Copilot Nov 20, 2025
a14b5c9
testing
l0lawrence Nov 24, 2025
ee75f22
Improve Python code quality and use file-specific cspell ignore
Copilot Nov 24, 2025
92f07da
Remove CODEOWNERS entries for setup.py and pyproject.toml - CI workfl…
Copilot Nov 24, 2025
f93a1ae
Revert accidental change to eventgrid setup.py
Copilot Nov 24, 2025
044c899
Add architect names to cspell ignore in check_strict_pins.py
Copilot Nov 24, 2025
79fd49b
Add cspell ignore comments to README and workflow files
Copilot Nov 24, 2025
fdc7cc2
Merge branch 'main' into copilot/add-github-action-block-pr-merging
l0lawrence Dec 1, 2025
4addcdd
remove GH action, add to analyze stage for now
l0lawrence Dec 2, 2025
53b46af
mini changes
l0lawrence Dec 2, 2025
8d799b9
Test: Add strict pin to requests
l0lawrence Dec 2, 2025
2a41637
Test: Add strict pin to requests
l0lawrence Dec 2, 2025
d98f9ff
Test: add strict pin to requests==2.31.0
l0lawrence Dec 2, 2025
02a98bb
Test: Add strict pin to requests
l0lawrence Dec 2, 2025
e08dca5
no pr test
l0lawrence Dec 2, 2025
73a5920
oops
l0lawrence Dec 2, 2025
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
148 changes: 148 additions & 0 deletions .github/README-strict-version-pins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Strict Version Pin Check Workflow

## Overview

This GitHub Actions workflow enforces a policy that requires architect approval for any pull requests that introduce strict version pins (`==`) in main runtime dependencies of Python packages within the `sdk/` directory.

## Purpose

Strict version pins can cause dependency conflicts and limit flexibility in package management. This workflow ensures that any such pins in main runtime dependencies are reviewed and approved by designated architects before merging.

## How It Works

### Trigger
The workflow runs on pull requests that modify:
- `sdk/**/setup.py`
- `sdk/**/pyproject.toml`

### Detection Logic

The workflow analyzes the diff to detect:
- **New strict version pins**: Dependencies newly added with `==` operator
- **Modified pins**: Dependencies changed from flexible constraints (e.g., `>=`, `~=`) to strict `==` pins

The detection is **scope-aware** and only considers:
- `install_requires` in `setup.py`
- `dependencies` under `[project]` in `pyproject.toml`

The following are **ignored**:
- Dev dependencies (`extras_require`, `[project.optional-dependencies]`)
- Test dependencies (`tests_require`)
- Comments
- Build dependencies

### Approval Requirements

If strict version pins are detected, the workflow:
1. Posts a comment on the PR listing the detected pins
2. Checks if any of the designated architects have approved the PR
3. **Blocks merging** if no architect approval is found (workflow fails with exit code 1)
4. **Allows merging** if an architect has approved

### CODEOWNERS Integration

The `.github/CODEOWNERS` file has been updated to require reviews from the architects for:
- `/sdk/**/setup.py`
- `/sdk/**/pyproject.toml`

This provides a secondary enforcement mechanism through branch protection rules.

Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section claims that .github/CODEOWNERS has been updated, but according to the PR description, CODEOWNERS entries were removed (not added) because they're not needed since the CI enforces approval. This documentation is inconsistent with the actual implementation.

This entire "CODEOWNERS Integration" section should be removed or rewritten to clarify that CODEOWNERS is NOT being used for this enforcement. The CI workflow itself handles the approval checks.

Suggested change
### CODEOWNERS Integration
The `.github/CODEOWNERS` file has been updated to require reviews from the architects for:
- `/sdk/**/setup.py`
- `/sdk/**/pyproject.toml`
This provides a secondary enforcement mechanism through branch protection rules.

Copilot uses AI. Check for mistakes.
## Examples

### ✅ Allowed (No Strict Pins)
```python
# setup.py
install_requires=[
"azure-core>=1.30.0",
"requests>=2.21.0",
]
```

### ⚠️ Requires Architect Approval
```python
# setup.py
install_requires=[
"azure-core==1.30.0", # Strict pin detected!
"requests>=2.21.0",
]
```

### ✅ Allowed (Strict Pin in Dev Dependencies)
```python
# setup.py
install_requires=[
"azure-core>=1.30.0",
],
extras_require={
"dev": ["pytest==7.0.0"] # OK - this is a dev dependency
}
```

## Testing

The detection logic has been validated with comprehensive test cases covering:
- Adding new strict pins
- Changing from flexible to strict constraints
- Ignoring dev/test dependencies
- Ignoring optional dependencies in pyproject.toml

Run tests locally:
```bash
python /tmp/test_strict_pins.py
```

## Files Modified

1. **`.github/workflows/check-strict-version-pins.yml`**
- Main workflow definition
- Triggers on PR events
- Runs detection and enforcement logic

2. **`.github/scripts/check_strict_pins.py`**
- Python script that analyzes git diffs
- Detects strict version pins in appropriate sections
- Checks for architect approvals via GitHub API

3. **`.github/CODEOWNERS`**
- Added architect requirements for setup.py and pyproject.toml

Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lists .github/CODEOWNERS as a file that was modified with "Added architect requirements for setup.py and pyproject.toml", but this is incorrect. According to the PR description, CODEOWNERS entries were removed, and this file was not actually changed in the PR. This should be removed from the Files Modified section.

Suggested change
3. **`.github/CODEOWNERS`**
- Added architect requirements for setup.py and pyproject.toml

Copilot uses AI. Check for mistakes.
## Branch Protection

To fully enforce this policy, ensure branch protection rules are configured to:
- Require status checks to pass before merging
- Require the "check-strict-pins" workflow to succeed
- Require review from code owners
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instruction to "Require review from code owners" is misleading since CODEOWNERS is not being used by this implementation. The workflow enforces approval directly through the GitHub API. Consider removing this line or clarifying that code owner review is not required for this specific feature to function.

Suggested change
- Require review from code owners
- (Optional) Require review from code owners (not required for this workflow; architect approval is enforced directly via the GitHub API)

Copilot uses AI. Check for mistakes.

## Troubleshooting

### Workflow Not Running
- Verify the PR modifies files matching `sdk/**/setup.py` or `sdk/**/pyproject.toml`
- Check workflow runs in the Actions tab

### False Positives
If the workflow incorrectly flags a dependency:
- Verify the dependency is in the main runtime dependencies section
- Check if comments are interfering with detection
- File an issue with the specific case

### Override Process
If a strict pin is necessary:
1. Document the justification in the PR description
2. Request review from one of the designated architects
3. Architect provides approval review
4. Workflow will pass and allow merge

## Maintenance

### Adding/Removing Architects
To modify the list of architects:
1. Update the `architects` set in `.github/scripts/check_strict_pins.py`
2. Update the CODEOWNERS entries in `.github/CODEOWNERS`
3. Update documentation in this README
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This instruction references updating "CODEOWNERS entries in .github/CODEOWNERS", but CODEOWNERS is not being used by this implementation. The architect list is maintained solely in the Python script. This line should be removed or clarified that CODEOWNERS is not used for this feature.

Suggested change
2. Update the CODEOWNERS entries in `.github/CODEOWNERS`
3. Update documentation in this README
2. Update documentation in this README

Copilot uses AI. Check for mistakes.

### Extending Detection
To add support for additional dependency formats:
1. Add extraction function in `check_strict_pins.py`
2. Update `check_file_for_strict_pins()` to handle new file types
3. Add corresponding test cases
4. Update workflow triggers if needed
Loading
Loading