This commit adds a complete testing setup for the prettier_action:
- Adds BATS (Bash Automated Testing System) testing framework
- Creates unit tests for _git_setup() and _git_changed() functions
- Creates plugin validation tests to ensure proper prettier plugin format
- Creates integration tests for end-to-end workflows
- Adds automated test runner script (tests/run_tests.sh)
- Adds GitHub Actions workflow for CI/CD testing
- Includes ShellCheck linting for bash scripts
- Updates README with comprehensive testing documentation
- Updates .gitignore to exclude test artifacts
Test coverage includes:
- Git configuration with different identity modes
- File change detection
- Plugin name validation (official, community, and scoped formats)
- Working directory handling
- node_modules cleanup
- package-lock.json restoration
- only_changed file filtering
- Dry run behavior
The test suite can be run locally with ./tests/run_tests.sh and runs
automatically on all pushes and pull requests.
* allow `only_changed` and `dry` to work together
Before this change, if you tried to use `dry` and `only_changed together, it acted as if `only_changed` was ignored. There was no code specific to `only_changed` down the `dry` code path.
This commit’s solution is to run prettier on the entire code base (as was already being done) and then, before doing any comparisons, reset changes to files that were not modified in the last commit.
* add `only_changed_pr` option
This behaves similarly to only_changed, except instead of only considering files which were modified in the last commit, this option only considers files which were modified in any commit included in the current PR.