Skip to content

Commit

Permalink
Merge pull request #27 from nyggus/add-pkg-ci
Browse files Browse the repository at this point in the history
Add pkg ci
  • Loading branch information
nyggus authored Oct 5, 2023
2 parents a1d8ad6 + a83f65f commit 7c82498
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 9 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow will install Python dependencies, run tests and lint with three versions of Python
# and three operating systems.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-cov setuptools wheel
- name: Build Package
run: |
python setup.py sdist bdist_wheel
- name: Install Built Package
run: |
pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --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: |
python -m pytest --cov=makepackage --cov-report=html tests/
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setuptools.setup(
name="makepackage",
version="0.1.9",
version="0.1.10",
author="Nyggus",
author_email="nyggus@gmail.com",
description="Creating a structure of a simple Python package",
Expand Down
31 changes: 23 additions & 8 deletions tests/test_makepackage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations
import subprocess

import platform
import subprocess
from pathlib import Path
from typing import Tuple


cmd_command = tuple[str, Path]
cmd_command = Tuple[str, Path]


def select_venv_cmd():
Expand All @@ -15,12 +16,26 @@ def select_venv_cmd():


def run_cmds(cmds: list[cmd_command]):
if platform.system() == "Windows":
executable = None
else:
executable = "/bin/bash"

for cmd, path in cmds:
if platform.system() == "Windows":
subprocess.run(cmd, shell=True, cwd=path, check=True)
else:
subprocess.run(
cmd, executable="/bin/bash", shell=True, cwd=path, check=True
process = subprocess.Popen(
args=cmd,
shell=True,
executable=executable,
cwd=path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)

_, stderr = process.communicate()

if process.returncode != 0:
raise RuntimeError(
f"Command failed with error code {process.returncode}: {stderr.decode()}"
)


Expand Down

0 comments on commit 7c82498

Please sign in to comment.