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

luxos code refactoring (add async support) #7

Merged
merged 23 commits into from
Apr 4, 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
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Description

Add your description here.

## Merge request checklist

- [ ] Added the appropriate `bug`, `enhancement` and/or `breaking-change` tags
- [ ] My code passes all tests, linter and formatting checks (`make check`).
- [ ] My commits follow the [How to Write a Git Commit Message Guide](https://chris.beams.io/posts/git-commit/).
- [ ] I have updated the `CHANGELOG` (yeah, last chance to do it).
- [ ] Run the `python make.py onepack` and add the new luxos.pyz/health-checker.pyz
generated files
86 changes: 86 additions & 0 deletions .github/workflows/pull-python-luxos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: LuxOS Pull-Request

on:
pull_request:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
PACKAGE: luxos

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
- name: Set up runner
run: echo noop

- name: Checkout
uses: actions/checkout@v4.1.0
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Python toolchain
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Python dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt

- name: Run Python checks (ruff)
shell: bash
env:
PYTHONPATH: src
run: |
ruff check src tests

- name: Run Python checks (mypy)
shell: bash
env:
PYTHONPATH: src
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
run: |
mypy src \
--no-incremental --xslt-html-report $OUTDIR/mypy

- name: Run Python checks
shell: bash
env:
PYTHONPATH: src
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
run: |
py.test \
--cov=${{ env.PACKAGE }} \
--cov-report=html:$OUTDIR/coverage --cov-report=xml:$OUTDIR/coverage.xml \
--junitxml=$OUTDIR/junit/junit.xml --html=$OUTDIR/junit/junit.html --self-contained-html \
tests

- name: Build wheel packages
if: ${{ ! contains(matrix.os, 'windows') }}
env:
GITHUB_DUMP: ${{ toJson(github) }}
run: |
python -m build
touch .keepme

- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: qa-results-${{ matrix.python-version }}-${{ matrix.os }}
path: |
build/qa-${{ matrix.python-version }}-${{ matrix.os}}
dist
.keepme
# Use always() to always run this step to publish test results when there are test failures
if: always()
88 changes: 88 additions & 0 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Master build

on:
push:
branches:
- main
tags:
- '*'

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
PACKAGE: luxos

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
- name: Set up runner
run: echo noop

- name: Checkout
uses: actions/checkout@v4.1.0
with:
ref: ${{ github.event.push.ref }}

- name: Setup Python toolchain
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Python dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt

- name: Run Python checks (ruff)
shell: bash
env:
PYTHONPATH: src
run: |
ruff check src tests

- name: Run Python checks (mypy)
shell: bash
env:
PYTHONPATH: src
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
run: |
mypy src \
--no-incremental --xslt-html-report $OUTDIR/mypy

- name: Run Python checks
shell: bash
env:
PYTHONPATH: src
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
run: |
py.test \
--cov=${{ env.PACKAGE }} \
--cov-report=html:$OUTDIR/coverage --cov-report=xml:$OUTDIR/coverage.xml \
--junitxml=$OUTDIR/junit/junit.xml --html=$OUTDIR/junit/junit.html --self-contained-html \
tests

- name: Build wheel packages
if: ${{ ! contains(matrix.os, 'windows') }}
env:
GITHUB_DUMP: ${{ toJson(github) }}
run: |
python -m build
touch .keepme

- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: qa-results-${{ matrix.python-version }}-${{ matrix.os }}
path: |
build/qa-${{ matrix.python-version }}-${{ matrix.os}}
dist
.keepme
# Use always() to always run this step to publish test results when there are test failures
if: always()
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/myenv
/build
/dist


# Compiled Python files
__pycache__/
*.pyc
*.pyo
*.pyd

# Python virtual environment
venv/
env/
*.env

# System, editor and IDE files
.vscode
.work
.ci-cargo
.idea/
*.swp
*.swo
*~
.project
*.pyproj
.DS_Store
Thumbs.db

# Ignore common temporary files
*.log
*.csv
tmp/
*.tmp

# Sonar artifacts
clippy.log
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.3.4
# hooks:
# - id: ruff
# args: [--fix, --exit-non-zero-on-fix]
#
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.9.0
# hooks:
# - id: mypy
# exclude: ^(tests)

repos:
- repo: local
hooks:
# repo: https://github.com/astral-sh/ruff-pre-commit
- id: ruff
name: ruff
description: "Run 'ruff' for extremely fast Python linting"
entry: ruff check --force-exclude
language: system
types_or: [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"

- id: ruff-format
name: ruff-format
description: "Run 'ruff format' for extremely fast Python formatting"
entry: ruff format --force-exclude
language: system
types_or: [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"

# https://github.com/pre-commit/mirrors-mypy
- id: mypy
name: mypy
description: ''
entry: mypy
language: system
types_or: [python, pyi]
args: ["--ignore-missing-imports", "--scripts-are-modules"]
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: '2.9.2'
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# LUXOS CHANGELOG

All notable changes to this project will be documented in this file.
<!--
Please, use the format:

## [Unreleased]

- <module>: short description

-->
82 changes: 82 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Develop

These are the developer's note, to develop luxos.

> **NOTE** We assume we're working inside the checked out
> `firmware-biz-tools` directory, and you have python (>=3.10)
> in your path.

## Setup

These instructions are useful for a quick start, and
you should be able to:

- **SETUP** the environment (this is done once)
<details><summary>Windows</summary>

```shell
python -m venv myenv
.\myenv\Scripts\activate

pip install -r tests\requirements.txt
pip install -e .
```
</details>

<details><summary>*NIX</summary>

```shell
python -m venv myenv
source ./myenv/bin/activate

pip install -r tests\requirements.txt
pip install -e .
```

- **ACTIVATE** the environment (each time you start a new shell)
<details><summary>Windows</summary>

```shell
.\myenv\Scripts\activate
```
</details>
<details><summary>*NIX</summary>

```shell
source ./myenv/bin/activate
```
</details>

- **RUN** the tests

(Windows & *NIX)
```shell
pytest -vvs tests
```

## Coding

### Precommit
When it comes to coding, you can use [pre-commit](https://pre-commit.com/) hooks
to help you validate code at every git commit.

- **ENABLE** precommit:
```shell
pre-commit install
```

- **DISABLE** precommit:
```shell
pre-commit uninstall
```

- **SKIP CHECKS** during git commit:
Use the `-n` flag:
```shell
git commit -n ....
```



At every `git commit` code scanner [ruff](https://github.com/astral-sh/ruff) and
[mypy](https://mypy-lang.org) will run.
Loading