Feature rye (#17)

Migrate from Poetry to Rye 
Adaptat github actions 
Group build targets in makefile
pull/18/head
Yax 1 year ago committed by GitHub
parent b57c4f1ae6
commit 6d53fdecac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,21 +3,22 @@ on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
build_docker:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.10.13]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11.0"
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.2.2
- name: Install dependencies
run: poetry install
- name: Build project
run: poetry build
- name: Checkout code
uses: actions/checkout@v3
- name: Set up rye
uses: atu4403/setup-rye-multiOS@v1
- name: Sync dependencies using rye
run: |
rye pin ${{ matrix.python-version }}
rye sync
rye build --wheel --out dist
- name: Build the Docker image
run: |
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io

@ -2,13 +2,22 @@ name: pyinstaller
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
build_binary:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.10.13]
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3
- name: Set up rye
uses: atu4403/setup-rye-multiOS@v1
- name: Sync dependencies using rye
run: |
rye pin ${{ matrix.python-version }}
rye sync
- name: Package application
uses: JackMcKew/pyinstaller-action-linux@python3.10
with:

@ -2,30 +2,26 @@ name: pytest
on: push
jobs:
ci:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.11.0]
poetry-version: [1.2.2]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
os: [ubuntu-latest]
python-version: [3.10.13]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: poetry install
- name: Checkout code
uses: actions/checkout@v3
- name: Set up rye
uses: atu4403/setup-rye-multiOS@v1
- name: Sync dependencies using rye
run: |
rye pin ${{ matrix.python-version }}
rye sync
- name: Pytest and Coverage
run: |
poetry run coverage run -m --source=stacosys pytest tests
poetry run coverage report
rye run coverage run -m --source=stacosys pytest tests
rye run coverage report
- name: Send report to Coveralls
run: poetry run coveralls
run: rye run coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

@ -1,16 +1,35 @@
all: black test typehint lint
ifeq (run,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
black:
poetry run isort --multi-line 3 --profile black stacosys/ tests/
poetry run black --target-version py311 stacosys/ tests/
.PHONY: all build run test
# code quality
all: black typehint lint
test:
poetry run coverage run -m --source=stacosys pytest
poetry run coverage report
black:
rye run isort --multi-line 3 --profile black src/ tests/
rye run black --target-version py311 src/ tests/
typehint:
poetry run mypy --ignore-missing-imports stacosys/ tests/
rye run mypy --ignore-missing-imports src/ tests/
lint:
poetry run pylint stacosys/
rye run pylint src/
# test
test:
rye run coverage run -m --source=stacosys pytest tests
rye run coverage report
# build
#rye run pyinstaller src/stacosys/run.py --name stacosys --onefile
build:
rye run pyinstaller --clean stacosys.spec
# run
run:
rye run python src/stacosys/run.py $(RUN_ARGS)

@ -1,9 +1,12 @@
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
config.vm.provider :virtualbox do |vb|
vb.memory = 1024
vb.cpus = 1
end
config.vm.define "master" do |master|
master.vm.hostname = "master"
master.vm.provision "shell", inline: <<-SHELL
mkdir /home/vagrant/stacosys
SHELL

@ -1,3 +0,0 @@
#!/bin/sh
#pyinstaller stacosys/run.py --name stacosys --onefile
poetry run pyinstaller stacosys.spec

@ -1,4 +0,0 @@
[flake8]
max-line-length = 88
extend-ignore = E203
spellcheck-targets=comments

1098
poetry.lock generated

File diff suppressed because it is too large Load Diff

@ -1,3 +0,0 @@
[virtualenvs]
in-project = true
prefer-active-python = true

@ -1,30 +1,42 @@
[tool.poetry]
[project]
name = "stacosys"
version = "3.3"
description = "STAtic COmmenting SYStem"
authors = ["Yax"]
authors = [
{ name = "Yax" }
]
readme = "README.md"
requires-python = ">= 3.8"
dependencies = [
"pyrss2gen>=1.1",
"markdown>=3.5.1",
"requests>=2.31.0",
"background>=0.2.1",
"Flask>=3.0.0",
"types-markdown>=3.5.0.1",
"pydal>=20230521.1"
]
[tool.poetry.dependencies]
python = ">=3.9.0,<3.12"
pyrss2gen = "^1.1"
markdown = "^3.1.1"
requests = "^2.25.1"
coverage = "^6.5"
background = "^0.2.1"
Flask = "^2.1.1"
types-markdown = "^3.4.2.1"
pydal = "^20221110.1"
[tool.poetry.group.dev.dependencies]
pylint = "^2.15"
mypy = "^0.991"
pytest = "^7.2.0"
coveralls = "^3.3.1"
pytest-cov = "^4.0.0"
black = "^22.10.0"
pyinstaller = "^5.9.0"
[tool.pytest.ini_options]
pythonpath = [
"src"
]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.rye]
managed = true
dev-dependencies = [
"pylint>=3.0.2",
"mypy>=1.6.1",
"pytest>=7.4.3",
"coveralls>=3.3.1",
"pytest-cov>=4.1.0",
"black>=23.10.1",
"pyinstaller>=6.1.0",
]
[tool.hatch.metadata]
allow-direct-references = true

@ -0,0 +1,53 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
-e file:.
altgraph==0.17.4
astroid==3.0.1
background==0.2.1
black==23.11.0
blinker==1.7.0
certifi==2023.7.22
charset-normalizer==3.3.2
click==8.1.7
coverage==6.5.0
coveralls==3.3.1
dill==0.3.7
docopt==0.6.2
exceptiongroup==1.1.3
flask==3.0.0
idna==3.4
iniconfig==2.0.0
isort==5.12.0
itsdangerous==2.1.2
jinja2==3.1.2
markdown==3.5.1
markupsafe==2.1.3
mccabe==0.7.0
mypy==1.6.1
mypy-extensions==1.0.0
packaging==23.2
pathspec==0.11.2
platformdirs==3.11.0
pluggy==1.3.0
pydal==20230521.1
pyinstaller==6.1.0
pyinstaller-hooks-contrib==2023.10
pylint==3.0.2
pyrss2gen==1.1
pytest==7.4.3
pytest-cov==4.1.0
requests==2.31.0
tomli==2.0.1
tomlkit==0.12.2
types-markdown==3.5.0.1
typing-extensions==4.8.0
urllib3==2.0.7
werkzeug==3.0.1
# The following packages are considered to be unsafe in a requirements file:
setuptools==68.2.2

@ -0,0 +1,26 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
-e file:.
background==0.2.1
blinker==1.7.0
certifi==2023.7.22
charset-normalizer==3.3.2
click==8.1.7
flask==3.0.0
idna==3.4
itsdangerous==2.1.2
jinja2==3.1.2
markdown==3.5.1
markupsafe==2.1.3
pydal==20230521.1
pyrss2gen==1.1
requests==2.31.0
types-markdown==3.5.0.1
urllib3==2.0.7
werkzeug==3.0.1

@ -1,3 +0,0 @@
#!/bin/sh
python3 stacosys/run.py "$@"

@ -5,7 +5,6 @@ from pydal import DAL, Field
class Database:
db_dal = DAL()
def configure(self, db_uri):

@ -30,7 +30,6 @@ class ConfigParameter(Enum):
class Config:
_cfg = configparser.ConfigParser()
def load(self, config_pathname):

@ -1,31 +1,24 @@
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['stacosys/run.py'],
pathex=[],
['src/stacosys/run.py'],
pathex=['src'],
binaries=[],
datas=[('stacosys/interface/templates/*.html', 'stacosys/interface/templates/')],
datas=[('src/stacosys/interface/templates/*.html', 'src/stacosys/interface/templates/')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='stacosys',

@ -83,13 +83,20 @@ def create_comment(url, author_name, content):
def test_find_recent_published_comments(setup_db):
comments = [create_comment("/post", "Adam", "Comment 1"), create_comment("/post", "Arf", "Comment 2"),
create_comment("/post", "Arwin", "Comment 3"), create_comment("/post", "Bill", "Comment 4"),
create_comment("/post", "Bo", "Comment 5"), create_comment("/post", "Charles", "Comment 6"),
create_comment("/post", "Dan", "Comment 7"), create_comment("/post", "Dwayne", "Comment 8"),
create_comment("/post", "Erl", "Comment 9"), create_comment("/post", "Jay", "Comment 10"),
create_comment("/post", "Kenny", "Comment 11"), create_comment("/post", "Lord", "Comment 12")]
comments = [
create_comment("/post", "Adam", "Comment 1"),
create_comment("/post", "Arf", "Comment 2"),
create_comment("/post", "Arwin", "Comment 3"),
create_comment("/post", "Bill", "Comment 4"),
create_comment("/post", "Bo", "Comment 5"),
create_comment("/post", "Charles", "Comment 6"),
create_comment("/post", "Dan", "Comment 7"),
create_comment("/post", "Dwayne", "Comment 8"),
create_comment("/post", "Erl", "Comment 9"),
create_comment("/post", "Jay", "Comment 10"),
create_comment("/post", "Kenny", "Comment 11"),
create_comment("/post", "Lord", "Comment 12"),
]
rows = dao.find_recent_published_comments()
assert len(rows) == 0

Loading…
Cancel
Save