This document explains the comprehensive testing strategy for the Setup Salesforce CLI Action. Our testing architecture ensures reliability, security, and cross-platform compatibility through a four-pillar testing approach.
We use a tiered testing approach to balance fast feedback loops with exhaustive validation:
- Critical Tests (
test-critical.yml): Fast, no-secret sanity checks running on every push. - Plugin Tests (
test-plugins.yml): Dedicated validation for ecosystem tools and plugins. - Authentication Tests (
test-auth.yml): Deep validation of all auth methods (requires secrets). - Cross-Platform Tests (
test-cross-platform.yml): Exhaustive matrix validation for releases.
| Workflow | File | Frequency | Focus | Secrets? |
|---|---|---|---|---|
| Critical | test-critical.yml |
Every Push/PR | Core Logic, Caching, Error Handling | ❌ No |
| Plugins | test-plugins.yml |
Every Push/PR | Plugins, Scanners, Dev Tools | ❌ No |
| Auth | test-auth.yml |
Owner Push/Manual | JWT, SFDX URL, Access Token | ✅ Yes |
| Release | test-cross-platform.yml |
Releases/Manual | OS Compatibility, Security |
Purpose: Fast feedback for "did I break the build?" questions. These tests never fail due to missing secrets.
- CLI Installation: Verifies
sfinstalls correctly without auth. - Error Handling: Ensures the action fails gracefully when inputs are missing.
- Cache Behavior: Verifies cache misses (first run) and hits (second run).
- Source Flags: cross-validates output logic for
source_dirs. - Retry Logic: Simulates network failures to test retry mechanisms.
Purpose: Validate the installation and execution of external tools and plugins.
- Custom Plugins: Installs external plugins (e.g.,
sfdx-hardis,@salesforce/plugin-packaging). - Built-in Tools: Verifies
install_scanner,install_deltalogic. - Dev Tools: Checks
prettier,eslint,sfdx-lwc-jest. - Strict Mode: Verifies that invalid plugin names fail the build when
strict: true.
Purpose: Verify that the action can actually authenticate with Salesforce. These tests require repository secrets and typically skip on forks.
- JWT Auth: The gold standard for CI/CD.
- SFDX URL: Alternate auth method.
- Access Token: Using ephemeral tokens minted dynamically.
- Output Validation: Verification of
org_id,username,instance_urloutputs. - Dev Hub: Validates
is_dev_hub: trueconfiguration.
Note: These tests are gated to run only for the repository owner or manual dispatch to prevent failure in forks.
Purpose: The final gate before a release. Ensures behavior is identical across OSs.
- OS: Ubuntu, Windows, macOS
- Node: v18, v20
- Platform Specifics: Checks
timeoutcommand availability (macOS), Path handling (Windows). - Security Hygiene: Verifies removal of
jwt.key,access_token.txtfiles after run (Unix). - Cache Robustness: Verifies detailed cache restoration logic across platforms.
You can use act to run these workflows locally.
# Fastest way to check your changes
act -j summary -W .github/workflows/test-critical.ymlact -j summary -W .github/workflows/test-plugins.ymlCreate a .secrets file with SFDX_JWT_KEY, SFDX_CLIENT_ID, etc.
act -j summary -W .github/workflows/test-auth.yml --secret-file .secrets| Problem | Likely Workflow | Check |
|---|---|---|
| "Action failed with missing inputs" | test-critical |
unexpected strict mode behavior? |
| "Plugin not found" | test-plugins |
NPM registry issues or regex validation error? |
| "Org login failed" | test-auth |
Expired certificate or invalid secrets? |
| "File permission error" | test-cross-platform |
Windows vs Unix chmod logic discrepancy? |
Questions? Open an issue or discussion!