Files
prettier_action/.github/workflows/test.yml
Claude 2b1305afee Add comprehensive testing infrastructure
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.
2025-11-17 16:11:51 +00:00

82 lines
1.8 KiB
YAML

name: Run Tests
on:
push:
branches: [ master, dev, 'claude/**' ]
pull_request:
branches: [ master, dev ]
workflow_dispatch:
jobs:
test:
name: Run BATS Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Install BATS
run: |
cd tests
./run_tests.sh --install-only
- name: Run unit tests
run: |
cd tests
./bats/bin/bats unit_tests.bats
- name: Run plugin validation tests
run: |
cd tests
./bats/bin/bats plugin_validation_tests.bats
- name: Run integration tests
run: |
cd tests
./bats/bin/bats integration_tests.bats
- name: Run all tests with runner script
run: |
./tests/run_tests.sh
test-action:
name: Test Action End-to-End
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create test files
run: |
echo "const x=1;const y=2;" > test.js
echo "function foo(){return 'bar';}" > test2.js
- name: Run prettier action in dry mode
uses: ./
with:
dry: true
prettier_options: "--write --check test*.js"
no_commit: true
github_token: ${{ secrets.GITHUB_TOKEN }}
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: '.'
severity: warning