diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5304c6424d..5a742c29ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,25 +39,24 @@ jobs: env: CI: 'true' steps: - - name: Install calibre dependencies + - name: Prepare the container run: | - set -xe - useradd -m ci pacman -Syu --noconfirm - pacman -S --noconfirm --needed base-devel sudo git sip5 pyqt-builder chmlib icu jxrlib hunspell libmtp libusb libwmf optipng podofo python-apsw python-beautifulsoup4 python-cssselect python-css-parser python-dateutil python-dbus python-dnspython python-dukpy python-feedparser python-html2text python-html5-parser python-lxml python-markdown python-mechanize python-msgpack python-netifaces python-unrardll python-pillow python-psutil python-pygments python-pyqt5 python-regex python-zeroconf python-pyqtwebengine qt5-x11extras qt5-svg qt5-imageformats udisks2 hyphen python-pychm python-pycryptodome speech-dispatcher + pacman -S --noconfirm tar - name: Checkout source code uses: actions/checkout@master with: fetch-depth: 10 + - name: Install calibre dependencies + run: setup/arch-ci.sh + - name: Bootstrap calibre - run: | - chown -R ci:users $GITHUB_WORKSPACE - runuser -u ci -- python setup.py bootstrap --ephemeral + run: runuser -u ci -- python setup.py bootstrap --ephemeral - name: Test calibre run: | + set -xe runuser -u ci -- python setup.py test runuser -u ci -- python setup.py test_rs - chmod +777 .git .git/config diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index a9989d9f02..5c085049d9 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -9,30 +9,32 @@ jobs: name: Update translations on Transifex if: github.repository == 'kovidgoyal/calibre' runs-on: ubuntu-latest + container: + image: 'archlinux/base:latest' + env: + CI: 'true' steps: + - name: Prepare the container + run: | + pacman -Syu --noconfirm + pacman -S --noconfirm tar + - name: Checkout source code uses: actions/checkout@master with: fetch-depth: 2 - - name: Checkout translations - uses: actions/checkout@master - with: - repository: 'kovidgoyal/calibre-translations' - path: 'translations' - - - name: Set up Python - uses: actions/setup-python@master - with: - python-version: 3.8 + - name: Install calibre dependencies + run: setup/arch-ci.sh - name: Install translations dependencies - run: - python -m pip install 'urllib3<1.26' transifex-client sphinx + run: python -m pip install transifex-client + + - name: Bootstrap calibre + run: runuser -u ci -- python setup.py bootstrap --ephemeral - name: Update translations env: tx: ${{ secrets.tx }} - CI: "true" - run: - python setup/unix-ci.py pot + run: | + runuser -u ci -- python setup/unix-ci.py pot diff --git a/manual/build.py b/manual/build.py index c34833f110..d9f9c2c710 100755 --- a/manual/build.py +++ b/manual/build.py @@ -12,7 +12,6 @@ from functools import partial j, d, a = os.path.join, os.path.dirname, os.path.abspath BASE = d(a(__file__)) SPHINX_BUILD = ['sphinx-build'] -is_ci = os.environ.get('CI') == 'true' sys.path.insert(0, d(BASE)) from setup import __appname__, __version__ @@ -71,12 +70,6 @@ def build_manual(language, base): def build_pot(base): cmd = SPHINX_BUILD + ['-b', 'gettext', '-t', 'online', '-t', 'gettext', '.', base] - if is_ci: - sp = eval(subprocess.check_output(['python', '-c', 'import sphinx; print(sphinx.__path__)']).decode('utf-8')) - code = f'import sys, os; sys.path += [{os.path.dirname(sp[0])!r}]; from sphinx.cmd.build import main; main({cmd[1:]!r})' - os.environ['CALIBRE_DEVELOP_FROM'] = j(d(BASE), 'src') - print('Running with calibre src:', os.environ['CALIBRE_DEVELOP_FROM']) - cmd = [sys.executable, '-c', code] print(' '.join(cmd)) subprocess.check_call(cmd) os.remove(j(base, 'generated.pot')) diff --git a/setup/arch-ci.sh b/setup/arch-ci.sh new file mode 100755 index 0000000000..67a291b1fa --- /dev/null +++ b/setup/arch-ci.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +# arch-ci.sh +# Copyright (C) 2020 Kovid Goyal + +set -xe +useradd -m ci +pacman -S --noconfirm --needed base-devel sudo git sip5 pyqt-builder chmlib icu jxrlib hunspell libmtp libusb libwmf optipng podofo python-apsw python-beautifulsoup4 python-cssselect python-css-parser python-dateutil python-dbus python-dnspython python-dukpy python-feedparser python-html2text python-html5-parser python-lxml python-markdown python-mechanize python-msgpack python-netifaces python-unrardll python-pillow python-psutil python-pygments python-pyqt5 python-regex python-zeroconf python-pyqtwebengine qt5-x11extras qt5-svg qt5-imageformats udisks2 hyphen python-pychm python-pycryptodome speech-dispatcher python-sphinx python-urllib3 python-pip +chown -R ci:users $GITHUB_WORKSPACE diff --git a/setup/unix-ci.py b/setup/unix-ci.py index 4e493b44f9..8577558cc3 100644 --- a/setup/unix-ci.py +++ b/setup/unix-ci.py @@ -85,13 +85,6 @@ def download_and_decompress(url, dest, compression=None): raise SystemExit('Failed to download ' + url) -def install_calibre_binary(): - dest = os.path.expanduser('~/calibre-bin') - os.mkdir(dest) - download_and_decompress('https://calibre-ebook.com/dist/linux64', dest, 'J') - return os.path.join(dest, 'calibre-debug') - - def install_qt_source_code(): dest = os.path.expanduser('~/qt-base') os.mkdir(dest) @@ -111,7 +104,7 @@ def run_python(*args): def install_linux_deps(): run('sudo', 'apt-get', 'update', '-y') # run('sudo', 'apt-get', 'upgrade', '-y') - run('sudo', 'apt-get', 'install', '-y', 'gettext', 'libgl1-mesa-dev', 'libespeak-ng-dev') + run('sudo', 'apt-get', 'install', '-y', 'gettext', 'libgl1-mesa-dev') def main(): @@ -145,12 +138,10 @@ username = api '''.replace('PASSWORD', os.environ['tx']) with open(os.path.expanduser('~/.transifexrc'), 'w') as f: f.write(transifexrc) - install_linux_deps() - interpreter = install_calibre_binary() install_qt_source_code() - run(interpreter, 'setup.py', 'gui') - run(interpreter, 'setup.py', 'pot') - + install_env() + run(sys.executable, '-m', 'pip', 'install', 'transifex-client') + run(sys.executable, 'setup.py', 'pot') elif action == 'test': os.environ['CI'] = 'true' if ismacos: