Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
91 changes: 40 additions & 51 deletions .github/workflows/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,57 +1,46 @@
# Dependencies
node_modules/

# Coverage reports
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python

# Virtual environments
.venv/
venv/
env/

# uv cache
.uv-cache/

# Testing & Coverage
.pytest_cache/
.coverage
htmlcov/
.tox/
coverage/
coverage.xml

# Jest cache
.cache/

# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity
# Build artifacts
build/
dist/
*.egg-info/

# dotenv environment variables file
# Environment variables
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
# IDEs and editors
.vscode/
.idea/
*.swp
*.swo

# OS files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
99 changes: 80 additions & 19 deletions .github/workflows/lib/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# GitHub Approval Automation

This module contains the `ApprovalManager` class used by GitHub Actions workflows to automate the approval process for pipeline proposals and RFCs.
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.

## Files

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

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

### Usage Scenarios

#### Pipeline Proposals
#### SIG Proposals

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

#### RFC Proposals

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

#### Pipeline Proposals

- **Approval Criteria**: Either 2 core team members OR 1 core team member + 1 maintainer
- **Issue Title Pattern**: Must start with "New pipeline"
- **Team Roles**: Both core team and maintainers can vote

## CLI Scripts

Each proposal type has its own rich-click-based CLI script that can be run directly with beautiful formatting:

### SIG Approval Script

```bash
uv run python scripts/sig_approval.py \
--github-token="<token>" \
--org="nf-core" \
--repo="proposals" \
--issue-number=123 \
--event-name="issue_comment" \
--event-action="created"
```

### RFC Approval Script

```bash
uv run python scripts/rfc_approval.py \
--github-token="<token>" \
--org="nf-core" \
--repo="proposals" \
--issue-number=123 \
--event-name="issue_comment" \
--event-action="created"
```

### Pipeline Approval Script

```bash
uv run python scripts/pipeline_approval.py \
--github-token="<token>" \
--org="nf-core" \
--repo="proposals" \
--issue-number=123 \
--event-name="issue_comment" \
--event-action="created"
```

## Running Tests

### Prerequisites

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

```bash
npm install
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
uv sync
```

### Test Commands

```bash
# Run all tests
npm test

# Run tests in watch mode (reruns on file changes)
npm test:watch
uv run pytest

# Run tests with coverage report
npm test:coverage
uv run pytest --cov=. --cov-report=html

# Run tests in verbose mode
uv run pytest -v
```

## Test Suite

The test suite includes both unit tests and integration tests:

### Unit Tests (`approval.test.js`)
### Unit Tests (`test_approval.py`)

Tests individual methods and functionality of the ApprovalManager class.

### Integration Tests (`workflow-integration.test.js`)
### Integration Tests (`test_workflow_integration.py`)

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

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

### SIG Proposal Scenarios

- ✅ Approval with 2 core members
- ✅ No approval with only 1 core member
- ✅ Ignoring maintainer votes (core-only)

### Pipeline Proposal Scenarios

- ✅ Approval with 2 core members
Expand Down
Loading