|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +This directory contains automated CI/CD workflows for the Currents MCP Server project. |
| 4 | + |
| 5 | +## Available Workflows |
| 6 | + |
| 7 | +### `test.yml` - Unit Tests |
| 8 | + |
| 9 | +Runs the unit test suite on every push and pull request. |
| 10 | + |
| 11 | +**Triggers:** |
| 12 | + |
| 13 | +- Push to any branch |
| 14 | +- Pull requests to any branch |
| 15 | + |
| 16 | +**What it does:** |
| 17 | + |
| 18 | +1. Checks out the code |
| 19 | +2. Sets up Node.js (tests on both Node 20.x and 22.x) |
| 20 | +3. Installs dependencies using `npm ci` |
| 21 | +4. Runs the test suite with `npm run test:run` |
| 22 | +5. Generates code coverage reports |
| 23 | +6. Optionally uploads coverage to Codecov (requires `CODECOV_TOKEN` secret) |
| 24 | + |
| 25 | +**Matrix Strategy:** |
| 26 | +The workflow runs tests on multiple Node.js versions to ensure compatibility: |
| 27 | + |
| 28 | +- Node.js 20.x (LTS) |
| 29 | +- Node.js 22.x (Latest) |
| 30 | + |
| 31 | +**Coverage Reports:** |
| 32 | +Coverage reports are generated for all Node versions, but only uploaded from Node 20.x to avoid duplicate reports. Coverage files are located in `mcp-server/coverage/`. |
| 33 | + |
| 34 | +## Secrets |
| 35 | + |
| 36 | +The following secrets can be configured in your repository settings: |
| 37 | + |
| 38 | +- `CODECOV_TOKEN` (optional): Token for uploading coverage reports to Codecov. If not set, the upload step will be skipped without failing the build. |
| 39 | + |
| 40 | +## Local Testing |
| 41 | + |
| 42 | +To run the same tests locally that run in CI: |
| 43 | + |
| 44 | +```bash |
| 45 | +cd mcp-server |
| 46 | +npm ci |
| 47 | +npm run test:run |
| 48 | +npm run test:coverage |
| 49 | +``` |
| 50 | + |
| 51 | +## Troubleshooting |
| 52 | + |
| 53 | +### Tests fail in CI but pass locally |
| 54 | + |
| 55 | +- Ensure you're using the same Node.js version as CI (check the matrix versions) |
| 56 | +- Run `npm ci` instead of `npm install` to ensure exact dependency versions |
| 57 | +- Check for race conditions or timing issues in tests |
| 58 | + |
| 59 | +### Coverage upload fails |
| 60 | + |
| 61 | +- Verify the `CODECOV_TOKEN` secret is set correctly |
| 62 | +- The workflow is configured to not fail if coverage upload fails (`fail_ci_if_error: false`) |
| 63 | + |
| 64 | +### Workflow doesn't trigger |
| 65 | + |
| 66 | +- Ensure the `.github/workflows/` directory is in the root of your repository |
| 67 | +- Check that your branch protection rules aren't preventing the workflow from running |
| 68 | +- Verify the workflow file has proper YAML syntax |
| 69 | + |
| 70 | +## Adding New Workflows |
| 71 | + |
| 72 | +To add a new workflow: |
| 73 | + |
| 74 | +1. Create a new `.yml` file in this directory |
| 75 | +2. Define the workflow name, triggers, and jobs |
| 76 | +3. Test it on a feature branch before merging to main |
| 77 | +4. Document it in this README |
| 78 | + |
| 79 | +For more information on GitHub Actions syntax, see the [official documentation](https://docs.github.com/en/actions). |
0 commit comments