Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3fe9852
feat: add poetry
GirZ0n Feb 16, 2024
097c9c4
style: add a blank line
GirZ0n Feb 16, 2024
ebe4be3
fix: add WPS232
GirZ0n Feb 16, 2024
362f784
style: add a blank line to the end of the file
GirZ0n Feb 16, 2024
15d897f
fix: remove unnecessary files
GirZ0n Feb 20, 2024
9173c59
fix: now if an error occurs while running a subprocess, it will be shown
GirZ0n Feb 20, 2024
7669db3
refactor: now using poetry except pip
GirZ0n Feb 20, 2024
d201535
fix: fix POETRY_HOME
GirZ0n Feb 20, 2024
8d11cc4
fix: fix poetry version
GirZ0n Feb 20, 2024
b2fde38
fix: fix poetry home
GirZ0n Feb 20, 2024
4331787
try to fix CI
GirZ0n Feb 20, 2024
b61e2af
try to fix CI
GirZ0n Feb 20, 2024
3494d1b
try to fix CI
GirZ0n Feb 20, 2024
064b570
try to fix CI
GirZ0n Feb 20, 2024
4bf9cdd
try to fix CI
GirZ0n Feb 20, 2024
89ed56c
try to fix CI
GirZ0n Feb 20, 2024
c2f5f36
try to fix CI
GirZ0n Feb 20, 2024
7122d4c
try to fix CI
GirZ0n Feb 20, 2024
c57d070
try to fix CI
GirZ0n Feb 20, 2024
b1dbdfa
try to fix CI
GirZ0n Feb 20, 2024
a47512a
try to fix CI
GirZ0n Feb 20, 2024
ea32d11
try to fix CI
GirZ0n Feb 20, 2024
cc46067
try to fix CI
GirZ0n Feb 20, 2024
4f2befb
feat: add an exit code handling
GirZ0n Feb 21, 2024
bdeccbc
feat: and a pip installation test
GirZ0n Feb 21, 2024
ab4da42
style: fix flake8 issue
GirZ0n Feb 21, 2024
facbdcf
fix: add some forgotten steps
GirZ0n Feb 21, 2024
e88f46c
fix: add some forgotten steps
GirZ0n Feb 21, 2024
d7eacba
fix: fix a small issue with artifact name
GirZ0n Feb 21, 2024
172177f
fix: update some action versions
GirZ0n Feb 21, 2024
9364fbc
fix: bump version to 0.3.2
GirZ0n Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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='ilyavlasov2011@gmail.com',
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