Skip to content

Commit

Permalink
Tests & build on push, build & publish on release
Browse files Browse the repository at this point in the history
  • Loading branch information
bart0003 committed Jan 22, 2024
1 parent ab8a7be commit e41b4e8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# This workflow 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: Build Python Package
name: Build Release Package

on:
release:
types: [created]
push: {}

jobs:
build:

deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
Expand All @@ -26,27 +20,20 @@ jobs:
- name: Install Poetry plugins
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
- name: Build for PyPi
- name: Build and publish
env:
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry build --format wheel
poetry publish --username=$PYPI_USERNAME --password=$PYPI_PASSWORD
- name: Build for Sber
run: |
sed -i "s/smart-app-framework/sber-nlp-platform-smart-app-framework/g" pyproject.toml
poetry build --format wheel
- name: Publish to PyPi
if: startsWith(github.ref, 'refs/tags/')
env:
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry publish --username=$PYPI_USERNAME --password=$PYPI_PASSWORD
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
path: dist/*.whl
- name: Upload Release Assets
- name: Upload Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/*.whl
dist/*.whl
65 changes: 51 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,71 @@ on:
push: {}

jobs:
tests:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: 'poetry'
- name: Install dependencies
run: poetry install --no-interaction --no-root --all-extras
- name: Lint with flake8
run: poetry run task lint

tests:
strategy:
fail-fast: false
matrix:
os-version: ['ubuntu-20.04']
python-version: ['3.8', '3.9', '3.10', '3.11']

runs-on: ${{ matrix.os-version }}
name: unittests with py-${{ matrix.python-version }} on ${{ matrix.os-version }}

runs-on: ubuntu-20.04
name: unittests with py-${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- 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 Poetry
uses: snok/install-poetry@v1
cache: 'poetry'
- name: Install dependencies
run: |
uname -a
poetry install --no-interaction --no-root --all-extras
- name: Lint with flake8
run: poetry run task lint
run: poetry install --no-interaction --no-root --all-extras
- name: Test with unittest
run: poetry run task unit_test
- name: Test run_app on HttpMainLoop
run: poetry run task runapp_http_test
- name: Test run_app on KafkaMainLoop
run: poetry run task runapp_kafka_test

build:
needs:
- lint
- tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: 'poetry'
- name: Install Poetry plugins
run: poetry self add "poetry-dynamic-versioning[plugin]"
- name: Build for PyPi
run: poetry build --format wheel
- name: Build for Sber
run: |
sed -i "s/smart-app-framework/sber-nlp-platform-smart-app-framework/g" pyproject.toml
poetry build --format wheel
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
path: dist/*.whl

0 comments on commit e41b4e8

Please sign in to comment.