Skip to content

Commit a190c55

Browse files
Merge pull request #13 from stefanoamorelli/tests/coverage
2 parents 1c74727 + dcf22f1 commit a190c55

26 files changed

+2166
-392
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Pull Request
2+
3+
## Description
4+
Brief description of changes made.
5+
6+
## Type of Change
7+
- [ ] Bug fix (non-breaking change which fixes an issue)
8+
- [ ] New feature (non-breaking change which adds functionality)
9+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10+
- [ ] Documentation update
11+
- [ ] Refactoring (no functional changes)
12+
13+
## Testing
14+
- [ ] Tests pass locally (`pytest tests/`)
15+
- [ ] New tests added for new functionality
16+
- [ ] Manual testing completed
17+
18+
## Checklist
19+
- [ ] Code follows project style guidelines
20+
- [ ] Self-review of code completed
21+
- [ ] Documentation updated (if applicable)
22+
- [ ] No breaking changes to existing functionality
23+
- [ ] Changes are backwards compatible
24+
25+
## Additional Notes
26+
Any additional information about the changes.

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.13"]
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
27+
with:
28+
version: "latest"
29+
30+
- name: Create virtual environment and install dependencies
31+
run: |
32+
uv venv
33+
uv pip install -e ".[test]"
34+
35+
- name: Run tests
36+
run: |
37+
uv run pytest tests/ -v --tb=short
38+
39+
- name: Test import functionality
40+
run: |
41+
uv run python -c "from nasdaq_data_link_mcp_os.server import mcp; print(f'Server name: {mcp.name}')"
42+
43+
security:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
49+
- name: Run Trivy vulnerability scanner
50+
uses: aquasecurity/trivy-action@master
51+
with:
52+
scan-type: 'fs'
53+
scan-ref: '.'
54+
format: 'sarif'
55+
output: 'trivy-results.sarif'
56+
57+
- name: Upload Trivy scan results to GitHub Security tab
58+
uses: github/codeql-action/upload-sarif@v3
59+
with:
60+
sarif_file: 'trivy-results.sarif'

.github/workflows/test.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.13]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
26+
with:
27+
version: "latest"
28+
29+
- name: Install dependencies
30+
run: |
31+
uv sync --extra test
32+
33+
- name: Run tests
34+
run: |
35+
uv run pytest tests/ -v --tb=short
36+
37+
- name: Run tests with coverage
38+
run: |
39+
uv run pytest tests/ --cov=nasdaq_data_link_mcp_os --cov-report=xml --cov-report=term
40+
41+
- name: Upload coverage to Codecov
42+
uses: codecov/codecov-action@v3
43+
with:
44+
file: ./coverage.xml
45+
flags: unittests
46+
name: codecov-umbrella
47+
fail_ci_if_error: false
48+
49+
lint:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v4
56+
with:
57+
python-version: 3.13
58+
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@v3
61+
with:
62+
version: "latest"
63+
64+
- name: Install dependencies
65+
run: |
66+
uv add --group dev ruff mypy
67+
68+
- name: Run ruff (linter)
69+
run: |
70+
uv run ruff check nasdaq_data_link_mcp_os/ tests/
71+
72+
- name: Run ruff (formatter)
73+
run: |
74+
uv run ruff format --check nasdaq_data_link_mcp_os/ tests/
75+
76+
- name: Run mypy (type checker)
77+
run: |
78+
uv run mypy nasdaq_data_link_mcp_os/ --ignore-missing-imports
79+
continue-on-error: true # Don't fail CI on type errors initially

CONTRIBUTING.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# Contributing to Nasdaq Data Link MCP
2+
3+
Thank you for your interest in contributing to the Nasdaq Data Link MCP Server! This document provides guidelines for contributing to the project.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
9+
- Python 3.13+
10+
- uv package manager
11+
- Git
12+
13+
### Development Setup
14+
15+
1. **Clone the repository**
16+
```bash
17+
git clone https://github.com/stefanoamorelli/nasdaq-data-link-mcp.git
18+
cd nasdaq-data-link-mcp
19+
```
20+
21+
2. **Set up development environment**
22+
```bash
23+
uv init mcp
24+
uv add "mcp[cli]"
25+
uv add --group test "pytest>=7.0" "pytest-mock" "pytest-cov"
26+
```
27+
28+
3. **Configure environment variables**
29+
```bash
30+
cp .env.example .env
31+
# Add your Nasdaq Data Link API key to .env
32+
```
33+
34+
4. **Install the server in development mode**
35+
```bash
36+
uv run mcp install nasdaq_data_link_mcp_os/server.py --env-file .env --name "Nasdaq Data Link MCP Server" --with nasdaq-data-link --with pycountry
37+
```
38+
39+
## Development Workflow
40+
41+
### Code Style
42+
43+
- Follow PEP 8 guidelines
44+
- Use meaningful variable names and clear function signatures
45+
- Add docstrings to all public functions and classes
46+
- Keep functions focused and single-purpose
47+
48+
### Testing
49+
50+
- Write tests for all new functionality
51+
- Run tests before submitting changes:
52+
```bash
53+
uv run pytest tests/
54+
```
55+
- Aim for good test coverage of critical functionality
56+
- Use mocking for external API calls in tests
57+
- All tests must pass in CI before merge
58+
59+
### Code Quality
60+
61+
- Run linting and formatting:
62+
```bash
63+
uv run ruff check nasdaq_data_link_mcp_os/ tests/
64+
uv run ruff format nasdaq_data_link_mcp_os/ tests/
65+
```
66+
- Run type checking:
67+
```bash
68+
uv run mypy nasdaq_data_link_mcp_os/
69+
```
70+
71+
### Documentation
72+
73+
- Update README.md if adding new features
74+
- Update relevant documentation in `docs/` directory
75+
- Include usage examples for new tools
76+
- Update the paper.md if changes affect the research description
77+
78+
## Types of Contributions
79+
80+
### Bug Reports
81+
82+
When filing a bug report, please include:
83+
84+
- Clear description of the issue
85+
- Steps to reproduce the problem
86+
- Expected vs actual behavior
87+
- Python version and environment details
88+
- Relevant error messages or logs
89+
90+
### Feature Requests
91+
92+
For new features, please:
93+
94+
- Describe the use case and motivation
95+
- Explain how it fits with existing functionality
96+
- Consider backward compatibility
97+
- Provide examples of the desired behavior
98+
99+
### Code Contributions
100+
101+
#### Adding New Tools
102+
103+
1. **Create the tool module** in the appropriate resource directory:
104+
```
105+
nasdaq_data_link_mcp_os/resources/[category]/[tool_name].py
106+
```
107+
108+
2. **Follow the existing pattern**:
109+
- Import required dependencies
110+
- Define tool function with proper type hints
111+
- Add comprehensive error handling
112+
- Include docstring with usage examples
113+
114+
3. **Register the tool** in `server.py`:
115+
```python
116+
@server.list_tools()
117+
async def list_tools() -> list[Tool]:
118+
return [
119+
# ... existing tools
120+
Tool(
121+
name="your_new_tool",
122+
description="Clear description of what the tool does",
123+
inputSchema={
124+
"type": "object",
125+
"properties": {
126+
# Define parameters
127+
}
128+
}
129+
)
130+
]
131+
```
132+
133+
4. **Add tests** in `tests/test_tools.py` or create new test file
134+
135+
#### Improving Existing Tools
136+
137+
- Maintain backward compatibility
138+
- Update documentation and examples
139+
- Add tests for new functionality
140+
- Consider edge cases and error handling
141+
142+
## Pull Request Process
143+
144+
1. **Fork the repository** and create a feature branch:
145+
```bash
146+
git checkout -b feature/your-feature-name
147+
```
148+
149+
2. **Make your changes** following the guidelines above
150+
151+
3. **Test thoroughly**:
152+
```bash
153+
uv run pytest tests/
154+
```
155+
156+
4. **Update documentation** as needed
157+
158+
5. **Commit with clear messages**:
159+
```bash
160+
git commit -m "Add feature: description of what was added"
161+
```
162+
163+
6. **Push to your fork** and create a pull request:
164+
```bash
165+
git push origin feature/your-feature-name
166+
```
167+
168+
7. **Describe your changes** in the pull request:
169+
- What was changed and why
170+
- How to test the changes
171+
- Any breaking changes or special considerations
172+
173+
## Code Review
174+
175+
All contributions will be reviewed for:
176+
177+
- Code quality and adherence to project standards
178+
- Test coverage and functionality
179+
- Documentation completeness
180+
- Backward compatibility
181+
- Security considerations
182+
183+
## Community Guidelines
184+
185+
- Be respectful and constructive in discussions
186+
- Help others learn and grow
187+
- Focus on the technical merits of contributions
188+
- Acknowledge the work of others
189+
190+
## Getting Help
191+
192+
- Check existing issues for similar problems
193+
- Ask questions in GitHub Discussions
194+
- Reach out to maintainers if needed
195+
196+
## License
197+
198+
By contributing to this project, you agree that your contributions will be licensed under the same MIT License that covers the project.
199+
200+
## Recognition
201+
202+
Contributors will be acknowledged in:
203+
- GitHub contributor list
204+
- Release notes for significant contributions
205+
- README.md for major features
206+
207+
Thank you for helping make financial data more accessible through conversational AI!

0 commit comments

Comments
 (0)