This document explains the complete testing strategy for the Setup Salesforce CLI action.
We use a two-tier testing approach to balance speed with comprehensive coverage:
- Quick Tests (
test.yml) - Fast feedback for development - Cross-Platform Tests (
test-cross-platform.yml) - Comprehensive validation before releases
| Aspect | Quick Tests | Cross-Platform Tests |
|---|---|---|
| File | test.yml |
test-cross-platform.yml |
| When | Every push/PR | PR to action.yml, tags, manual |
| Duration | ~5-10 minutes | ~20-30 minutes |
| Platforms | Ubuntu only | Ubuntu + Windows + macOS |
| Node Versions | Default (20) | 18, 20 |
| Purpose | Development feedback | Release validation |
| Secrets Required | Optional | Optional (manual trigger) |
Provide fast feedback during development. These tests run on every push and PR to ensure basic functionality works.
- Basic authentication
- CLI installation
- Output variables
- Org detection
- CLI installation without authentication
- Works in any fork (no secrets needed)
- Validates action can be used for setup-only scenarios
- sfdx-git-delta installation
- Code analyzer installation
- Strict mode behavior
- Prettier installation
- ESLint installation
- LWC Jest installation
- Tool version verification
- Custom org alias
- Node version selection
- CLI version specification
- Missing required inputs
- Graceful failure behavior
- Error message quality
- Cache creation
- Cache restoration
- Performance improvement verification
- ✅ Every push to
mainordevelop - ✅ Every pull request
- ✅ Manual dispatch for testing
Most tests will skip gracefully if secrets are unavailable (e.g., in forks). Critical tests that don't need secrets will always run:
- CLI Only (No Auth)
- Error Handling
- Cache Behavior
Ensure the action works identically across all supported platforms before releasing new versions.
Tests basic CLI installation on:
- Ubuntu (latest)
- Windows (latest)
- macOS (latest)
- Node 18 and 20
Total: 6 combinations
Tests complete setup with all optional tools on all platforms:
- All plugins (delta, scanner)
- All dev tools (prettier, eslint, jest)
- Strict mode
Total: 3 platforms
Tests caching behavior:
- First run (cache miss)
- Second run (cache hit)
- Platform-specific cache paths
Total: 6 runs (3 platforms × 2 runs)
Tests authentication on all platforms (only runs with secrets):
- JWT authentication
- Org detection
- Output variables
Total: 3 platforms (when enabled)
Tests error handling on all platforms:
- Missing inputs
- Invalid configurations
- Platform-specific error messages
Total: 3 platforms
- ✅ Pull requests that modify
action.yml - ✅ New version tags (
v*) - ✅ Manual dispatch (with optional auth tests)
Ubuntu ✅ Full coverage
Windows ✅ Full coverage
macOS ✅ Full coverage
graph LR
A[Code Change] --> B[Quick Tests]
B --> C{Pass?}
C -->|Yes| D[Continue Development]
C -->|No| E[Fix Issues]
E --> A
graph LR
A[Ready to Release] --> B[Cross-Platform Tests]
B --> C{All Pass?}
C -->|Yes| D[Create Tag]
C -->|No| E[Fix Platform Issues]
E --> A
D --> F[Publish to Marketplace]
# Install act (https://github.com/nektos/act)
brew install act # macOS
# or
choco install act-cli # Windows
# Run quick tests
act -j test-skip-auth # This one doesn't need secrets
# Run with secrets (if available)
act -j test-minimal --secret-file .secretsCross-platform tests are best run in GitHub Actions, but you can test individual platforms:
# Test on current platform
act -j test-cli-install --matrix os:ubuntu-latest
# Note: Windows and macOS testing requires native runnersBefore submitting a PR:
- Run quick tests locally if possible
- Verify
test-skip-authpasses (no secrets needed) - Check that your changes don't break existing functionality
- Add new tests for new features
- Update documentation if behavior changes
Before releasing:
- All quick tests pass
- Cross-platform tests pass on all platforms
- Authentication tests pass (if secrets available)
- Cache tests show performance improvement
- Error handling tests pass
- Check the test logs in GitHub Actions
- Look for the specific step that failed
- Common issues:
- Missing secrets (tests should skip gracefully)
- Authentication failures (check credentials)
- Plugin installation errors (check network)
- Tool installation errors (check package availability)
-
Identify which platform(s) failed
-
Check platform-specific issues:
- Windows: PowerShell syntax, path issues
- macOS: Homebrew availability, slower performance
- Linux: Sudo access, package managers
-
Common cross-platform issues:
- Shell script compatibility (use bash)
- Path separators (use
/even on Windows in bash) - Line endings (configure git properly)
- Case sensitivity (macOS/Linux vs Windows)
Add a new job to test.yml:
test-new-feature:
name: Test New Feature
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup with New Feature
uses: ./
with:
# Your inputs
- name: Verify New Feature
run: |
# Your verificationAdd a new job with matrix to test-cross-platform.yml:
test-new-feature:
name: Test New Feature - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
# Your test stepsWe track these metrics:
- Success Rate: Should be >95%
- Duration: Target <10 minutes
- Coverage: Core functionality
- Success Rate: Should be 100% before release
- Duration: Target <30 minutes
- Coverage: All platforms, all features
- Fail Fast: Tests should fail quickly if something is wrong
- Clear Errors: Error messages should explain what went wrong
- Idempotent: Tests should be runnable multiple times
- Isolated: Tests shouldn't depend on each other
- Documented: Complex tests should have comments
- Maintained: Update tests when features change
Questions about testing? Open an issue or discussion!