Skip to content

Commit

Permalink
Resolve "Use uv in CI " (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger authored Jan 5, 2025
1 parent 3ef5d85 commit 40301d0
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 161 deletions.
61 changes: 49 additions & 12 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,62 @@ jobs:
with:
python-version: ${{ inputs.python-version }}

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

- name: Check git status (not Windows)
if: runner.os != 'Windows'
run: |
if [[ -z "$(git status --porcelain)" ]]; then
echo "No changes found."
else
echo "Changes detected. Please commit or discard changes before publishing."
git status --porcelain
exit 1
fi
- name: Check git status (Windows)
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install build
if (-not (git status --porcelain)) {
Write-Output "No changes found."
} else {
Write-Output "Changes detected. Please commit or discard changes before publishing."
git status --porcelain
exit 1
}
- name: Build the package
run: python -m build --outdir .
- name: Build Linux
if: runner.os == 'linux'
run: |
uv build .
uv tool install dist/kraken_infinity_grid*.whl
uv run kraken-infinity-grid --version
- name: Install the package on Linux or MacOS
if: runner.os != 'Windows'
run: python -m pip install kraken_infinity_grid*.whl
- name: Build macOS
if: runner.os == 'macOS'
run: |
uv build .
uv tool install dist/kraken_infinity_grid*.whl
uv run kraken-infinity-grid --version
- name: Install the package on Windows
- name: Build Windows
if: runner.os == 'Windows'
run: |
uv build .
try {
$WHEEL = Get-ChildItem -Path . -Filter "kraken_infinity_grid*.whl" -ErrorAction Stop
python -m pip install $WHEEL
$WHEEL = Get-ChildItem -Path ./dist -Filter "kraken_infinity_grid*.whl" -ErrorAction Stop
uv tool install $WHEEL#
uv run kraken-infinity-grid --version
} catch {
Write-Error "Error: .whl file not found in the current directory."
Write-Error "Error: .whl file not found in .\dist."
exit 1
}
- name: Store the distribution packages
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
# upload artifacts with the oldest supported version
if: runner.os == 'linux' && inputs.python-version == '3.11'
with:
name: python-package-distributions
path: dist/
3 changes: 1 addition & 2 deletions .github/workflows/_build_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ jobs:
python-version: 3.11

- name: Install dependencies
run: |
python -m pip install --upgrade pip
run: python -m pip install --upgrade pip

- name: Build the package
run: python -m pip wheel -w dist --no-deps .
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/_pre_commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
Pre-Commit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pre-commit/action@v3.0.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.11"
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
27 changes: 19 additions & 8 deletions .github/workflows/_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,31 @@ jobs:
runs-on: ${{ inputs.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

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

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

- name: Install package (Linux or macOS)
if: runner.os != 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install pytest
uv venv
source .venv/bin/activate
echo ${GITHUB_WORKSPACE}/.venv/bin >> $GITHUB_PATH
uv pip install ".[test]"
- name: Install package
run: python -m pip install ".[dev,test]"
- name: Install package (Windows)
if: runner.os == 'Windows'
run: |
uv venv
.venv\Scripts\activate.ps1
echo "$env:GITHUB_WORKSPACE\.venv\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
uv pip install ".[test]"
- name: Running tests
- name: Run the tests
run: pytest -vv tests
6 changes: 3 additions & 3 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ jobs:
with:
TAG: dev

## Run the unit and acceptance tests
## Run the unit and integration tests
##
Test:
needs: [Build]
uses: ./.github/workflows/_test.yaml
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13"]
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
73 changes: 0 additions & 73 deletions .github/workflows/release.yaml

This file was deleted.

57 changes: 0 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,6 @@

</div>

# TODOs:

- [x] Telegram exception is not receiving messages properly
- [x] Fix the connection aborted error
- [x] If amount something in balance has changed, cancel all open buy orders
- [x] Show current wealth in telegram
- [x] Improve exception handling
- [x] Add script for calculating max drawdown by given input
- [x] Rename balances table to configuration
- [x] Update docstrings in gridbot.py
- [x] Round amounts to n decimals
- [ ] Testing
- [x] Add unit tests
- [x] Add integration tests
- [ ] Add performance/load tests
- [ ] Setup
- [x] Use src layout
- [ ] Use uv in CI
- [ ] Rename the project to infinity-grid-algorithm
- [ ] Add codecov to CI and add badge
- [ ] Add codeql to CI and add badge
- [ ] Add a badges:
- [ ] Latest release (PyPI and GitHub)
- [ ] Documentation
- [ ] License
- [ ] Code style
- [ ] Upload to PyPI
- [ ] Upload to Docker Hub
- [ ] Add harden runner to CI and add badge
- [ ] Add Scripts or site-tools for backtesting
- [ ] Bugs and open questions
- [ ] What if execution while bot is initializing?
- [ ] Call self.close properly after error
- [ ] Resolve FIXMEs and TODOs
- [ ] Add timeout for subscribing to ticker and executions to 20 seconds
- [ ] Fee percentage should be adjustable or depending on the tier
- [ ] Review the full execution flow and think about how to simplify it.
- [ ] Extend integration tests
- [ ] Test unfilled surplus
- [ ] Update balances of mock API and test what happens if balances are not
sufficient.
- [ ] Features
- [ ] Implement proper dryrun (make use of validate trades)
- [ ] Allow for local sqlite database
- [ ] Write the documentation covering:
- [ ] Strategies (don't do switches)
- [ ] Kraken API (use different API keys for different instances)
- [ ] Configuration
- [ ] Troubleshooting
- [ ] Setup
- [ ] Logging
- [ ] Telegram notifications
- [ ] Database configuration
- [ ] Choosing the right strategy
- [ ] Choosing the right interval and amount per grid
- [ ] Backtesting

> ⚠️ **Disclaimer**: This software was initially designed for private use only.
> Please note that this project is independent and not endorsed by Kraken or
> Payward Ltd. Users should be aware that they are using third-party software,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gridbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async def test_on_message_ticker(instance: KrakenInfinityGridBot) -> None:
instance.om.check_price_range.assert_not_called()

# == Ensure saving the last price time
instance.configuration.update.called_once()
instance.configuration.update.assert_called_once()
assert instance.ticker.last == 50000.0

# == Ensure doing nothing if the price did not change
Expand Down
4 changes: 2 additions & 2 deletions tests/test_order_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def test_new_sell_order_GridSell(
)

# == Ensure sell order was placed
strategy.trade.create_order.called_once()
strategy.trade.create_order.assert_called_once()

# == Ensure adding to pending txids
strategy.pending_txids.add.assert_called_once_with("txid2")
Expand Down Expand Up @@ -588,7 +588,7 @@ def test_new_sell_order_GridHODL_SWING(
)

# == Ensure sell order was placed
strategy.trade.create_order.called_once()
strategy.trade.create_order.assert_called_once()

# == Ensure adding to pending txids
strategy.pending_txids.add.assert_called_once_with("txid2")
Expand Down

0 comments on commit 40301d0

Please sign in to comment.