Skip to content

Commit

Permalink
Resolve "Add codecov to CI" (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger authored Jan 13, 2025
1 parent 618e9bc commit 71c6445
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 15 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/_codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2025 Benjamin Thomas Schwertfeger
# GitHub: https://github.com/btschwertfeger
#
# Template workflow to build the project for a specific os and Python version,
# run the tests and upload the results to codecov.
#

name: CodeCov

on:
workflow_call:
inputs:
os:
type: string
required: true
python-version:
type: string
required: true
secrets:
CODECOV_TOKEN:
required: true

permissions:
contents: read

jobs:
CodeCov:
name: Coverage
runs-on: ${{ inputs.os }}
timeout-minutes: 10
env:
OS: ${{ inputs.os }}
PYTHON: ${{ inputs.python-version }}

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
allowed-endpoints: >
api.codecov.io:443
api.kraken.com:443
api.github.com:443
cli.codecov.io:443
files.pythonhosted.org:443
github.com:443
objects.githubusercontent.com:443
pypi.org:443
storage.googleapis.com:443
ws-auth.kraken.com:443
ws.kraken.com:443
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ inputs.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install package
run: |
uv venv
source .venv/bin/activate
echo ${GITHUB_WORKSPACE}/.venv/bin >> $GITHUB_PATH
uv pip install ".[test,dev]"
- name: Generate coverage report
run: pytest -vv --cov --cov-report=xml:coverage.xml tests

- name: Export coverage report
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
env_vars: OS,PYTHON
fail_ci_if_error: true
flags: unittests
name: codecov-umbrella
verbose: true
22 changes: 20 additions & 2 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ jobs:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}

## ===========================================================================
## Generates and uploads the coverage statistics to codecov
##
CodeCov:
if: |
(success() && github.actor == 'btschwertfeger')
&& (github.event_name == 'push' || github.event_name == 'release')
needs:
- Test
uses: ./.github/workflows/_codecov.yaml
with:
os: "ubuntu-latest"
python-version: "3.11"
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

## ===========================================================================
## Uploads the package to test.pypi.org on master if triggered by
## a regular commit/push.
Expand All @@ -97,7 +113,8 @@ jobs:
needs:
- Build
- Build-Doc
- Test
- CodeCov
- CodeQL
name: Upload development version to Test PyPI
uses: ./.github/workflows/_pypi_test_publish.yaml
secrets:
Expand All @@ -114,7 +131,8 @@ jobs:
needs:
- Build
- Build-Doc
- Test
- CodeCov
- CodeQL
name: Upload release to PyPI
uses: ./.github/workflows/_pypi_publish.yaml
secrets:
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Typing](https://img.shields.io/badge/typing-mypy-informational)](https://mypy-lang.org/)
[![CI/CD](https://github.com/btschwertfeger/kraken-infinity-grid/actions/workflows/cicd.yaml/badge.svg?branch=master)](https://github.com/btschwertfeger/kraken-infinity-grid/actions/workflows/cicd.yaml)

<!-- [![codecov](https://codecov.io/gh/btschwertfeger/kraken-infinity-grid/branch/master/badge.svg)](https://app.codecov.io/gh/btschwertfeger/kraken-infinity-grid) -->
[![codecov](https://codecov.io/gh/btschwertfeger/kraken-infinity-grid/branch/master/badge.svg)](https://app.codecov.io/gh/btschwertfeger/kraken-infinity-grid)

[![release](https://shields.io/github/release-date/btschwertfeger/kraken-infinity-grid)](https://github.com/btschwertfeger/kraken-infinity-grid/releases)
[![release](https://img.shields.io/pypi/v/kraken-infinity-grid)](https://pypi.org/project/kraken-infinity-grid/)
[![Documentation Status Stable](https://readthedocs.org/projects/kraken-infinity-grid/badge/?version=stable)](https://kraken-infinity-grid.readthedocs.io/en/stable)

</div>

Expand Down Expand Up @@ -50,6 +50,11 @@ on the algorithms's activity and exceptions. For this the algorithm requires two
different Telegram bot tokens and chat IDs, one for regular notifications and
one for exception notifications (see [Setup](#Setup) for more information).

Documentation:

- https://kraken-infinity-grid.readthedocs.io/en/latest/
- https://kraken-infinity-grid.readthedocs.io/en/stable/

## 📚 Fundamental concepts

`kraken-infinity-grid` is a sophisticated trading algorithm designed for
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Welcome to kraken-infinity-grid's documentation!
================================================

|GitHub badge| |PyVersions badge| |Downloads badge|
|CI/CD badge| |Typing badge|
|CI/CD badge| |Typing badge| |codecov badge|
|Release date badge| |Release version badge|

.. toctree::
Expand Down
2 changes: 1 addition & 1 deletion doc/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Introduction
============

|GitHub badge| |PyVersions badge| |Downloads badge|
|CI/CD badge| |Typing badge|
|CI/CD badge| |Typing badge| |codecov badge|
|Release date badge| |Release version badge|


Expand Down
6 changes: 3 additions & 3 deletions doc/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
.. _Kraken: https://pro.kraken.com
.. _python-kraken-sdk: https://github.com/btschwertfeger/python-kraken-sdk
.. _kraken-infinity-grid: https://github.com/btschwertfeger/kraken-infinity-grid
.. _kraken-infinity-grid/issues: https://github.com/btschwertfeger/kraken-infinity-grid/issues
.. _kraken-infinity-grid/discussions: https://github.com/btschwertfeger/kraken-infinity-grid/discussions
.. _kraken-infinity-grid: https://github.com/btschwertfeger/kraken-infinity-grid
.. _kraken-infinity-grid/issues: https://github.com/btschwertfeger/kraken-infinity-grid/issues
.. _kraken-infinity-grid/discussions: https://github.com/btschwertfeger/kraken-infinity-grid/discussions

.. BADGES
Expand Down
4 changes: 0 additions & 4 deletions src/kraken_infinity_grid/gridbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,7 @@ async def on_message( # noqa: C901, PLR0912
# 5012.66172606, 'vwap': 106355.8, 'low': 103207.8, 'high':
# 108297.6, 'change': -2800.0, 'change_pct': -2.62}]}
self.configuration.update({"last_price_time": datetime.now()})

# last_price = self.ticker.last
self.ticker = SimpleNamespace(last=float(data[0]["last"]))
# if last_price == self.ticker.last:
# return

if self.unsold_buy_order_txids.count() != 0:
self.om.add_missed_sell_orders()
Expand Down
2 changes: 0 additions & 2 deletions src/kraken_infinity_grid/order_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@ def new_buy_order(
)

self.__s.pending_txids.add(placed_order["txid"][0])
# if txid_to_delete is not None:
# self.__s.orderbook.remove(filters={"txid": txid_to_delete})
self.__s.om.assign_order_by_txid(placed_order["txid"][0])
return

Expand Down

0 comments on commit 71c6445

Please sign in to comment.