Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjeannesson committed Mar 12, 2024
2 parents 61316dc + d68f255 commit c78dd0a
Show file tree
Hide file tree
Showing 125 changed files with 5,364 additions and 3,058 deletions.
72 changes: 72 additions & 0 deletions .github/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[tool.ruff]

# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
# https://beta.ruff.rs/docs/rules/
lint.select = ["A", "B", "C", "D", "E", "F", "DTZ", "RUF", "S", "COM", "C4", "DJ", "EM", "ISC", "ICN", "PIE", "RET", "SLF", "SIM", "TID", "PD", "NPY"]
lint.ignore = [
"SLF001", # Private member accessed
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D105", # Missing docstring in magic method
"D106", # Missing docstring in public nested class
"D107", # Missing docstring in __init__
"A003", # attribute is shadowing a Python builtin
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the first line
"C901", # McCabe complexity is too high
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF100", # For transition with workflow
]

# Allow autofix for all enabled rules (when `--fix`) is provided
lint.fixable = ["A", "B", "C", "D", "E", "F", "DTZ", "RUF", "S", "COM", "C4", "DJ", "EM", "ISC", "ICN", "PIE", "RET", "SLF", "SIM", "TID", "PD", "NPY"]
lint.unfixable = []

# Exclude a variety of commonly ignored directories.
lint.exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
".venv",
"migrations",
]

lint.pydocstyle.convention ="google"
# Same as Black.
line-length = 150

# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.11.
target-version = "py311"

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "F403", "D104"]

[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = 60
3 changes: 2 additions & 1 deletion .github/workflows/check_no_changes_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Check Workflow Files Changes
on:
pull_request_target:
paths:
- .github/workflows/*
- .github/*
- pyproject.toml

jobs:
check-changes:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}

- name: Linting code with ruff
uses: chartboost/ruff-action@v1
with:
src: "."
args: --config .github/pyproject.toml

- name: Set up python
uses: actions/setup-python@v5
with:
Expand Down
88 changes: 79 additions & 9 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,97 @@ on:
push:
branches:
- main
- feature/mkdocs

permissions:
contents: write

jobs:
deploy:

start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_EC2_IMAGE_ID }}
ec2-instance-type: t3.micro
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SECURITY_GROUP_ID }}



deploy:
needs: start-runner
name: Deploy documentation
runs-on: ${{ needs.start-runner.outputs.label }}
timeout-minutes: 10
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-python@v5
with:
python-version: 3.11
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: |
pip install mkdocs-material
pip install mkdocs-plugin-inline-svg
- run: mkdocs gh-deploy --force
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pip-tools
pip-compile ./requirements/development.txt --output-file ./full-requirements.txt --resolver=backtracking
pip install -r ./full-requirements.txt
- name: Tests with coverage
run: |
export PYTHONPATH="$PYTHONPATH:./django-napse/"
export NAPSE_IS_IN_PIPELINE=True
cd tests/test_app
bash setup_secrets.sh
cd ../..
python3 tests/test_app/manage.py makemigrations && python3 tests/test_app/manage.py migrate
coverage run ./tests/test_app/manage.py test -v2 --keepdb && coverage html
- name: Write open-api schema
run: python tests/test_app/manage.py spectacular --file docs/schema.yml
- name: Deploy documentation
run: |
mkdocs gh-deploy --force
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- deploy # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
4 changes: 3 additions & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

Expand All @@ -28,6 +28,8 @@ jobs:
echo "LATEST_TAG=$tag" >> $GITHUB_ENV
- name: Update version in setup.py
env:
LATEST_TAG: ${{ env.LATEST_TAG }}
run: sed -i "s/{{VERSION}}/${{ env.LATEST_TAG }}/g" setup.py

- name: Install pypa/build
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ MANIFEST
# pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
# htmlcov/
.tox/
.nox/
.coverage
Expand Down
82 changes: 82 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,85 @@
# [1.12.0](https://github.com/napse-invest/django-napse/compare/v1.11.0...v1.12.0) (2024-02-27)


### Bug Fixes

* **Fields:** instance_check is now a static method ([6f773db](https://github.com/napse-invest/django-napse/commit/6f773dbdc3a9f0f53236e737e8a0596f3dcc54e2))
* **serializer:** models check works now well with validated data ([dcb249a](https://github.com/napse-invest/django-napse/commit/dcb249a2b8f6912d60fb77e9eeb19948a5382c3c))
* **serializers:** minor fixes for cleaner code ([f92705b](https://github.com/napse-invest/django-napse/commit/f92705b55ce27eca52dbb492ec027fbafdc3eecd))


### Features

* **serializer:** add validations + model manipulation in serializer + UUIDField and DatetimeField ([34317ca](https://github.com/napse-invest/django-napse/commit/34317ca8a5c211d16dde8eddd6befae89049f21b))

# [1.11.0](https://github.com/napse-invest/django-napse/compare/v1.10.4...v1.11.0) (2024-02-21)


### Bug Fixes

* **bot:** add fleet property ([69d2ca4](https://github.com/napse-invest/django-napse/commit/69d2ca431cf2770a1666a68d94248f86a9a80613))
* **bot:** add space containerization ([66bbba6](https://github.com/napse-invest/django-napse/commit/66bbba693fc0b40787ac3f3c343c3c3fe83973f6))
* **bot:** fix bot_in_cluster issues ([386d841](https://github.com/napse-invest/django-napse/commit/386d8414dd7db814cd19373bf0439ef74809ac07))
* **bot:** return only trading bot in endpoints queryset ([b9bc89f](https://github.com/napse-invest/django-napse/commit/b9bc89f6e91359f2740280d6a8b9e5d50d143bf1))
* **cluster:** rework cluster serializer for fleet creation ([3e00688](https://github.com/napse-invest/django-napse/commit/3e00688a5cd66c89eefc8294b2ac387355bad2d5))
* **db_essentials:** now automatically creates the secrets.json file ([0d4c6c6](https://github.com/napse-invest/django-napse/commit/0d4c6c6339ffd1cc191e896815df7f05fe7e6cfb))
* **fleet:** add delta ([0b1fb5c](https://github.com/napse-invest/django-napse/commit/0b1fb5c7d958984af83c87faef2a33b879cb9f74))
* **fleet:** add return to create() & fix auth ([66fcf9c](https://github.com/napse-invest/django-napse/commit/66fcf9c10f24d9f2b5d8c92fce7dafcd241a06b2))
* **fleet:** add space & exchange_account in FleetDetailSerializer ([1d63d9e](https://github.com/napse-invest/django-napse/commit/1d63d9ef8c846cab9f8d6e200db05932871632e4))
* **fleet:** add to_representation method to FleetSerializer ([91fbe69](https://github.com/napse-invest/django-napse/commit/91fbe691eb08e7879509d26020375c40ae6d7c1d))
* **fleet:** export bout_count method to fleet's model ([1d99f34](https://github.com/napse-invest/django-napse/commit/1d99f34310bc4a184dee5385ccbaf5e37eae2d80))
* **fleet:** finished list, retrieve & create fleet endpoints ([aa12309](https://github.com/napse-invest/django-napse/commit/aa123091d4e171479d95fca6127e94cc38af22ba))
* **fleet:** fix create endpoints ([517985f](https://github.com/napse-invest/django-napse/commit/517985f58e4153d1ae5ef2ae968f06e71125aa87))
* **fleet:** fix issue in space's list endpoint behavior ([e7cd0e8](https://github.com/napse-invest/django-napse/commit/e7cd0e89c1dda8746170eebaccdd44fcfdd4ed69))
* **fleet:** fix retrieve endpoint ([ae4c76b](https://github.com/napse-invest/django-napse/commit/ae4c76bfd6596af1d1e6d82c1f746bdc62ff36cc))
* **fleet:** improve fleet serializer ([dd9b5be](https://github.com/napse-invest/django-napse/commit/dd9b5be68127e1989a937dba8e2d1bcf433a89e3))
* **fleet:** rework list and create fleet endpoints ([ae8bfca](https://github.com/napse-invest/django-napse/commit/ae8bfcac5de94ad9e7b14885c06a5cef7a30d0be))
* **fleet:** space_containers=False situation in list endpoint ([b8ca67a](https://github.com/napse-invest/django-napse/commit/b8ca67aa31530ea61c40ce5029f3d2475dfd00d1))
* free bot list are now contained in exchange account ([b90c762](https://github.com/napse-invest/django-napse/commit/b90c762ba11aa677d96ff8d204a66579d84a9774))
* **history:** add bot history to init.py ([4df6892](https://github.com/napse-invest/django-napse/commit/4df6892b836a0cbd63494108d5e362eed81c9812))
* **makefile:** add shell command to makefile ([7cadbbd](https://github.com/napse-invest/django-napse/commit/7cadbbdf762f5ff06e9533c6be5b7461d6c6143e))
* **makefile:** PHONY setup to force it to work ([3142302](https://github.com/napse-invest/django-napse/commit/31423020e1a8b998789b174a297fac8e7127ed09))
* **order:** order serializer ([8ceb1fc](https://github.com/napse-invest/django-napse/commit/8ceb1fc4dda5b3a84a599b0d39b9078c3b7f334a))
* **order:** rename exit amount ([18db2be](https://github.com/napse-invest/django-napse/commit/18db2bebaa9baf103b77d092ad5df759a07b5721))
* **orders:** improve lisiblity of serializer ([f34cfbc](https://github.com/napse-invest/django-napse/commit/f34cfbccf276f381c95311d77faabb8f72445932))
* **setup:** fix pip-tools installation ([8c41f95](https://github.com/napse-invest/django-napse/commit/8c41f95df87547b6c4c02dbd6b3a67610fef56e0))
* **strategy:** add info method ([8d1ac2c](https://github.com/napse-invest/django-napse/commit/8d1ac2c9e7746f9248f22a779fc6a34ca78f693b))
* **wallet:** connect_to() method works even if the connection already exists ([4995227](https://github.com/napse-invest/django-napse/commit/49952276fcdb3e1152b1876da91fd85bab8bec84))
* **workflow:** pyproject.toml can be only modify by owner ([66b8e94](https://github.com/napse-invest/django-napse/commit/66b8e9468cd8ce7818bf482508ace3f66060ffbb))


### Features

* **bot:** add retrieve view ([806bbee](https://github.com/napse-invest/django-napse/commit/806bbee7b6b918a740c52e2cf79ce2aa35fac2d3))
* **order:** create order serializer ([fb1ca16](https://github.com/napse-invest/django-napse/commit/fb1ca1605bea16decc689e840b28fd1d3c85c544))

## [1.10.4](https://github.com/napse-invest/django-napse/compare/v1.10.3...v1.10.4) (2023-12-21)


### Bug Fixes

* **fleet:** add cluster into serializer ([3f34b00](https://github.com/napse-invest/django-napse/commit/3f34b0066eb4ea018ca9fdc8668f87798ae7811a))

## [1.10.3](https://github.com/napse-invest/django-napse/compare/v1.10.2...v1.10.3) (2023-12-21)


### Bug Fixes

* **docs:** finish mkdocs setup ([a900525](https://github.com/napse-invest/django-napse/commit/a900525b36e19f40cf0019ed35540b673a3727ae))
* **fleet:** improve list endpoint ([039479f](https://github.com/napse-invest/django-napse/commit/039479fb0cd5b1cc15a7ada83cce5b0eb522c73b))
* **space:** remove possible_exchange_account ([2a46272](https://github.com/napse-invest/django-napse/commit/2a4627289b33b537b9c045296cca33090e30d45a))

## [1.10.2](https://github.com/napse-invest/django-napse/compare/v1.10.1...v1.10.2) (2023-11-28)


### Bug Fixes

* **api:** minor fixes ([4a9ff34](https://github.com/napse-invest/django-napse/commit/4a9ff349fe8e9d22e94839e51e10df72aa9298f1))
* **mkdocs & api:** fix currency serializer & mkdocs issues ([ef5a749](https://github.com/napse-invest/django-napse/commit/ef5a7492eb4bab353f259978767742d6a6ce7a4e))
* **mkdocs:** fix mkdocs workflow ([0e9537a](https://github.com/napse-invest/django-napse/commit/0e9537a2241ce2d4483bf5660eca1131e3a321c1))
* **readme:** fix logo ([8aa2d0e](https://github.com/napse-invest/django-napse/commit/8aa2d0eea245bbd1e7373e8f8c487c93ae4647a4))
* **readme:** logo color ([494be3e](https://github.com/napse-invest/django-napse/commit/494be3e65a36f6ae0e369abc05576dfdc0abf8d4))

## [1.10.1](https://github.com/napse-invest/django-napse/compare/v1.10.0...v1.10.1) (2023-11-21)


Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
SHELL := /bin/bash

.PHONY: setup
OS := $(shell uname)

all: setup-testing-environment makemigrations migrate runserver

setup:
ifeq ($(OS),Darwin) # Mac OS X
./setup-osx.sh
./setup/setup-osx.sh
else ifeq ($(OS),Linux)
./setup-unix.sh
./setup/setup-unix.sh
else
./setup-windows.sh
powershell -NoProfile -ExecutionPolicy Bypass -File ".\setup\setup-windows.ps1"
endif

setup-testing-environment:
Expand All @@ -37,6 +37,9 @@ clean:
celery:
source .venv/bin/activate && watchfiles --filter python celery.__main__.main --args "-A tests.test_app worker --beat -l INFO"

shell:
source .venv/bin/activate && python tests/test_app/manage.py shell

test:
source .venv/bin/activate && python tests/test_app/manage.py test -v2 --keepdb --parallel

Expand Down
Loading

0 comments on commit c78dd0a

Please sign in to comment.