Skip to content

Commit d6bd0e4

Browse files
committed
✨ feat: migrate approval automation from JavaScript to Python with Click CLI │
│ │ │ - Convert ApprovalManager class from JavaScript to Python using PyGithub │ │ - Replace Node.js dependencies with Python uv environment management │ │ - Implement Click-based CLI interfaces for all three approval types: │ │ - SIG proposals: requires 2 core team approvals │ │ - RFC proposals: requires core team quorum │ │ - Pipeline proposals: requires 2 core OR 1 core + 1 maintainer │ │ - Migrate Jest test suite to pytest with comprehensive coverage (21/21 tests) │ │ - Update GitHub Actions workflows to use Python scripts with CLI parameters │ │ - Replace package.json with pyproject.toml for modern Python packaging │ │ - Update documentation to reflect Python-based automation system │ │ │ │ 🤖 Generated with [Claude Code](https://claude.ai/code) │ │ │ │ Co-Authored-By: Claude <[email protected]>
1 parent 010abe1 commit d6bd0e4

23 files changed

+1890
-5328
lines changed

.github/workflows/lib/.gitignore

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,44 @@
1-
# Dependencies
2-
node_modules/
3-
4-
# Coverage reports
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
8+
# Virtual environments
9+
.venv/
10+
venv/
11+
env/
12+
13+
# Testing & Coverage
14+
.pytest_cache/
15+
.coverage
16+
htmlcov/
17+
.tox/
518
coverage/
19+
coverage.json
20+
coverage.lcov
621

7-
# Jest cache
8-
.cache/
9-
10-
# Logs
11-
npm-debug.log*
12-
yarn-debug.log*
13-
yarn-error.log*
14-
15-
# Runtime data
16-
pids
17-
*.pid
18-
*.seed
19-
*.pid.lock
20-
21-
# Optional npm cache directory
22-
.npm
23-
24-
# Optional REPL history
25-
.node_repl_history
26-
27-
# Output of 'npm pack'
28-
*.tgz
29-
30-
# Yarn Integrity file
31-
.yarn-integrity
22+
# Build artifacts
23+
build/
24+
dist/
25+
*.egg-info/
3226

33-
# dotenv environment variables file
27+
# Environment variables
3428
.env
3529
.env.test
3630

37-
# parcel-bundler cache (https://parceljs.org/)
38-
.cache
39-
.parcel-cache
40-
41-
# next.js build output
42-
.next
43-
44-
# nuxt.js build output
45-
.nuxt
46-
47-
# vuepress build output
48-
.vuepress/dist
49-
50-
# Serverless directories
51-
.serverless
52-
53-
# FuseBox cache
54-
.fusebox/
55-
56-
# DynamoDB Local files
57-
.dynamodb/
31+
# IDEs and editors
32+
.vscode/
33+
.idea/
34+
*.swp
35+
*.swo
36+
37+
# OS files
38+
.DS_Store
39+
.DS_Store?
40+
._*
41+
.Spotlight-V100
42+
.Trashes
43+
ehthumbs.db
44+
Thumbs.db

.github/workflows/lib/README.md

Lines changed: 80 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# GitHub Approval Automation
22

3-
This module contains the `ApprovalManager` class used by GitHub Actions workflows to automate the approval process for pipeline proposals and RFCs.
3+
This module contains the `ApprovalManager` class and CLI scripts used by GitHub Actions workflows to automate the approval process for pipeline proposals, RFCs, and SIG proposals.
44

55
## Files
66

7-
- `approval.js` - The main ApprovalManager class
8-
- `approval.test.js` - Unit tests for ApprovalManager class
9-
- `workflow-integration.test.js` - Integration tests for complete workflow scenarios
10-
- `package.json` - Node.js package configuration with Jest setup
7+
- `approval.py` - The main ApprovalManager class (Python)
8+
- `scripts/` - Click-based CLI scripts for different proposal types
9+
- `sig_approval.py` - SIG proposal automation
10+
- `rfc_approval.py` - RFC proposal automation
11+
- `pipeline_approval.py` - Pipeline proposal automation
12+
- `tests/` - Pytest test suite
13+
- `test_approval.py` - Unit tests for ApprovalManager class
14+
- `test_workflow_integration.py` - Integration tests for complete workflow scenarios
15+
- `pyproject.toml` - Python package configuration with pytest setup
1116
- `README.md` - This documentation file
1217

1318
## ApprovalManager Class
@@ -21,50 +26,100 @@ The `ApprovalManager` class handles:
2126

2227
### Usage Scenarios
2328

24-
#### Pipeline Proposals
29+
#### SIG Proposals
2530

26-
- **Approval Criteria**: Either 2 core team members OR 1 core team member + 1 maintainer
27-
- **Issue Title Pattern**: Must start with "New Pipeline"
28-
- **Team Roles**: Both core team and maintainers can vote
31+
- **Approval Criteria**: 2 core team members
32+
- **Issue Title Pattern**: Must start with "New special interest group"
33+
- **Team Roles**: Only core team members can vote
2934

3035
#### RFC Proposals
3136

32-
- **Approval Criteria**: Quorum of core team members (Math.ceil(coreTeamMembers.length / 2))
37+
- **Approval Criteria**: Quorum of core team members (ceil(coreTeamMembers.length / 2))
3338
- **Issue Title Pattern**: Must start with "New RFC"
3439
- **Team Roles**: Only core team members can vote
3540

41+
#### Pipeline Proposals
42+
43+
- **Approval Criteria**: Either 2 core team members OR 1 core team member + 1 maintainer
44+
- **Issue Title Pattern**: Must start with "New pipeline"
45+
- **Team Roles**: Both core team and maintainers can vote
46+
47+
## CLI Scripts
48+
49+
Each proposal type has its own Click-based CLI script that can be run directly:
50+
51+
### SIG Approval Script
52+
53+
```bash
54+
uv run python scripts/sig_approval.py \
55+
--github-token="<token>" \
56+
--org="nf-core" \
57+
--repo="proposals" \
58+
--issue-number=123 \
59+
--event-name="issue_comment" \
60+
--event-action="created"
61+
```
62+
63+
### RFC Approval Script
64+
65+
```bash
66+
uv run python scripts/rfc_approval.py \
67+
--github-token="<token>" \
68+
--org="nf-core" \
69+
--repo="proposals" \
70+
--issue-number=123 \
71+
--event-name="issue_comment" \
72+
--event-action="created"
73+
```
74+
75+
### Pipeline Approval Script
76+
77+
```bash
78+
uv run python scripts/pipeline_approval.py \
79+
--github-token="<token>" \
80+
--org="nf-core" \
81+
--repo="proposals" \
82+
--issue-number=123 \
83+
--event-name="issue_comment" \
84+
--event-action="created"
85+
```
86+
3687
## Running Tests
3788

3889
### Prerequisites
3990

40-
Install Node.js and npm, then install Jest:
91+
Install Python 3.11+ and uv for dependency management:
4192

4293
```bash
43-
npm install
94+
# Install uv (if not already installed)
95+
curl -LsSf https://astral.sh/uv/install.sh | sh
96+
97+
# Install dependencies
98+
uv sync
4499
```
45100

46101
### Test Commands
47102

48103
```bash
49104
# Run all tests
50-
npm test
51-
52-
# Run tests in watch mode (reruns on file changes)
53-
npm test:watch
105+
uv run pytest
54106

55107
# Run tests with coverage report
56-
npm test:coverage
108+
uv run pytest --cov=. --cov-report=html
109+
110+
# Run tests in verbose mode
111+
uv run pytest -v
57112
```
58113

59114
## Test Suite
60115

61116
The test suite includes both unit tests and integration tests:
62117

63-
### Unit Tests (`approval.test.js`)
118+
### Unit Tests (`test_approval.py`)
64119

65120
Tests individual methods and functionality of the ApprovalManager class.
66121

67-
### Integration Tests (`workflow-integration.test.js`)
122+
### Integration Tests (`test_workflow_integration.py`)
68123

69124
End-to-end tests that simulate complete workflow scenarios as they would run in GitHub Actions.
70125

@@ -80,6 +135,12 @@ The combined test suites cover:
80135
- ✅ Status comment updates
81136
- ✅ Issue label management
82137

138+
### SIG Proposal Scenarios
139+
140+
- ✅ Approval with 2 core members
141+
- ✅ No approval with only 1 core member
142+
- ✅ Ignoring maintainer votes (core-only)
143+
83144
### Pipeline Proposal Scenarios
84145

85146
- ✅ Approval with 2 core members

0 commit comments

Comments
 (0)