Edit publish workflow to reuse existing test workflow, and use the build package to build the libretranslate package

This commit is contained in:
Vincent Emonet 2023-07-10 08:11:51 +02:00
parent 1c0fb597fb
commit a1eb871bb6
5 changed files with 20 additions and 66 deletions

View file

@ -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 }}

View file

@ -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: