Skip to content

Commit 124098d

Browse files
authored
ci: Enable automatic tests execution via Github workflow (#113)
* ci: Enable automatic tests execution via Github workflow * Remove min coverage setting, remove coverage badge
1 parent fd5cd1e commit 124098d

File tree

5 files changed

+66
-69
lines changed

5 files changed

+66
-69
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
# Concurrency group that uses the workflow name and PR number if available
11+
# or commit SHA as a fallback. If a new build is triggered under that
12+
# concurrency group while a previous build is running it will be canceled.
13+
# Repeated pushes to a PR will cancel all previous builds, while multiple
14+
# merges to master will not cancel.
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
tests:
20+
runs-on: ubuntu-24.04
21+
strategy:
22+
matrix:
23+
python-version: ['3.9', '3.11']
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Install poetry
33+
run: make poetry-download
34+
35+
- name: Set up cache
36+
uses: actions/cache@v4
37+
with:
38+
path: .venv
39+
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
40+
41+
- name: Install dependencies
42+
run: |
43+
poetry config virtualenvs.in-project true
44+
poetry install
45+
46+
- name: Run tests
47+
run: |
48+
make test
49+
50+
- name: Archive Coverage Artifacts
51+
uses: actions/upload-artifact@v4
52+
# also upload in case of test failure. this does not affect the overall workflow status
53+
if: always()
54+
with:
55+
name: coverage-html-report-${{ matrix.python-version }}
56+
path: htmlcov
57+
retention-days: 5

Makefile

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,67 @@
11
#* Variables
2-
SHELL := /usr/bin/env bash
3-
PYTHON := python
4-
PYTHONPATH := `pwd`
2+
SHELL := /usr/bin/env bash -o pipefail -o errexit
53

64
#* Installation
7-
.PHONY: install
85
install:
96
poetry lock -n --no-update && poetry export --without-hashes > requirements.txt
107
poetry install -n
118
-poetry run mypy --install-types --non-interactive ./
129

1310
#* Poetry
14-
.PHONY: poetry-download
1511
poetry-download:
16-
curl -sSL https://install.python-poetry.org | $(PYTHON) -
12+
curl -sSL https://install.python-poetry.org | python -
1713

1814
#* Formatters
19-
.PHONY: codestyle
2015
codestyle:
2116
poetry run pyupgrade --exit-zero-even-if-changed --py37-plus **/*.py
2217
poetry run isort --settings-path pyproject.toml ./
2318
poetry run black --config pyproject.toml ./
2419

25-
.PHONY: formatting
2620
formatting: codestyle
2721

2822
#* Linting
29-
.PHONY: test
3023
test:
31-
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --record-mode=once --cov-report=html --cov=hyperliquid tests/
24+
poetry run pytest -c pyproject.toml tests/
3225
poetry run coverage-badge -o assets/images/coverage.svg -f
3326

34-
.PHONY: check-codestyle
3527
check-codestyle:
3628
poetry run isort --diff --check-only --settings-path pyproject.toml ./
3729
poetry run black --diff --check --config pyproject.toml ./
3830
poetry run darglint --verbosity 2 hyperliquid tests
3931

40-
.PHONY: check
4132
check:
4233
poetry run mypy --config-file pyproject.toml ./
4334

44-
.PHONY: check-safety
4535
check-safety:
4636
poetry check
4737
poetry run safety check --full-report
4838
poetry run bandit -ll --recursive hyperliquid tests
4939

50-
.PHONY: lint
5140
lint: test check-codestyle mypy check-safety
5241

53-
.PHONY: update-dev-deps
5442
update-dev-deps:
5543
poetry add -D bandit@latest darglint@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest coverage-badge@latest pytest-cov@latest
5644
poetry add -D --allow-prereleases black@latest
5745

58-
#* Docker
59-
# Example: make docker-build VERSION=latest
60-
# Example: make docker-build IMAGE=some_name VERSION=0.1.0
61-
.PHONY: docker-build
62-
docker-build:
63-
@echo Building docker $(IMAGE):$(VERSION) ...
64-
docker build \
65-
-t $(IMAGE):$(VERSION) . \
66-
-f ./docker/Dockerfile --no-cache
67-
68-
# Example: make docker-remove VERSION=latest
69-
# Example: make docker-remove IMAGE=some_name VERSION=0.1.0
70-
.PHONY: docker-remove
71-
docker-remove:
72-
@echo Removing docker $(IMAGE):$(VERSION) ...
73-
docker rmi -f $(IMAGE):$(VERSION)
74-
7546
#* Cleaning
76-
.PHONY: pycache-remove
7747
pycache-remove:
7848
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf
7949

80-
.PHONY: dsstore-remove
8150
dsstore-remove:
8251
find . | grep -E ".DS_Store" | xargs rm -rf
8352

84-
.PHONY: mypycache-remove
8553
mypycache-remove:
8654
find . | grep -E ".mypy_cache" | xargs rm -rf
8755

88-
.PHONY: ipynbcheckpoints-remove
8956
ipynbcheckpoints-remove:
9057
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf
9158

92-
.PHONY: pytestcache-remove
9359
pytestcache-remove:
9460
find . | grep -E ".pytest_cache" | xargs rm -rf
9561

96-
.PHONY: build-remove
9762
build-remove:
9863
rm -rf build/
9964

100-
.PHONY: cleanup
10165
cleanup: pycache-remove dsstore-remove mypycache-remove ipynbcheckpoints-remove pytestcache-remove
66+
67+
.PHONY: all $(MAKECMDGOALS)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/.pre-commit-config.yaml)
1010
[![Semantic Versions](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--versions-e10079.svg)](https://github.com/hyperliquid-dex/hyperliquid-python-sdk/releases)
1111
[![License](https://img.shields.io/pypi/l/hyperliquid-python-sdk)](https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/LICENSE.md)
12-
![Coverage Report](https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/assets/images/coverage.svg)
1312

1413
SDK for Hyperliquid API trading with Python.
1514

assets/images/coverage.svg

Lines changed: 0 additions & 21 deletions
This file was deleted.

pyproject.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,13 @@ addopts = [
138138
"--tb=short",
139139
"--doctest-modules",
140140
"--doctest-continue-on-failure",
141+
"--record-mode=once",
142+
"--cov-report=html",
143+
"--cov=hyperliquid"
141144
]
142145

143146
[tool.coverage.run]
144-
source = ["tests"]
145-
146-
[coverage.paths]
147-
source = "hyperliquid-python-sdk"
148-
149-
[coverage.run]
150147
branch = true
151148

152-
[coverage.report]
153-
fail_under = 50
149+
[tool.coverage.report]
154150
show_missing = true

0 commit comments

Comments
 (0)