ewega / ewega/copilot-chargeback
Set up comprehensive testing infrastructure for GitHub Actions with act and real GitHub org/team integration
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
# Testing Infrastructure Setup for copilot-chargeback GitHub Action
## Overview
Create a complete testing environment that validates both theoretical functionality and practical implementation of the copilot-chargeback GitHub Action using act (local runner) and real GitHub infrastructure in the "eldrick19-test-ghec" enterprise.
## Detailed Instructions for Copilot Coding Agent
### Phase 1: Local Testing with act Setup
1. **Install and configure act CLI**
- Add act installation instructions to README or separate testing guide
- Create `.actrc` configuration file if needed
- Test basic act functionality with existing workflows
2. **Create comprehensive .env templates**
- `.env.example` with all required environment variables
- `.env.test-org-only` for organization-only sync scenarios
- `.env.test-team-sync` for team-specific sync scenarios
- `.env.test-errors` for error condition testing
- Document each variable's purpose and expected values
3. **Configure act-specific workflow files**
- Create `.github/workflows/test-local.yml` optimized for act execution
- Ensure proper secret handling for local testing
- Add act-specific event triggers and conditions
### Phase 2: GitHub Test Infrastructure Creation
1. **Create test organization in eldrick19-test-ghec enterprise**
- Organization name: `copilot-chargeback-test`
- Configure basic organization settings
- Set up appropriate billing and enterprise association
2. **Create test teams structure**
- Team: `engineering-team` with 3-5 test users
- Team: `design-team` with 2-3 test users
- Team: `empty-team` with no users (edge case testing)
- Ensure teams have appropriate permissions and visibility
3. **Add test users to organization/teams**
- Create or invite test users with clear naming (e.g., `test-user-1`, `test-user-2`)
- Distribute users across teams for realistic testing scenarios
- Document which users belong to which teams
4. **Configure GitHub tokens and permissions**
- Create PAT with org:read, team:read, and team:write permissions
- Test token access to created infrastructure
- Document token setup and security considerations
### Phase 3: Mock Cost Center API Development
1. **Create mock API server**
- Implement in Node.js using Express or similar
- Create separate directory: `test-infrastructure/mock-api/`
- Implement all required endpoints:
- `GET /cost-centers/{name}/users` - return user list
- `POST /cost-centers/{name}/users` - add user
- `DELETE /cost-centers/{name}/users/{username}` - remove user
2. **Add configurable test scenarios**
- Support different response modes (success, failure, partial)
- Implement request logging for debugging
- Add artificial delays to simulate real API behavior
- Support multiple cost centers for testing
3. **Containerize mock API**
- Create Dockerfile for mock API
- Add docker-compose.yml for easy local deployment
- Include health check endpoints
- Document deployment and usage
### Phase 4: Comprehensive Test Suite
1. **Create test scenarios documentation**
- Document each test case with expected inputs/outputs
- Include both positive and negative test cases
- Cover edge cases (empty teams, API failures, rate limiting)
2. **Implement automated test scripts**
- Create `scripts/test-local.sh` for act-based testing
- Create `scripts/test-integration.sh` for GitHub API testing
- Add validation scripts to verify results
- Include cleanup scripts for test data
3. **Add CI/CD integration tests**
- Extend existing `.github/workflows/ci.yml`
- Add integration test job using mock API
- Ensure tests run on PR and main branch changes
### Phase 5: Documentation and Validation
1. **Create comprehensive testing guide**
- File: `docs/TESTING.md`
- Step-by-step instructions for local testing
- Troubleshooting guide for common issues
- Examples of successful test runs
2. **Validate complete testing pipeline**
- Test action locally using act with mock API
- Test action against real GitHub infrastructure
- Verify all error conditions are properly handled
- Confirm cleanup procedures work correctly
## Specific Implementation Requirements
### Environment Variables Template (.env.example)
```
# GitHub Configuration
GITHUB_TOKEN=ghp_your_token_here
GITHUB_ORGANIZATION=copilot-chargeback-test
GITHUB_TEAM=engineering-team
GITHUB_COST_CENTER_NAME=engineering-cost-center
# Mock API Configuration (for local testing)
COST_CENTER_API_BASE_URL=http://localhost:3001
```
### Expected Directory Structure After Completion
```
test-infrastructure/
├── mock-api/
│ ├── server.js
│ ├── package.json
│ ├── Dockerfile
│ └── docker-compose.yml
├── scripts/
│ ├── test-local.sh
│ ├── test-integration.sh
│ └── cleanup.sh
└── fixtures/
├── sample-org-users.json
└── sample-cost-center-users.json
docs/
└── TESTING.md
.env.example
.env.test-org-only
.env.test-team-sync
.env.test-errors
```
## Success Criteria
- [ ] Action can be tested locally using act without external dependencies
- [ ] Integration tests pass against real GitHub APIs using test infrastructure
- [ ] Mock API accurately simulates cost center behavior
- [ ] All error scenarios are covered and properly handled
- [ ] Documentation enables reproduction of testing setup
- [ ] CI/CD pipeline includes automated testing
## Failure Reporting
If any step fails:
1. Document the specific step that failed
2. Include error messages and relevant logs
3. Suggest alternative approaches or troubleshooting steps
4. Request additional permissions or resources if needed
## Resources and References
- [act documentation](https://github.com/nektos/act)
- [GitHub REST API - Organizations](https://docs.github.com/en/rest/orgs)
- [GitHub REST API - Teams](https://docs.github.com/en/rest/teams)
- [GitHub Actions Toolkit](https://github.com/actions/toolkit)
Execute these phases sequentially and report progress after each major milestone.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.