mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-21 15:31:00 +00:00
Edit publish workflow to reuse existing test workflow, and use the build package to build the libretranslate package
This commit is contained in:
parent
1c0fb597fb
commit
a1eb871bb6
5 changed files with 20 additions and 66 deletions
49
.github/workflows/publish-package.yml
vendored
49
.github/workflows/publish-package.yml
vendored
|
@ -9,35 +9,8 @@ on:
|
|||
jobs:
|
||||
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.8', '3.9', '3.10']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pytest flake8
|
||||
pip install .
|
||||
python scripts/compile_locales.py
|
||||
|
||||
- name: Check code style with flake8 (lint)
|
||||
run: |
|
||||
# warnings if there are Python syntax errors or undefined names
|
||||
# (remove --exit-zero to fail when syntax error)
|
||||
flake8 . --count --exit-zero --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
|
||||
|
||||
- name: Test with pytest
|
||||
run: pytest
|
||||
uses: LibreTranslate/LibreTranslate/.github/workflows/run-tests.yml@main
|
||||
secrets: inherit
|
||||
|
||||
|
||||
publish:
|
||||
|
@ -52,16 +25,16 @@ jobs:
|
|||
python-version: '3.8'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install setuptools wheel twine
|
||||
python setup.py sdist bdist_wheel
|
||||
pipx install build
|
||||
|
||||
- name: Build and publish to PyPI
|
||||
env:
|
||||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||
- name: Build
|
||||
run: |
|
||||
pip install Babel==2.11.0
|
||||
python scripts/compile_locales.py
|
||||
python setup.py sdist bdist_wheel
|
||||
twine upload dist/*
|
||||
python -m build
|
||||
|
||||
- name: Publish to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
user: ${{ secrets.PYPI_USERNAME }}
|
||||
password: ${{ secrets.PYPI_PASSWORD }}
|
||||
|
|
14
.github/workflows/run-tests.yml
vendored
14
.github/workflows/run-tests.yml
vendored
|
@ -2,6 +2,7 @@ name: Run tests
|
|||
# Run test at each push to main, if changes to package or tests files
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
push:
|
||||
|
@ -29,18 +30,11 @@ jobs:
|
|||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install ".[test]"
|
||||
|
||||
- name: Check code style with flake8 (lint)
|
||||
run: |
|
||||
# warnings if there are Python syntax errors or undefined names
|
||||
# (remove --exit-zero to fail when syntax error)
|
||||
flake8 . --count --exit-zero --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
|
||||
pipx install hatch
|
||||
hatch run locales
|
||||
|
||||
- name: Test with pytest
|
||||
run: pytest -v
|
||||
run: hatch run test
|
||||
|
||||
|
||||
test_docker_build:
|
||||
|
|
|
@ -45,14 +45,12 @@ def check_and_install_models(force=False, load_only_lang_codes=None):
|
|||
# Download and install all available packages
|
||||
for available_package in available_packages:
|
||||
print(
|
||||
"Downloading %s (%s) ..."
|
||||
% (available_package, available_package.package_version)
|
||||
f"Downloading {available_package} ({available_package.package_version}) ..."
|
||||
)
|
||||
available_package.install()
|
||||
|
||||
# reload installed languages
|
||||
libretranslate.language.languages = translate.get_installed_languages()
|
||||
print(
|
||||
"Loaded support for %s languages (%s models total)!"
|
||||
% (len(translate.get_installed_languages()), len(available_packages))
|
||||
f"Loaded support for {len(translate.get_installed_languages())} languages ({len(available_packages)} models total)!"
|
||||
)
|
||||
|
|
|
@ -84,8 +84,10 @@ features = [
|
|||
"test",
|
||||
]
|
||||
|
||||
|
||||
[tool.hatch.envs.default.scripts]
|
||||
dev = "python main.py {args}"
|
||||
locales = "python scripts/compile_locales.py"
|
||||
fmt = [
|
||||
"ruff libretranslate scripts --fix",
|
||||
]
|
||||
|
@ -145,8 +147,7 @@ select = [
|
|||
"PLE", # pylint error
|
||||
# "PLR", # pylint refactor
|
||||
# "PLW", # pylint warning
|
||||
"RUF", # ruff specific
|
||||
"T",
|
||||
# "RUF", # ruff specific
|
||||
]
|
||||
|
||||
ignore = [
|
||||
|
|
12
setup.cfg
12
setup.cfg
|
@ -1,12 +0,0 @@
|
|||
[flake8]
|
||||
exclude = .git,
|
||||
.vscode,
|
||||
.gitignore,
|
||||
README.md,
|
||||
venv,
|
||||
test,
|
||||
setup.py,
|
||||
libretranslate/__init__.py
|
||||
|
||||
max-line-length = 136
|
||||
ignore = E741
|
Loading…
Reference in a new issue