[MVP-1] Add proper CI/CD, tests and fix codestyle (#1) #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Default | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- "main" | |
env: | |
POETRY_HOME: "/opt/poetry" | |
PYTHON_VERSION: "3.8" | |
jobs: | |
linters: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pylint flake8 | |
- name: Analysing the code with pylint | |
run: | | |
pylint --rcfile ${{ github.workspace }}/.pylintrc \ | |
--disable=import-error \ | |
--fail-under 5 \ | |
--fail-on E \ | |
${{ github.workspace }}/open_pcc_metric | |
- name: Analysing the code with flake8 | |
run: | | |
flake8 --config=${{ github.workspace }}/.flake8 \ | |
${{ github.workspace }}/open_pcc_metric/*.py \ | |
${{ github.workspace }}/tests/**/*.py | |
pytest: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python3 -m venv $POETRY_HOME | |
$POETRY_HOME/bin/pip install poetry==1.8.1 | |
$POETRY_HOME/bin/poetry --version | |
$POETRY_HOME/bin/poetry install | |
- name: Test with pytest | |
run: | | |
export ENV_PATH=$(${POETRY_HOME}/bin/poetry env info -p) | |
${ENV_PATH}/bin/pytest --junit-xml report.xml | |
- name: Upload docker meta | |
uses: actions/upload-artifact@v4 | |
with: | |
name: unit-report | |
path: report.xml | |
publish-wheel: | |
runs-on: ubuntu-latest | |
if: github.event.action == 'create' | |
needs: | |
- linters | |
- pytest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python3 -m venv $POETRY_HOME | |
$POETRY_HOME/bin/pip install poetry==1.8.1 | |
$POETRY_HOME/bin/poetry --version | |
- name: Build and publish | |
run: | | |
$POETRY_HOME/bin/poetry config pypi-token.pypi ${{ env.PYPI_TOKEN }} | |
$POETRY_HOME/bin/poetry publish --build |