diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 2da245f1f..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,117 +0,0 @@ -version: 2 - -jobs: - - lin-sys: - docker: - - image: kovidgoyal/kitty-test:latest - steps: - - checkout - - run: if grep -Inr '\s$' kitty kitty_tests kittens docs *.py *.asciidoc *.rst .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi - - run: python3 -m flake8 --count . - - run: python3 setup.py build --debug --verbose - - run: ./kitty/launcher/kitty +launch test.py - - run: make FAIL_WARN=-W man - - run: make FAIL_WARN=-W html - - lin-package: - docker: - - image: kovidgoyal/kitty-test:latest - steps: - - checkout - - run: python3 setup.py linux-package --update-check-interval=0 - - lin-35: - docker: - - image: kovidgoyal/kitty-test:latest - environment: - CC: gcc - CFLAGS: -funsigned-char - LD_LIBRARY_PATH: /opt/py3.5/lib - ASAN_OPTIONS: leak_check_at_exit=0 - steps: - - checkout - - run: /opt/py3.5/bin/python3 setup.py build --debug --verbose --sanitize - - run: ./kitty/launcher/kitty +launch test.py - - lin-37: - docker: - - image: kovidgoyal/kitty-test:latest - environment: - CC: clang - LD_LIBRARY_PATH: /opt/py3.7/lib - ASAN_OPTIONS: leak_check_at_exit=0 - steps: - - checkout - - run: /opt/py3.7/bin/python3 setup.py build --debug --verbose --sanitize - - run: ./kitty/launcher/kitty +launch test.py - - lin-38: - docker: - - image: kovidgoyal/kitty-test:latest - environment: - CC: clang - LD_LIBRARY_PATH: /opt/py3.8/lib - ASAN_OPTIONS: leak_check_at_exit=0 - steps: - - checkout - - run: /opt/py3.8/bin/python3 setup.py build --debug --verbose --sanitize - - run: ./kitty/launcher/kitty +launch test.py - - lin-bundle: - docker: - - image: kovidgoyal/kitty-test:latest - environment: - ASAN_OPTIONS: leak_check_at_exit=0 - steps: - - checkout - - run: echo "export LD_LIBRARY_PATH=$SW/lib" >> $BASH_ENV - - run: echo "export PKG_CONFIG_PATH=$SW/lib/pkgconfig" >> $BASH_ENV - - run: echo "export PYTHONHOME=$SW" >> $BASH_ENV - - run: $SW/bin/python3 setup.py build --debug --verbose - - run: ./kitty/launcher/kitty +launch test.py - - mac-bundle: - macos: - xcode: "10.1.0" - environment: - LC_ALL: en_US.UTF-8 - LANG: en_US.UTF-8 - SW: /Users/Shared/buildbot/sw/sw - steps: - - checkout - - run: mkdir -p $SW - - run: curl https://download.calibre-ebook.com/travis/kitty/osx.tar.xz | tar xJ -C $SW - - run: echo "export PATH=$SW/bin:$PATH" >> $BASH_ENV - - run: python3 setup.py build --debug --verbose - - run: ./kitty/launcher/kitty +launch test.py - - mac-brew: - macos: - xcode: "11.3.1" - environment: - LC_ALL: en_US.UTF-8 - LANG: en_US.UTF-8 - steps: - - checkout - - run: brew install $(cat Brewfile|grep -v "#") - - run: python3 setup.py build --debug --verbose - - run: ./kitty/launcher/kitty +launch test.py - - run: echo "export PATH=/usr/local/opt/sphinx-doc/bin:$PATH" >> $BASH_ENV - - run: python3 setup.py linux-package --verbose - - run: python3 setup.py kitty.app --verbose - - run: kitty.app/Contents/MacOS/kitty +runpy "from kitty.constants import *; print(kitty_exe())" - - -workflows: - version: 2 - all_jobs: - jobs: - - mac-bundle - - lin-sys - - lin-35 - - lin-37 - - lin-38 - - lin-package - - lin-bundle - - mac-brew diff --git a/.circleci/images/Dockerfile b/.circleci/images/Dockerfile deleted file mode 100644 index 9b03e981b..000000000 --- a/.circleci/images/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -# When changing this file, go to -# https://cloud.docker.com/repository/docker/kovidgoyal/kitty-test/builds and -# click the "Trigger" button under Automated builds to rebuild -FROM ubuntu:latest - -# make Apt non-interactive -ENV DEBIAN_FRONTEND=noninteractive -RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \ - && echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci \ - && echo 'Acquire::Languages "none";' >> /etc/apt/apt.conf.d/90circleci - -# System setup -RUN apt-get update && mkdir -p /usr/share/man/man1 && apt-get install -y python3-flake8 python3-pip python3-pil clang git apt locales sudo openssh-client ca-certificates tar gzip parallel net-tools netcat unzip zip bzip2 gnupg curl wget build-essential apt-utils - -# Setup circleci user -RUN groupadd --gid 3434 circleci \ - && useradd --uid 3434 --gid circleci --shell /bin/bash --create-home circleci \ - && echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci \ - && echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep \ - && echo 'Defaults env_keep += "SW"' >> /etc/sudoers.d/env_keep \ - && echo 'Defaults env_keep += "LANG"' >> /etc/sudoers.d/env_keep - -# Set timezone to UTC by default -RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime - -# Use unicode -RUN locale-gen en_US.UTF-8 || true -ENV LANG=en_US.UTF-8 - -# Deps needed for building python -RUN apt-get install -y libreadline-dev zlib1g-dev libssl-dev libbz2-dev libsqlite3-dev libffi-dev - -# kitty deps -RUN apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libpng-dev libfontconfig-dev libpython3-dev libxkbcommon-x11-dev python3-pygments libcanberra-dev - -# Needed to build kitty docs -RUN pip3 install sphinx - -# Install multiple pythons -ADD install-python.py /tmp/install-python.py -RUN python3 /tmp/install-python.py py3.5 https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tar.xz -RUN python3 /tmp/install-python.py py3.7 https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz -RUN python3 /tmp/install-python.py py3.8 https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tar.xz - -# Install kitty bundle -ENV SW=/home/circleci/sw -RUN python3 /tmp/install-python.py bundle https://download.calibre-ebook.com/travis/kitty/linux-64.tar.xz -RUN echo SW=$SW >> /etc/environment - -# Clean unused files -RUN apt-get clean -y - -USER circleci - -LABEL com.circleci.preserve-entrypoint=true -ENTRYPOINT sleep 2h diff --git a/.circleci/images/install-python.py b/.circleci/images/install-python.py deleted file mode 100644 index b29656721..000000000 --- a/.circleci/images/install-python.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2019, Kovid Goyal - -import io -import os -import shlex -import shutil -import subprocess -import sys -import tarfile -from urllib.request import urlopen - -PY, URL = sys.argv[1], sys.argv[2] -if PY == 'bundle': - SW = os.environ['SW'] - os.mkdir(SW) - os.chdir(SW) -else: - os.chdir('/usr/src') - - -def run(cmd): - cmd = shlex.split(cmd) - p = subprocess.Popen(cmd) - if p.wait() != 0: - raise SystemExit(p.returncode) - - -with urlopen(URL) as f: - data = f.read() - -with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf: - tf.extractall() - - -def replace_in_file(path, src, dest): - with open(path, 'r+') as f: - n = f.read().replace(src, dest) - f.seek(0), f.truncate() - f.write(n) - - -if PY == 'bundle': - replaced = 0 - for dirpath, dirnames, filenames in os.walk(SW): - for f in filenames: - if f.endswith('.pc') or (f.endswith('.py') and f.startswith('_sysconfig')): - replace_in_file(os.path.join(dirpath, f), '/sw/sw', SW) - replaced += 1 - if replaced < 2: - raise SystemExit('Failed to replace path to SW in bundle') -else: - src = os.path.abspath(tuple(os.listdir('.'))[0]) - os.chdir(src) - run(f'./configure --prefix=/opt/{PY} --enable-shared --with-system-expat --without-ensurepip') - run(f'make -j {os.cpu_count()}') - run('make install') - os.chdir('/') - shutil.rmtree(src) diff --git a/.github/workflows/ci.py b/.github/workflows/ci.py new file mode 100644 index 000000000..ef3811c0e --- /dev/null +++ b/.github/workflows/ci.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8 +# License: GPLv3 Copyright: 2020, Kovid Goyal + +import io +import os +import shlex +import subprocess +import sys +import tarfile +from urllib.request import urlopen + +is_bundle = os.environ.get('KITTY_BUNDLE') == '1' +is_macos = 'darwin' in sys.platform.lower() +SW = None + + +def run(*a): + if len(a) == 1: + a = shlex.split(a[0]) + print(' '.join(map(shlex.quote, a))) + sys.stdout.flush() + ret = subprocess.Popen(a).wait() + if ret != 0: + raise SystemExit(ret) + + +def install_deps(): + print('Installing kitty dependencies...') + sys.stdout.flush() + if is_macos: + items = (x.strip() for x in open('Brewfile').readlines() if not x.startswith('#')) + run('brew', 'install', *items) + else: + run('sudo apt-get update') + run('sudo apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev' + ' libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev' + ' libpng-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev') + if is_bundle: + install_bundle() + else: + run('pip install Pillow pygments') + + +def build_kitty(): + python = 'python3' if is_bundle else sys.executable + cmd = '{} setup.py build --verbose'.format(python) + if os.environ.get('KITTY_SANITIZE') == '1': + cmd += ' --debug --sanitize' + run(cmd) + + +def test_kitty(): + run('./kitty/launcher/kitty +launch test.py') + + +def package_kitty(): + py = 'python3' if is_macos else 'python' + run(py + ' setup.py linux-package --update-check-interval=0 --verbose') + if is_macos: + run('python3 setup.py kitty.app --update-check-interval=0 --verbose') + run('kitty.app/Contents/MacOS/kitty +runpy "from kitty.constants import *; print(kitty_exe())"') + + +def replace_in_file(path, src, dest): + with open(path, 'r+') as f: + n = f.read().replace(src, dest) + f.seek(0), f.truncate() + f.write(n) + + +def setup_bundle_env(): + global SW + os.environ['SW'] = SW = '/Users/Shared/buildbot/sw/sw' if is_macos else os.path.join(os.environ['GITHUB_WORKSPACE'], 'sw') + os.environ['PKG_CONFIG_PATH'] = SW + '/lib/pkgconfig' + if is_macos: + os.environ['PATH'] = '{}:{}'.format('/usr/local/opt/sphinx-doc/bin', os.environ['PATH']) + else: + os.environ['LD_LIBRARY_PATH'] = SW + '/lib' + os.environ['PYTHONHOME'] = SW + os.environ['PATH'] = '{}:{}'.format(os.path.join(SW, 'bin'), os.environ['PATH']) + + +def install_bundle(): + cwd = os.getcwd() + os.makedirs(SW) + os.chdir(SW) + with urlopen('https://download.calibre-ebook.com/travis/kitty/{}.tar.xz'.format( + 'osx' if is_macos else 'linux-64')) as f: + data = f.read() + with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf: + tf.extractall() + if not is_macos: + replaced = 0 + for dirpath, dirnames, filenames in os.walk('.'): + for f in filenames: + if f.endswith('.pc') or (f.endswith('.py') and f.startswith('_sysconfig')): + replace_in_file(os.path.join(dirpath, f), '/sw/sw', SW) + replaced += 1 + if replaced < 2: + raise SystemExit('Failed to replace path to SW in bundle') + os.chdir(cwd) + + +def main(): + if is_bundle: + setup_bundle_env() + else: + if not is_macos: + os.environ['LD_LIBRARY_PATH'] = '{}/lib'.format(os.environ['pythonLocation']) + action = sys.argv[-1] + if action in ('build', 'package'): + install_deps() + if action == 'build': + build_kitty() + elif action == 'package': + package_kitty() + elif action == 'test': + test_kitty() + else: + raise SystemExit('Unknown action: ' + action) + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..a656a1b3e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,128 @@ +name: CI +on: [push, pull_request] +env: + CI: 'true' + ASAN_OPTIONS: leak_check_at_exit=0 + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + +jobs: + linux: + name: Linux (python=${{ matrix.pyver }} cc=${{ matrix.cc }} sanitize=${{ matrix.sanitize }}) + runs-on: ubuntu-latest + env: + CC: ${{ matrix.cc }} + KITTY_SANITIZE: ${{ matrix.sanitize }} + + strategy: + matrix: + python: [a, b, c] + cc: [gcc, clang] + include: + - python: a + pyver: 3.5 + sanitize: 0 + + - python: b + pyver: 3.7 + sanitize: 1 + + - python: c + pyver: 3.8 + sanitize: 1 + + + exclude: + - python: a + cc: clang + - python: b + cc: clang + - python: c + cc: gcc + + steps: + - name: Checkout source code + uses: actions/checkout@master + with: + fetch-depth: 10 + - name: Set up Python ${{ matrix.pyver }} + uses: actions/setup-python@master + with: + python-version: ${{ matrix.pyver }} + + - name: Build kitty + run: python .github/workflows/ci.py build + + - name: Test kitty + run: python .github/workflows/ci.py test + + linux-package: + name: Linux package + runs-on: ubuntu-latest + env: + CFLAGS: -funsigned-char + steps: + - name: Checkout source code + uses: actions/checkout@master + with: + fetch-depth: 10 + + - name: Test for trailing whitespace + run: if grep -Inr '\s$' kitty kitty_tests kittens docs *.py *.asciidoc *.rst .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi + + - name: Set up Python + uses: actions/setup-python@master + with: + python-version: 3.8 + + - name: Check python code + run: | + pip install flake8 sphinx + python -m flake8 --count . + + - name: Build kitty package + run: python .github/workflows/ci.py package + + - name: Build man page + run: make FAIL_WARN=-W man + + - name: Build HTML docs + run: make FAIL_WARN=-W html + + bundle: + name: Bundle test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + env: + KITTY_BUNDLE: 1 + steps: + - name: Checkout source code + uses: actions/checkout@master + with: + fetch-depth: 10 + + - name: Build kitty + run: which python3 && python3 .github/workflows/ci.py build + + - name: Test kitty + run: python3 .github/workflows/ci.py test + + brew: + name: macOS Brew + runs-on: macos-latest + steps: + - name: Checkout source code + uses: actions/checkout@master + with: + fetch-depth: 10 + + - name: Build kitty + run: python3 .github/workflows/ci.py build + + - name: Test kitty + run: python3 .github/workflows/ci.py test + + - name: Build kitty package + run: python3 .github/workflows/ci.py package