Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Taskfile #148

Merged
merged 9 commits into from
Nov 19, 2024
Merged
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
10 changes: 8 additions & 2 deletions .github/actions/setup-test-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ runs:
with:
github_token: ${{ github.token }}

- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ github.token }}

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -35,8 +41,8 @@ runs:
python-version: ${{ inputs.python-version }}
cache: "pip"

- name: Setup ruff
- name: Setup Python tools
shell: bash
run: |
pip install "ruff >= 0.7.0, < 0.8.0"
ruff --version
pip install pytest-github-actions-annotate-failures
57 changes: 13 additions & 44 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@ jobs:
uses: ./.github/actions/setup-test-environment

- name: Install dependencies
run: |
pip install "python/ommx/[dev]"

- name: Regenerate python codes from proto files
run: |
buf generate --template buf.gen.python.yaml
working-directory: proto
run: pip install "python/ommx/[dev]"

- name: Format generated codes
run: |
ruff format $(find python -type f -regex ".*_pb2.pyi*")
- name: Regenerate python bindings
run: task protogen_python

- name: Check updated
run: |
Expand All @@ -45,10 +38,7 @@ jobs:
uses: ./.github/actions/setup-test-environment

- name: Regenerate stub file
uses: actions-rs/cargo@v1
with:
command: run
args: --bin stub_gen --features=stub_gen
run: task stubgen

- name: Check updated
run: |
Expand All @@ -69,41 +59,18 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install ommx
run: |
pip install -v -e 'python/ommx/[dev]'
pip install pytest-github-actions-annotate-failures

- name: Ruff check
if: always()
run: |
ruff check python

- name: Type check ommx
if: always()
run: |
pyright python/ommx
run: task install_python_sdk

- name: Test ommx
if: always()
run: |
pytest -vv --doctest-modules python/ommx
run: task test_python_sdk

# FIXME: Python-MIP does not support Python 3.12
- name: Install ommx-python-mip-adapter
if: ${{ matrix.python-version != '3.12' }}
run: |
pip install -v -e 'python/ommx-python-mip-adapter/[dev]'

- name: Lint ommx-python-mip-adapter
if: ${{ matrix.python-version != '3.12' }}
run: |
pyright python/ommx-python-mip-adapter/

- name: Test ommx-python-mip-adapter
if: ${{ matrix.python-version != '3.12' }}
run: |
pytest -vv --doctest-modules python/ommx-python-mip-adapter/
markdown-code-runner ./python/ommx-python-mip-adapter/README.md
task install_python_mip_adapter
task test_python_mip_adapter

- name: Run notebooks
if: ${{ github.actor != 'dependabot[bot]' && matrix.python-version != '3.12' }}
Expand All @@ -114,7 +81,7 @@ jobs:
OMMX_BASIC_AUTH_USERNAME: ${{ github.actor }}
OMMX_BASIC_AUTH_PASSWORD: ${{ github.token }}

format:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -123,5 +90,7 @@ jobs:
uses: ./.github/actions/setup-test-environment

- name: Format
run: |
ruff format --check python
run: ruff format --check python

- name: Lint
run: ruff check python
57 changes: 57 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# https://taskfile.dev
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"

tasks:
# Protocol Buffers
protogen:
cmds:
- task: protogen_python
- task: protogen_rust

protogen_python:
cmds:
- task: buf_generate_python
- task: format_python

protogen_rust:
cmds:
- cargo run --bin protogen

buf_generate_python:
cmds:
- buf generate --template buf.gen.python.yaml
dir: proto

# Python
install_python_sdk:
cmds:
- pip install -ve "python/ommx[dev]"

install_python_mip_adapter:
cmds:
- pip install -ve "python/ommx-python-mip-adapter[dev]"

format_python:
cmds:
- ruff format

test_python:
cmds:
- task: test_python_sdk
- task: test_python_mip_adapter

test_python_sdk:
cmds:
- pytest -vv --doctest-modules python/ommx/
- pyright python/ommx/

test_python_mip_adapter:
cmds:
- pytest -vv --doctest-modules python/ommx-python-mip-adapter/
- markdown-code-runner python/ommx-python-mip-adapter/README.md
- pyright python/ommx-python-mip-adapter/

stubgen:
cmds:
- cargo run --bin stub_gen --features=stub_gen
Loading