Skip to content

Commit

Permalink
0.3.2 (#6)
Browse files Browse the repository at this point in the history
* feat: add poetry

* style: add a blank line

* fix: add WPS232

* style: add a blank line to the end of the file

* fix: remove unnecessary files

* fix: now if an error occurs while running a subprocess, it will be shown

* refactor: now using poetry except pip

* fix: fix POETRY_HOME

* fix: fix poetry version

* fix: fix poetry home

* try to fix CI

* feat: add an exit code handling

* feat: and a pip installation test
style: add custom names for jobs

* style: fix flake8 issue

* fix: add some forgotten steps
style: change the workflow name

* fix: add some forgotten steps

* fix: fix a small issue with artifact name

* fix: update some action versions

* fix: bump version to 0.3.2
  • Loading branch information
GirZ0n authored Feb 21, 2024
1 parent 0baf217 commit aca14d8
Show file tree
Hide file tree
Showing 11 changed files with 1,084 additions and 90 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ignore=WPS100, # Found wrong module name
WPS202, # Found too many module members
WPS210, # Found too many local variables
WPS221, # Found line with high Jones Complexity
WPS232, # Forbid modules with average cognitive complexity that is too high
WPS237, # Found a too complex `f` string
WPS305, # Found `f` string
WPS323, # Found `%` string formatting
Expand Down
147 changes: 112 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Python build
name: Main workflow

on: [push]

env:
POETRY_VERSION: 1.7.1
JETBRAINS_MONO_VERSION: 2.304
PYTHON_VERSION: "3.8"

Expand All @@ -11,56 +12,77 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}


name: Setup files on ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4.5.0
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Python virtual environment
- name: Cache Poetry
id: poetry-cache
uses: actions/cache@v4
with:
path: ~/poetry
key: ${{ runner.os }}-poetry-cache-${{ env.POETRY_VERSION }}

- name: Install Poetry
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
python3 -m venv ~/poetry
~/poetry/bin/pip3 install poetry==$POETRY_VERSION
- name: Cache virtual environment
id: pip-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ./venv
key: ${{ runner.os }}-pip-cache-${{ hashFiles('./requirements*.txt') }}
path: ./.venv
key: ${{ runner.os }}-pip-cache-${{ hashFiles('./poetry.lock') }}

- name: Install Python requirements
- name: Install requirements
if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
python3 -m venv venv
source venv/bin/activate
pip install -r ./requirements.txt -r ./requirements-code-style.txt -r ./requirements-test.txt
~/poetry/bin/poetry install
code-style:
needs: setup

runs-on: ubuntu-latest

name: Check code style

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4.5.0
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Python virtual environment
- name: Cache Poetry
id: poetry-cache
uses: actions/cache@v4
with:
path: ~/poetry
key: ${{ runner.os }}-poetry-cache-${{ env.POETRY_VERSION }}

- name: Cache virtual environment
id: pip-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ./venv
key: ${{ runner.os }}-pip-cache-${{ hashFiles('./requirements*.txt') }}
path: ./.venv
key: ${{ runner.os }}-pip-cache-${{ hashFiles('./poetry.lock') }}

- name: Run Flake8
run: |
source ./venv/bin/activate
flake8 . --count --statistics --config ./.flake8
~/poetry/bin/poetry run flake8 . --count --statistics --config ./.flake8
- name: Run Black
uses: psf/black@stable
with:
Expand All @@ -75,25 +97,29 @@ jobs:

runs-on: ${{ matrix.os }}

name: Run tests on ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4.5.0
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Python virtual environment
id: pip-cache
uses: actions/cache@v3
- name: Cache Poetry
id: poetry-cache
uses: actions/cache@v4
with:
path: ./venv
key: ${{ runner.os }}-pip-cache-${{ hashFiles('./requirements*.txt') }}
path: ~/poetry
key: ${{ runner.os }}-poetry-cache-${{ env.POETRY_VERSION }}

- name: Install anderson
run: |
source ./venv/bin/activate
pip install .
- name: Cache virtual environment
id: pip-cache
uses: actions/cache@v4
with:
path: ./.venv
key: ${{ runner.os }}-pip-cache-${{ hashFiles('./poetry.lock') }}

- name: Download JetBrains Mono
run: |
Expand All @@ -112,5 +138,56 @@ jobs:
- name: Test anderson
run: |
source ./venv/bin/activate
pytest . -vv
~/poetry/bin/poetry install
~/poetry/bin/poetry run pytest . -vv
pip-test:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]

runs-on: ${{ matrix.os }}

name: Run Anderson via pip on ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install anderson
run: |
python3 -m venv .venv
source .venv/bin/activate
pip3 install .
- name: Download JetBrains Mono
run: |
curl -sLO https://github.com/JetBrains/JetBrainsMono/releases/download/v$JETBRAINS_MONO_VERSION/JetBrainsMono-$JETBRAINS_MONO_VERSION.zip
unzip JetBrainsMono-$JETBRAINS_MONO_VERSION.zip
- name: Install JetBrains Mono on MacOS
if: matrix.os == 'macos-latest'
run: cp fonts/ttf/JetBrainsMono-Regular.ttf /Library/Fonts/

- name: Install JetBrains Mono on Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo cp fonts/ttf/JetBrainsMono-Regular.ttf /usr/local/share/fonts/
fc-cache -f -v
- name: Generate Python Bot GIFs
run: |
source .venv/bin/activate
cd examples/python_bot
anderson "python3 main.py" out config.yaml
- name: Upload GIFs
uses: actions/upload-artifact@v4
with:
name: GIFs - ${{ matrix.os }}
path: examples/python_bot/out/
if-no-files-found: error
5 changes: 4 additions & 1 deletion anderson/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def main() -> int:
args.output.mkdir(parents=True, exist_ok=True)
for gif in gif_config.gifs:
logger.info(f'Generating {gif.name}.gif')
run_in_subprocess(create_gif_generation_command(Path(cast_file.name), args.output, gif))
exit_code = run_in_subprocess(create_gif_generation_command(Path(cast_file.name), args.output, gif))
if exit_code != 0:
logger.error("Can't generate GIF file! For more information please see the stacktrace.")
return 1


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion anderson/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def run_in_subprocess(command: List[str]) -> int:
logger.debug(f"{command[0]}'s stdout:\n{stdout}")

if stderr:
logger.debug(f"{command[0]}'s stderr:\n{stderr}")
logger.error(f"{command[0]}'s stderr:\n{stderr}")

return process.returncode
46 changes: 1 addition & 45 deletions setup.py → build.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import os
import re
import stat
from pathlib import Path
from platform import libc_ver, machine, system
from typing import List, Optional
from typing import Optional
from urllib.request import urlretrieve

from setuptools import find_packages, setup

from anderson.utils import AGG_PATH

VERSION = '0.3.1'
AGG_VERSION = '1.4.2'

REQUIREMENTS_FILE = Path(__file__).parent / 'requirements.txt'


def get_requires() -> List[str]:
with open(REQUIREMENTS_FILE) as requirements_file:
return [re.sub(r'(git\+.*egg=(.*))', r'\2 @ \1', line) for line in requirements_file.read().split('\n')]


def get_agg_bin_name() -> Optional[str]: # noqa: WPS231
agg_bin_name = None
Expand Down Expand Up @@ -61,35 +49,3 @@ def download_agg_bin() -> None:


download_agg_bin()


setup(
name='anderson',
version=VERSION,
author='Ilya Vlasov',
author_email='[email protected]',
description='A tool for automatically recording a terminal session into animated GIF files',
long_description='file: README.md',
long_description_content_type='text/markdown',
url='https://github.com/GirZ0n/anderson',
license='Apache License 2.0',
license_files='LICENSE',
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'License :: OSI Approved :: Apache Software License',
'Intended Audience :: Education',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Topic:: Utilities',
],
python_requires='>=3.8, <4',
install_requires=get_requires(),
include_package_data=True,
package_data={'anderson': ['bin/*']},
packages=find_packages(),
entry_points={'console_scripts': ['anderson=anderson.main:main']},
)
Loading

0 comments on commit aca14d8

Please sign in to comment.