Skip to content

Commit 1b44b5a

Browse files
Add LICENSE, CI/CD workflow, and issue templates
- Add MIT LICENSE file - Add GitHub Actions workflow for automated testing - Tests on Python 3.11, 3.12, 3.13 - API connection tests - Linting with ruff - Add issue templates (bug report, feature request) - Add pytest configuration - Add ruff configuration for linting - Add test suite for PortWatch API
1 parent 4375889 commit 1b44b5a

7 files changed

Lines changed: 212 additions & 1 deletion

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Bug report
3+
about: Report a bug or issue with the Trade Disruption Monitor
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Bug Description
10+
A clear and concise description of what the bug is.
11+
12+
## Steps to Reproduce
13+
1. Go to '...'
14+
2. Click on '....'
15+
3. Scroll down to '....'
16+
4. See error
17+
18+
## Expected Behavior
19+
A clear and concise description of what you expected to happen.
20+
21+
## Actual Behavior
22+
A clear and concise description of what actually happened.
23+
24+
## Screenshots / Logs
25+
If applicable, add screenshots or logs to help explain your problem.
26+
27+
## Environment
28+
- Python version:
29+
- Operating system:
30+
- Project version/commit:
31+
32+
## Additional Context
33+
Add any other context about the problem here.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea or enhancement for the Trade Disruption Monitor
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Feature Description
10+
A clear and concise description of the feature you'd like to see added.
11+
12+
## Problem Statement
13+
Is your feature request related to a problem? Please describe.
14+
15+
Example: "I'm always frustrated when [...]" or "It would be helpful if [...]" because it would allow me to [...]
16+
17+
## Proposed Solution
18+
Describe the solution you'd like to see implemented.
19+
20+
## Alternatives Considered
21+
Describe any alternative solutions or features you've considered.
22+
23+
## Additional Context
24+
Add any other context, screenshots, or mockups about the feature request here.

.github/workflows/test.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
python-version: ['3.11', '3.12', '3.13']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v2
23+
with:
24+
version: "latest"
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
run: uv python install ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
run: uv sync --dev
31+
32+
- name: Run tests
33+
run: |
34+
uv run python -m pytest tests/ -v --tb=short
35+
36+
- name: Lint with ruff
37+
run: |
38+
uv run ruff check src/ tests/
39+
uv run ruff format --check src/ tests/
40+
41+
api-test:
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Install uv
49+
uses: astral-sh/setup-uv@v2
50+
with:
51+
version: "latest"
52+
53+
- name: Set up Python
54+
run: uv python install 3.12
55+
56+
- name: Install dependencies
57+
run: uv sync
58+
59+
- name: Test API connection
60+
run: |
61+
uv run python -c "
62+
from src.data.portwatch_api import PortWatchAPI
63+
api = PortWatchAPI()
64+
if api.test_connection():
65+
print('✓ API connection successful')
66+
exit(0)
67+
else:
68+
print('✗ API connection failed')
69+
exit(1)
70+
"
71+
72+
- name: Test Malaysian ports fetch
73+
run: |
74+
uv run python -c "
75+
from src.data.portwatch_api import PortWatchAPI
76+
api = PortWatchAPI()
77+
ports = api.get_all_malaysian_ports()
78+
if len(ports) > 0:
79+
print(f'✓ Retrieved {len(ports)} ports')
80+
exit(0)
81+
else:
82+
print('✗ No ports retrieved')
83+
exit(1)
84+
"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 sediamembantu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "trade-disruption"
33
version = "0.1.0"
4-
description = "Add your description here"
4+
description = "Monitor Malaysian maritime trade disruption from Iran conflict using PortWatch data"
55
readme = "README.md"
66
requires-python = ">=3.13"
77
dependencies = [
@@ -13,3 +13,10 @@ dependencies = [
1313
"schedule>=1.2.2",
1414
"seaborn>=0.13.2",
1515
]
16+
17+
[project.optional-dependencies]
18+
dev = [
19+
"pytest>=8.0.0",
20+
"pytest-cov>=4.0.0",
21+
"ruff>=0.6.0",
22+
]

pytest.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[tool.pytest.ini_options]
2+
testpaths = ["tests"]
3+
python_files = ["test_*.py"]
4+
python_classes = ["Test*"]
5+
python_functions = ["test_*"]
6+
addopts = [
7+
"-v",
8+
"--tb=short",
9+
"--strict-markers",
10+
]
11+
markers = [
12+
"slow: marks tests as slow",
13+
"api: marks tests that call external APIs",
14+
]

ruff.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[lint]
2+
select = [
3+
"E", # pycodestyle errors
4+
"W", # pycodestyle warnings
5+
"F", # pyflakes
6+
"I", # isort
7+
"N", # pep8-naming
8+
"UP", # pyupgrade
9+
"B", # flake8-bugbear
10+
"C4", # flake8-comprehensions
11+
"SIM", # flake8-simplify
12+
"T20", # flake8-print
13+
]
14+
ignore = [
15+
"E501", # line too long (handled by formatter)
16+
"T201", # print allowed in this project
17+
"SIM108", # use ternary operator (sometimes less readable)
18+
]
19+
20+
line-length = 100
21+
22+
target-version = "py313"
23+
24+
[format]
25+
line-length = 100
26+
indent-style = "space"
27+
quote-style = "double"
28+
skip-magic-trailing-comma = false

0 commit comments

Comments
 (0)