Skip to content
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
88 changes: 15 additions & 73 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Unit test

on:
Expand All @@ -9,116 +6,61 @@ on:

jobs:
ut:

runs-on: ${{ matrix.os }}
strategy:
matrix:
# Github action runner update ubuntu to 22.04, which does not have
# python-3.6 in it: https://github.com/actions/setup-python/issues/544#issuecomment-1320295576
# To fix it: use os: [ubuntu-20.04] instead
os: [ubuntu-latest]
python-version: [3.9, "3.10", 3.11, 3.12]

steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Install npm dependencies
run: |
if [ -f package.json ]; then npm install; fi

# manually add module binary path to github ci
echo "add node module path: $GITHUB_WORKSPACE/node_modules/.bin/"
echo "$GITHUB_WORKSPACE/node_modules/.bin/" >> $GITHUB_PATH

- name: Install apt dependencies
run: |
if [ -f packages.txt ]; then cat packages.txt | xargs sudo apt-get install; fi
pip install pytest k3ut
pip install -e .
- name: Test with pytest
env:
# interactive command such as k3handy.cmdtty to run git, git complains
# if no TERM set:
# out: - (press RETURN)
# err: WARNING: terminal is not fully functional
# And waiting for a RETURN to press for ever
TERM: xterm
run: |
cp setup.py ..
cd ..
python setup.py install
cd -

if [ -f sudo_test ]; then
sudo env "PATH=$PATH" pytest -v
else
pytest -v
fi

- uses: actions/upload-artifact@v4
if: failure()
with:
path: test/
pytest -v

build_doc:

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

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi

- name: Test building doc
run: |
pip install -r _building/building-requirements.txt
make -C docs html
pip install -e .
pip install mkdocs mkdocs-material "mkdocstrings[python]"
mkdocs build

lint:

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

steps:
- uses: actions/checkout@v5

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi

- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install ruff
ruff check .
ruff format --check .
44 changes: 20 additions & 24 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
Expand All @@ -10,27 +7,26 @@ on:

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
cp setup.py ..
cd ..
python setup.py sdist bdist_wheel
pip install dist/*.tar.gz
python -c 'import '${GITHUB_REPOSITORY#*/}
twine upload dist/*
- uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: python -m build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,4 @@ dmypy.json
.pyre/

.claude/
site/
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

mkdocs:
configuration: mkdocs.yml

python:
install:
- method: pip
path: .
extra_requirements:
- docs
9 changes: 5 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
# from .proc import CalledProcessError
# from .proc import ProcError

__version__ = "0.1.1"
__name__ = "k3utfjson"
from importlib.metadata import version

__version__ = version("k3utfjson")

from .utfjson import (
dump,
load,
)

__all__ = [
'dump',
'load',
"dump",
"load",
]
129 changes: 0 additions & 129 deletions _building/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions _building/Makefile

This file was deleted.

Loading