|
| 1 | +# Continuous Integration (CI) Setup |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project uses GitHub Actions for continuous integration to ensure code quality through automated linting and formatting checks. The CI workflow runs on every push to the main branch and on pull requests. |
| 6 | + |
| 7 | +## Workflow Configuration |
| 8 | + |
| 9 | +The CI workflow is defined in `.github/workflows/lint.yml` and performs the following steps: |
| 10 | + |
| 11 | +1. **Checkout Code**: Fetches the repository code with full history for proper lockfile validation |
| 12 | +2. **Setup pnpm**: Installs the pnpm package manager (version 8.15.4) |
| 13 | +3. **Setup Node.js**: Configures Node.js environment (version 20.3.0) with pnpm caching |
| 14 | +4. **Install Dependencies**: Installs project dependencies using pnpm |
| 15 | +5. **Check Formatting**: Verifies code formatting using Biome |
| 16 | +6. **Run Linting**: Performs code linting using Biome |
| 17 | + |
| 18 | +## Important Notes on Dependency Management |
| 19 | + |
| 20 | +### Lockfile Handling |
| 21 | + |
| 22 | +The CI workflow is configured to handle the pnpm lockfile (`pnpm-lock.yaml`) properly by: |
| 23 | + |
| 24 | +- Using `fetch-depth: 0` in the checkout step to ensure the complete repository history is available |
| 25 | +- Using standard `pnpm install` instead of `--frozen-lockfile` to avoid issues with lockfile compatibility in CI environments |
| 26 | + |
| 27 | +### Node.js Version |
| 28 | + |
| 29 | +The project requires Node.js version 20.3.0 or higher, which is specified in: |
| 30 | + |
| 31 | +- `package.json` via the `engines` field |
| 32 | +- `.nvmrc` file for local development with nvm |
| 33 | + |
| 34 | +## Troubleshooting CI Issues |
| 35 | + |
| 36 | +### Common Problems |
| 37 | + |
| 38 | +1. **Lockfile Compatibility Issues**: |
| 39 | + - Error: `WARN Ignoring not compatible lockfile` or `ERR_PNPM_NO_LOCKFILE` |
| 40 | + - Solution: Ensure the lockfile is properly committed and use `pnpm install` without the `--frozen-lockfile` flag in CI |
| 41 | + |
| 42 | +2. **Node.js Version Mismatch**: |
| 43 | + - Error: Issues related to Node.js version compatibility |
| 44 | + - Solution: Ensure the Node.js version in CI matches the requirements in `package.json` |
| 45 | + |
| 46 | +### Resolving Dependency Issues |
| 47 | + |
| 48 | +If you encounter dependency-related issues in CI: |
| 49 | + |
| 50 | +1. Update your local environment to match the CI configuration |
| 51 | +2. Run `pnpm install` locally to generate a fresh lockfile |
| 52 | +3. Commit the updated lockfile |
| 53 | +4. Push the changes to trigger a new CI run |
| 54 | + |
| 55 | +## Best Practices |
| 56 | + |
| 57 | +1. Always commit the `pnpm-lock.yaml` file to ensure consistent dependencies |
| 58 | +2. Use the same Node.js and pnpm versions locally as specified in the CI workflow |
| 59 | +3. Avoid manually editing the lockfile |
| 60 | +4. When adding new dependencies, update the lockfile by running `pnpm install` and commit the changes |
| 61 | +5. If you're experiencing CI failures related to the lockfile, try removing the `--frozen-lockfile` flag in your local environment |
0 commit comments