This document provides guidelines and instructions for setting up the project locally and contributing to its development.
- Node.js: Version 20 or higher (required by the project)
- npm: Usually comes with Node.js
-
Install Dependencies
npm install
-
Package the TypeScript for distribution
npm run bundle
To simulate the GitHub Action locally, you can use the @github/local-action package:
-
Copy the existing
.env.examplefile in your project root:cp .env.example .env
-
Run the action locally:
npm run local-action
-
Test with different working directories by modifying the
.envfile:# Test with a subdirectory echo "INPUT_WORKING-DIRECTORY=./test-dir" > .env npm run local-action
-
For development with real-time changes:
# Build in watch mode npm run package:watch # In another terminal, run the local action npm run local-action
-
Make Your Changes
- Edit files in the
src/directory - Add tests in the
__tests__/directory - Update documentation as needed
- Edit files in the
-
Test Your Changes
# Run tests npm test # Prepare to commit (Check code quality, Format code, Build the project, etc.) npm run all
-
Open a Pull Request
The project uses Jest for testing. Tests are located in the __tests__/ directory.
- Run all tests:
npm test - Run tests in watch mode:
npm test -- --watch - Generate coverage report:
npm run coverage
main.test.ts- Tests for the main action logicversions.test.ts- Tests for version parsing and validationtestdata/- Test fixtures and sample data__fixtures__/- Test mocks
The project enforces code quality through several tools:
- Configuration:
eslint.config.mjs - Run:
npm run lint - Autofix:
npm run lint -- --fix
- Configuration:
.prettierrc(inherited from eslint-config-prettier) - Check formatting:
npm run format:check - Format code:
npm run format:write
- Configuration:
tsconfig.json - The project is written in TypeScript and compiled to JavaScript
- Type checking is integrated into the build process
-
Create a Pull Request
- Fill out the PR template with:
- Description of changes
- Related issues
- Testing performed
- Any breaking changes
- Fill out the PR template with:
-
PR Review Process
- Ensure all CI checks pass
- Address any review comments
- Maintainers will review and merge when ready
By contributing to PHP Version Action, you agree that your contributions will be licensed under the MIT License.