Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,24 @@ layout_poetry () {
export VIRTUAL_ENV
}

layout_uv() {
if [[ -d ".venv" ]]; then
VIRTUAL_ENV="$(pwd)/.venv"
fi

if [[ -z $VIRTUAL_ENV || ! -d $VIRTUAL_ENV ]]; then
log_status "No virtual environment exists. Executing \`uv venv\` to create one."
uv venv
VIRTUAL_ENV="$(pwd)/.venv"
fi

PATH_add "$VIRTUAL_ENV/bin"

export UV_ACTIVE=1 # or VENV_ACTIVE=1
export VIRTUAL_ENV
}

use flake
layout poetry

layout uv
uv sync
88 changes: 88 additions & 0 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Check Code

permissions:
contents: read

on:
workflow_dispatch:
pull_request:
push:
branches: [main, test-ci]
paths:
- "src/**"
- "tests/**"
- "pyproject.toml"
- "uv.lock"
- "nix/**"
- "flake.nix"
- "flake.lock"
- ".github/workflows/check-code.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-code:
# Ubicloud managed runner
runs-on: ubicloud-standard-2

strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.12"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Setup uv (with caching)
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
ignore-nothing-to-cache: true

# - name: Create venv for ${{ matrix.python-version }}
# run: uv venv --python ${{ matrix.python-version }}

- name: Sync dependencies
run: uv sync --python ${{ matrix.python-version }} --frozen

# Optional: prove we're using the right interpreter
- name: Show Python used by uv
run: uv run --python ${{ matrix.python-version }} python -V

- name: Lint
run: uv run --python ${{ matrix.python-version }} ruff check ./src

- name: Typecheck
run: |
uv run --python ${{ matrix.python-version }} basedpyright ./src

- name: Check formatting
run: |
uv run --python ${{ matrix.python-version }} ruff format --check ./src

- name: Test
run: uv run --python ${{ matrix.python-version }} pytest -q

- name: Coverage
run: uv run --python ${{ matrix.python-version }} pytest --cov=torusdk --cov-report=term-missing --cov-report=xml

- name: Upload coverage XML
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: coverage.xml

# - name: Enforce Towncrier fragment on PRs
# if: ${{ github.event_name == 'pull_request' }}
# run: uv run --python ${{ matrix.python-version }} towncrier check --compare-with origin/main

- name: Build package
run: uv run --python ${{ matrix.python-version }} uv build
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ name: Nix checks
on:
pull_request:
push:
branches: [main, dev]
branches: [main, test-ci]

jobs:
checks:
check-nix:
runs-on: ubicloud-standard-2
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

# - uses: DeterminateSystems/magic-nix-cache-action@main

- name: Check health of flake.lock
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/tests.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/type-checker.yml

This file was deleted.

9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.direnv
# Local files
*.local.*

# Nix / direnv
/.direnv


# ==== Python ====

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
6 changes: 4 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"recommendations": [
"editorconfig.editorconfig",
"jnoortheen.nix-ide",
"skellock.just",
// Python
"ms-python.python",
"ms-python.debugpy",
"detachhead.basedpyright",
"charliermarsh.ruff"
]
}
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
{
"cSpell.words": [
"aiohttp",
"basedpyright",
"dmap",
"fastapi",
"keypair",
"netuid",
"openai",
"pdoc",
"pydantic",
"pyproject",
"subtable",
"torus",
"torustrateinterface",
"towncrier",
"typeguard",
"typer",
"unstake",
"uvicorn"
],
// "python.analysis.extraPaths": ["./sources"],
"python.analysis.typeCheckingMode": "off",
"python.autoComplete.extraPaths": [
"/home/manjairo/tcheco/torustrate-interface"
]
}
}
18 changes: 11 additions & 7 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
"version": "2.0.0",
"tasks": [
{
"label": "pyright file",
"label": "typecheck file",
"type": "shell",
"command": "pyright ${file}"
"command": "basedpyright ${file}"
},
{
"label": "autopep8 file",
"label": "format file",
"type": "shell",
"command": "autopep8 --in-place --aggressive --aggressive ${file}"
"command": "ruff format ${file}"
},
{
"label": "isort file",
"label": "lint file",
"type": "shell",
"command": "isort ${file}"
"command": "ruff check --fix ${file}"
},

{
"label": "run tests",
"type": "shell",
"command": "just test"
}
]
}
Loading