Skip to content

Commit 2207767

Browse files
committed
add workflows
1 parent f23c7f5 commit 2207767

5 files changed

Lines changed: 147 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.9"
18+
19+
- name: Install build dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install build twine wheel
23+
24+
- name: Build package
25+
run: python -m build
26+
27+
- name: Publish to Test PyPI
28+
env:
29+
TWINE_USERNAME: __token__
30+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
31+
run: |
32+
twine upload --repository testpypi dist/*
33+
34+
- name: Publish to PyPI
35+
if: github.event_name == 'release' && github.event.action == 'published'
36+
env:
37+
TWINE_USERNAME: __token__
38+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
39+
run: |
40+
twine upload dist/*

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.7", "3.8", "3.9", "3.10"]
16+
17+
steps:
18+
- uses: actions/checkout@v3
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 dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install .[test]
29+
30+
- name: Run tests
31+
run: |
32+
pytest tests/ --cov=nt_trading_api --cov-report=xml
33+
34+
- name: Upload coverage to Codecov
35+
uses: codecov/codecov-action@v3
36+
with:
37+
file: ./coverage.xml
38+
fail_ci_if_error: true

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Coverage
24+
.coverage
25+
coverage.xml
26+
htmlcov/
27+
28+
# Virtual Environment
29+
.env
30+
.venv
31+
env/
32+
venv/
33+
ENV/
34+
35+
# IDE
36+
.idea/
37+
.vscode/
38+
*.swp
39+
*.swo
40+
41+
# OS
42+
.DS_Store
43+
Thumbs.db

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include LICENSE
2+
include README.md
3+
include pyproject.toml
4+
include MANIFEST.in
5+
recursive-include tests *.py

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.pytest.ini_options]
6+
testpaths = ["tests"]
7+
python_files = ["test_*.py"]
8+
addopts = "-ra -q --cov=nt_trading_api"
9+
10+
[tool.coverage.run]
11+
source = ["nt_trading_api"]
12+
omit = ["tests/*"]
13+
14+
[tool.coverage.report]
15+
exclude_lines = [
16+
"pragma: no cover",
17+
"def __repr__",
18+
"if __name__ == .__main__.:",
19+
"raise NotImplementedError",
20+
"if TYPE_CHECKING:",
21+
]

0 commit comments

Comments
 (0)