Skip to content

Commit 884a790

Browse files
author
cav71
authored
Merge pull request #7 from LuxorLabs/pr/luxos-code-refactoring
luxos code refactoring (add async support)
2 parents e2b4d8a + d15e80e commit 884a790

30 files changed

+2021
-567
lines changed

.github/pull_request_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Description
2+
3+
Add your description here.
4+
5+
## Merge request checklist
6+
7+
- [ ] Added the appropriate `bug`, `enhancement` and/or `breaking-change` tags
8+
- [ ] My code passes all tests, linter and formatting checks (`make check`).
9+
- [ ] My commits follow the [How to Write a Git Commit Message Guide](https://chris.beams.io/posts/git-commit/).
10+
- [ ] I have updated the `CHANGELOG` (yeah, last chance to do it).
11+
- [ ] Run the `python make.py onepack` and add the new luxos.pyz/health-checker.pyz
12+
generated files
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: LuxOS Pull-Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
env:
11+
PACKAGE: luxos
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
python-version: ["3.9", "3.10", "3.11", "3.12"]
19+
runs-on: ${{ matrix.os }}
20+
21+
steps:
22+
- name: Set up runner
23+
run: echo noop
24+
25+
- name: Checkout
26+
uses: actions/checkout@v4.1.0
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
29+
30+
- name: Setup Python toolchain
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Python dependencies
36+
shell: bash
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -r tests/requirements.txt
40+
41+
- name: Run Python checks (ruff)
42+
shell: bash
43+
env:
44+
PYTHONPATH: src
45+
run: |
46+
ruff check src tests
47+
48+
- name: Run Python checks (mypy)
49+
shell: bash
50+
env:
51+
PYTHONPATH: src
52+
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
53+
run: |
54+
mypy src \
55+
--no-incremental --xslt-html-report $OUTDIR/mypy
56+
57+
- name: Run Python checks
58+
shell: bash
59+
env:
60+
PYTHONPATH: src
61+
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
62+
run: |
63+
py.test \
64+
--cov=${{ env.PACKAGE }} \
65+
--cov-report=html:$OUTDIR/coverage --cov-report=xml:$OUTDIR/coverage.xml \
66+
--junitxml=$OUTDIR/junit/junit.xml --html=$OUTDIR/junit/junit.html --self-contained-html \
67+
tests
68+
69+
- name: Build wheel packages
70+
if: ${{ ! contains(matrix.os, 'windows') }}
71+
env:
72+
GITHUB_DUMP: ${{ toJson(github) }}
73+
run: |
74+
python -m build
75+
touch .keepme
76+
77+
- name: Archive artifacts
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: qa-results-${{ matrix.python-version }}-${{ matrix.os }}
81+
path: |
82+
build/qa-${{ matrix.python-version }}-${{ matrix.os}}
83+
dist
84+
.keepme
85+
# Use always() to always run this step to publish test results when there are test failures
86+
if: always()

.github/workflows/push-main.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Master build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- '*'
9+
10+
concurrency: ${{ github.workflow }}-${{ github.ref }}
11+
12+
env:
13+
PACKAGE: luxos
14+
15+
jobs:
16+
build:
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
python-version: ["3.9", "3.10", "3.11", "3.12"]
21+
runs-on: ${{ matrix.os }}
22+
23+
steps:
24+
- name: Set up runner
25+
run: echo noop
26+
27+
- name: Checkout
28+
uses: actions/checkout@v4.1.0
29+
with:
30+
ref: ${{ github.event.push.ref }}
31+
32+
- name: Setup Python toolchain
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
37+
- name: Python dependencies
38+
shell: bash
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install -r tests/requirements.txt
42+
43+
- name: Run Python checks (ruff)
44+
shell: bash
45+
env:
46+
PYTHONPATH: src
47+
run: |
48+
ruff check src tests
49+
50+
- name: Run Python checks (mypy)
51+
shell: bash
52+
env:
53+
PYTHONPATH: src
54+
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
55+
run: |
56+
mypy src \
57+
--no-incremental --xslt-html-report $OUTDIR/mypy
58+
59+
- name: Run Python checks
60+
shell: bash
61+
env:
62+
PYTHONPATH: src
63+
OUTDIR: build/qa-${{ matrix.python-version }}-${{ matrix.os}}
64+
run: |
65+
py.test \
66+
--cov=${{ env.PACKAGE }} \
67+
--cov-report=html:$OUTDIR/coverage --cov-report=xml:$OUTDIR/coverage.xml \
68+
--junitxml=$OUTDIR/junit/junit.xml --html=$OUTDIR/junit/junit.html --self-contained-html \
69+
tests
70+
71+
- name: Build wheel packages
72+
if: ${{ ! contains(matrix.os, 'windows') }}
73+
env:
74+
GITHUB_DUMP: ${{ toJson(github) }}
75+
run: |
76+
python -m build
77+
touch .keepme
78+
79+
- name: Archive artifacts
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: qa-results-${{ matrix.python-version }}-${{ matrix.os }}
83+
path: |
84+
build/qa-${{ matrix.python-version }}-${{ matrix.os}}
85+
dist
86+
.keepme
87+
# Use always() to always run this step to publish test results when there are test failures
88+
if: always()

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/myenv
2+
/build
3+
/dist
4+
5+
6+
# Compiled Python files
7+
__pycache__/
8+
*.pyc
9+
*.pyo
10+
*.pyd
11+
12+
# Python virtual environment
13+
venv/
14+
env/
15+
*.env
16+
17+
# System, editor and IDE files
18+
.vscode
19+
.work
20+
.ci-cargo
21+
.idea/
22+
*.swp
23+
*.swo
24+
*~
25+
.project
26+
*.pyproj
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Ignore common temporary files
31+
*.log
32+
*.csv
33+
tmp/
34+
*.tmp
35+
36+
# Sonar artifacts
37+
clippy.log

.pre-commit-config.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# - repo: https://github.com/astral-sh/ruff-pre-commit
2+
# rev: v0.3.4
3+
# hooks:
4+
# - id: ruff
5+
# args: [--fix, --exit-non-zero-on-fix]
6+
#
7+
# - repo: https://github.com/pre-commit/mirrors-mypy
8+
# rev: v1.9.0
9+
# hooks:
10+
# - id: mypy
11+
# exclude: ^(tests)
12+
13+
repos:
14+
- repo: local
15+
hooks:
16+
# repo: https://github.com/astral-sh/ruff-pre-commit
17+
- id: ruff
18+
name: ruff
19+
description: "Run 'ruff' for extremely fast Python linting"
20+
entry: ruff check --force-exclude
21+
language: system
22+
types_or: [python, pyi]
23+
args: []
24+
require_serial: true
25+
additional_dependencies: []
26+
minimum_pre_commit_version: "2.9.2"
27+
28+
- id: ruff-format
29+
name: ruff-format
30+
description: "Run 'ruff format' for extremely fast Python formatting"
31+
entry: ruff format --force-exclude
32+
language: system
33+
types_or: [python, pyi]
34+
args: []
35+
require_serial: true
36+
additional_dependencies: []
37+
minimum_pre_commit_version: "2.9.2"
38+
39+
# https://github.com/pre-commit/mirrors-mypy
40+
- id: mypy
41+
name: mypy
42+
description: ''
43+
entry: mypy
44+
language: system
45+
types_or: [python, pyi]
46+
args: ["--ignore-missing-imports", "--scripts-are-modules"]
47+
require_serial: true
48+
additional_dependencies: []
49+
minimum_pre_commit_version: '2.9.2'

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# LUXOS CHANGELOG
2+
3+
All notable changes to this project will be documented in this file.
4+
<!--
5+
Please, use the format:
6+
7+
## [Unreleased]
8+
9+
- <module>: short description
10+
11+
-->

DEVELOP.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Develop
2+
3+
These are the developer's note, to develop luxos.
4+
5+
> **NOTE** We assume we're working inside the checked out
6+
> `firmware-biz-tools` directory, and you have python (>=3.10)
7+
> in your path.
8+
9+
## Setup
10+
11+
These instructions are useful for a quick start, and
12+
you should be able to:
13+
14+
- **SETUP** the environment (this is done once)
15+
<details><summary>Windows</summary>
16+
17+
```shell
18+
python -m venv myenv
19+
.\myenv\Scripts\activate
20+
21+
pip install -r tests\requirements.txt
22+
pip install -e .
23+
```
24+
</details>
25+
26+
<details><summary>*NIX</summary>
27+
28+
```shell
29+
python -m venv myenv
30+
source ./myenv/bin/activate
31+
32+
pip install -r tests\requirements.txt
33+
pip install -e .
34+
```
35+
36+
- **ACTIVATE** the environment (each time you start a new shell)
37+
<details><summary>Windows</summary>
38+
39+
```shell
40+
.\myenv\Scripts\activate
41+
```
42+
</details>
43+
<details><summary>*NIX</summary>
44+
45+
```shell
46+
source ./myenv/bin/activate
47+
```
48+
</details>
49+
50+
- **RUN** the tests
51+
52+
(Windows & *NIX)
53+
```shell
54+
pytest -vvs tests
55+
```
56+
57+
## Coding
58+
59+
### Precommit
60+
When it comes to coding, you can use [pre-commit](https://pre-commit.com/) hooks
61+
to help you validate code at every git commit.
62+
63+
- **ENABLE** precommit:
64+
```shell
65+
pre-commit install
66+
```
67+
68+
- **DISABLE** precommit:
69+
```shell
70+
pre-commit uninstall
71+
```
72+
73+
- **SKIP CHECKS** during git commit:
74+
Use the `-n` flag:
75+
```shell
76+
git commit -n ....
77+
```
78+
79+
80+
81+
At every `git commit` code scanner [ruff](https://github.com/astral-sh/ruff) and
82+
[mypy](https://mypy-lang.org) will run.

0 commit comments

Comments
 (0)