Feature rye (#17)

Migrate from Poetry to Rye 
Adaptat github actions 
Group build targets in makefile
pull/18/head
Yax 12 months 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: push:
branches: [ main ] branches: [ main ]
jobs: jobs:
build: build_docker:
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.10.13]
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- uses: actions/setup-python@v4 uses: actions/checkout@v3
with: - name: Set up rye
python-version: "3.11.0" uses: atu4403/setup-rye-multiOS@v1
- name: Install poetry - name: Sync dependencies using rye
uses: abatilo/actions-poetry@v2 run: |
with: rye pin ${{ matrix.python-version }}
poetry-version: 1.2.2 rye sync
- name: Install dependencies rye build --wheel --out dist
run: poetry install
- name: Build project
run: poetry build
- name: Build the Docker image - name: Build the Docker image
run: | run: |
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io

@ -2,13 +2,22 @@ name: pyinstaller
on: on:
push: push:
branches: [ main ] branches: [ main ]
pull_request:
branches: [ main ]
jobs: jobs:
build: build_binary:
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.10.13]
steps: 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 - name: Package application
uses: JackMcKew/pyinstaller-action-linux@python3.10 uses: JackMcKew/pyinstaller-action-linux@python3.10
with: with:

@ -2,30 +2,26 @@ name: pytest
on: push on: push
jobs: jobs:
ci: test:
runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false
matrix: matrix:
python-version: [3.11.0] os: [ubuntu-latest]
poetry-version: [1.2.2] python-version: [3.10.13]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- uses: actions/setup-python@v4 uses: actions/checkout@v3
with: - name: Set up rye
python-version: ${{ matrix.python-version }} uses: atu4403/setup-rye-multiOS@v1
- name: Install poetry - name: Sync dependencies using rye
uses: abatilo/actions-poetry@v2 run: |
with: rye pin ${{ matrix.python-version }}
poetry-version: ${{ matrix.poetry-version }} rye sync
- name: Install dependencies
run: poetry install
- name: Pytest and Coverage - name: Pytest and Coverage
run: | run: |
poetry run coverage run -m --source=stacosys pytest tests rye run coverage run -m --source=stacosys pytest tests
poetry run coverage report rye run coverage report
- name: Send report to Coveralls - name: Send report to Coveralls
run: poetry run coveralls run: rye run coveralls
env: env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} 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: .PHONY: all build run test
poetry run isort --multi-line 3 --profile black stacosys/ tests/
poetry run black --target-version py311 stacosys/ tests/ # code quality
all: black typehint lint
test: black:
poetry run coverage run -m --source=stacosys pytest rye run isort --multi-line 3 --profile black src/ tests/
poetry run coverage report rye run black --target-version py311 src/ tests/
typehint: typehint:
poetry run mypy --ignore-missing-imports stacosys/ tests/ rye run mypy --ignore-missing-imports src/ tests/
lint: 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| Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64" config.vm.box = "debian/bullseye64"
config.vm.provider :virtualbox do |vb| config.vm.provider :virtualbox do |vb|
vb.memory = 1024
vb.cpus = 1
end end
config.vm.define "master" do |master| config.vm.define "master" do |master|
master.vm.hostname = "master"
master.vm.provision "shell", inline: <<-SHELL master.vm.provision "shell", inline: <<-SHELL
mkdir /home/vagrant/stacosys mkdir /home/vagrant/stacosys
SHELL 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" name = "stacosys"
version = "3.3" version = "3.3"
description = "STAtic COmmenting SYStem" description = "STAtic COmmenting SYStem"
authors = ["Yax"] authors = [
{ name = "Yax" }
]
readme = "README.md" 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] [tool.pytest.ini_options]
python = ">=3.9.0,<3.12" pythonpath = [
pyrss2gen = "^1.1" "src"
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"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["hatchling"]
build-backend = "poetry.core.masonry.api" 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: class Database:
db_dal = DAL() db_dal = DAL()
def configure(self, db_uri): def configure(self, db_uri):

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

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

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

Loading…
Cancel
Save