mirror of
https://github.com/LukeHagar/usage-statistics.git
synced 2025-12-06 04:21:55 +00:00
GitHub Action Testing Workflows
This directory contains multiple workflows for testing the Usage Statistics Tracker GitHub Action in different scenarios.
Workflow Files
1. test-action.yml - Test Published Action
- Purpose: Tests the published version of the action from GitHub Marketplace
- Action Reference:
LukeHagar/usage-statistics@latest - Use Case: Verify that the published action works correctly for end users
- Triggers: Push to main, pull requests, manual dispatch
2. test-action-dev.yml - Test Development Action
- Purpose: Tests the development version of the action from the main branch
- Action Reference:
LukeHagar/usage-statistics@main - Use Case: Test changes before publishing a new version
- Triggers: Push to main, pull requests, manual dispatch
3. test-action-local.yml - Test Local Action Build
- Purpose: Tests the locally built action using
./reference - Action Reference:
./(local action) - Use Case: Test the action during development before pushing changes
- Triggers: Push to main, pull requests, manual dispatch
Testing Scenarios
Each workflow tests the action in two modes:
Preview Mode
- Uses
preview-mode: 'true' - Tests with mock data (no external API calls)
- Validates action outputs and file generation
- Expected behavior: No files should be generated in preview mode
Real Data Mode
- Uses actual package names for testing
- Tests with real API calls to external services
- Validates JSON, CSV, and report file generation
- Tests multiple platforms: NPM, GitHub, PyPI, Homebrew, Go
Test Packages Used
The workflows test with these sample packages:
- NPM:
lodash,axios - GitHub:
microsoft/vscode - PyPI:
requests - Homebrew:
git - Go:
github.com/go-chi/chi
Output Validation
Each workflow validates:
- File Generation: Checks if expected files are created
- Action Outputs: Validates action output variables
- JSON Structure: Verifies JSON output format and structure
- CSV Format: Checks CSV headers and data format
- Report Content: Validates markdown report generation
Usage
For Development
Use test-action-local.yml to test your local changes:
# Make changes to your action
# Push to trigger the workflow
git push origin main
For Pre-release Testing
Use test-action-dev.yml to test the main branch version:
# This runs automatically on push to main
# Or trigger manually via GitHub UI
For Release Validation
Use test-action.yml to test the published version:
# This tests the actual published action
# Useful for validating releases
Troubleshooting
Action Not Found
If you get "Action not found" errors:
- Ensure the action is properly built (
bun run action:build) - Check that the action is published to GitHub Marketplace
- Verify the latest version is available
Build Failures
If builds fail:
- Check that all dependencies are installed
- Verify TypeScript compilation
- Ensure the
dist/directory is generated
API Rate Limiting
If you encounter rate limiting:
- The preview mode should work without API calls
- Consider using GitHub tokens for authenticated requests
- Implement proper rate limiting in the action
Best Practices
- Always test locally first: Use
test-action-local.ymlfor initial testing - Test before publishing: Use
test-action-dev.ymlbefore creating releases - Validate published versions: Use
test-action.ymlto ensure releases work - Monitor outputs: Check all generated files and action outputs
- Handle errors gracefully: The workflows include error handling for missing files
Workflow Dependencies
- Bun: Used for building and testing
- jq: Used for JSON validation
- GitHub Actions: Required for running the workflows
- Node.js: Required for action execution (Node 20)
Contributing
When adding new features to the action:
- Update the local test workflow first
- Test with real data to ensure API compatibility
- Update the development workflow if needed
- Test the published version after release