diff options
author | scoder <stefan_ml@behnel.de> | 2021-07-16 18:06:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-16 18:06:02 +0200 |
commit | 0240d0587a8f83dcd6a2e4f35026b056660e51c8 (patch) | |
tree | d159c05b98a0b589b33a5bf20787d5c5e549b80d | |
parent | 6660ff2de00c884c9ce82c4833e39553835ce780 (diff) | |
download | python-lxml-0240d0587a8f83dcd6a2e4f35026b056660e51c8.tar.gz |
Switch to GitHub actions (GH-319)
-rw-r--r-- | .github/workflows/ci.yml | 138 | ||||
-rw-r--r-- | test.py | 4 | ||||
-rw-r--r-- | tools/ci-run.sh | 65 |
3 files changed, 205 insertions, 2 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..dfa301a6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,138 @@ +name: CI + +on: [push, pull_request] + +jobs: + ci: + strategy: + # Allows for matrix sub-jobs to fail without canceling the rest + fail-fast: false + + # MATRIX: + # ======= + # Required parameters: + # os the os to run on + # python-version the python version to use + # backend the backend to use + # env any additional env variables. Set to '{}' for none + # Optional parameters: + # allowed_failure whether the job is allowed to fail + # extra_hash extra hash str to differentiate from other caches with similar name (must always start with '-') + matrix: + # Tests [amd64] + # + os: [ubuntu-18.04, macos-10.15] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10-dev] + env: [{ STATIC_DEPS: true }, { STATIC_DEPS: false }] + + include: + # Temporary - Allow failure on all 3.10-dev jobs until beta comes out + - os: ubuntu-18.04 + python-version: 3.10-dev + allowed_failure: true + # Coverage setup + - os: ubuntu-18.04 + python-version: 3.9 + env: { COVERAGE: true } + extra_hash: "-coverage" + allowed_failure: true # shouldn't fail but currently does... + - os: ubuntu-18.04 + python-version: 3.9 + env: { STATIC_DEPS: false, EXTRA_DEPS: "docutils pygments sphinx sphinx-rtd-theme" } + extra_hash: "-docs" + allowed_failure: true # shouldn't fail but currently does... + # Old library setup with minimum version requirements + - os: ubuntu-18.04 + python-version: 3.9 + env: { + STATIC_DEPS: true, + LIBXML2_VERSION: 2.9.2, + LIBXSLT_VERSION: 1.1.27, + } + extra_hash: "-oldlibs" + allowed_failure: true # shouldn't fail but currently does... + # Ubuntu sub-jobs: + # ================ + # Pypy + - os: ubuntu-18.04 + python-version: pypy-2.7 + env: { STATIC_DEPS: false } + allowed_failure: true + - os: ubuntu-18.04 + python-version: pypy-3.7 + env: { STATIC_DEPS: false } + allowed_failure: true + + # MacOS sub-jobs + # ============== + - os: macos-10.15 + allowed_failure: true # Unicode parsing fails in Py3 + + # This defaults to 360 minutes (6h) which is way too long and if a test gets stuck, it can block other pipelines. + # From testing, the runs tend to take ~3 minutes, so a limit of 20 minutes should be enough. This can always be + # changed in the future if needed. + timeout-minutes: 20 + runs-on: ${{ matrix.os }} + + env: + OS_NAME: ${{ matrix.os }} + PYTHON_VERSION: ${{ matrix.python-version }} + MACOSX_DEPLOYMENT_TARGET: 10.14 + LIBXML2_VERSION: 2.9.10 + LIBXSLT_VERSION: 1.1.34 + COVERAGE: false + GCC_VERSION: 8 + USE_CCACHE: 1 + CCACHE_SLOPPINESS: "pch_defines,time_macros" + CCACHE_COMPRESS: 1 + CCACHE_MAXSIZE: "100M" + + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache [ccache] + uses: pat-s/always-upload-cache@v2.1.3 + if: startsWith(runner.os, 'Linux') + with: + path: ~/.ccache + key: ${{ runner.os }}-ccache${{ matrix.extra_hash }}-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt', '.github/**/ci.yml', '**/ci-run.sh') }} + + - name: Run CI + continue-on-error: ${{ matrix.allowed_failure || false }} + env: ${{ matrix.env }} + run: bash ./tools/ci-run.sh + + - name: Build docs + if: contains( env.EXTRA_DEPS, 'sphinx') + run: make html + + - name: Upload docs + uses: actions/upload-artifact@v2 + if: contains( env.EXTRA_DEPS, 'sphinx') + with: + name: website_html + path: doc/html + if-no-files-found: ignore + + - name: Upload Coverage Report + uses: actions/upload-artifact@v2 + with: + name: pycoverage_html + path: coverage* + if-no-files-found: ignore + + - name: Upload Wheel + uses: actions/upload-artifact@v2 + if: ${{ env.STATIC_DEPS == 'true' && matrix.extra_hash == 0 }} + with: + name: wheels-${{ runner.os }} + path: dist/*.whl + if-no-files-found: ignore @@ -545,8 +545,8 @@ def main(argv): # Set up tracing before we start importing things cov = None if cfg.run_tests and cfg.coverage: - from coverage import coverage - cov = coverage(omit=['test.py']) + from coverage import Coverage + cov = Coverage(omit=['test.py']) # Finding and importing test_files = get_test_files(cfg) diff --git a/tools/ci-run.sh b/tools/ci-run.sh new file mode 100644 index 00000000..e4f9be99 --- /dev/null +++ b/tools/ci-run.sh @@ -0,0 +1,65 @@ +#!/usr/bin/bash + +GCC_VERSION=${GCC_VERSION:=8} + +# Set up compilers +if [ -z "${OS_NAME##ubuntu*}" ]; then + echo "Installing requirements [apt]" + sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" + sudo apt-get update -y -q + sudo apt-get install -y -q ccache gcc-$GCC_VERSION "libxml2=2.9.4*" "libxml2-dev=2.9.4*" libxslt1.1 libxslt1-dev || exit 1 + sudo /usr/sbin/update-ccache-symlinks + echo "/usr/lib/ccache" >> $GITHUB_PATH # export ccache to path + + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 + + export CC="gcc" + +elif [ -z "${OS_NAME##macos*}" ]; then + export CC="clang -Wno-deprecated-declarations" +fi + +# Log versions in use +echo "====================" +echo "|VERSIONS INSTALLED|" +echo "====================" +python -c 'import sys; print("Python %s" % (sys.version,))' +if [ "$CC" ]; then + which ${CC%% *} + ${CC%% *} --version +fi +pkg-config --modversion libxml-2.0 libxslt +echo "====================" + +ccache -s || true + +# Install python requirements +echo "Installing requirements [python]" +python -m pip install -U pip setuptools wheel +if [ -z "${PYTHON_VERSION##*-dev}" ]; + then python -m pip install --install-option=--no-cython-compile https://github.com/cython/cython/archive/master.zip; + else python -m pip install -r requirements.txt; +fi +python -m pip install -U beautifulsoup4 cssselect html5lib rnc2rng ${EXTRA_DEPS} || exit 1 +if [ "$COVERAGE" == "true" ]; then + python -m pip install coverage || exit 1 + python -m pip install --pre 'Cython>=3.0a0' || exit 1 +fi + +# Build +CFLAGS="-Og -g -fPIC" python -u setup.py build_ext --inplace \ + $(if [ -n "${PYTHON_VERSION##2.*}" ]; then echo -n " -j7 "; fi ) \ + $(if [ "$COVERAGE" == "true" ]; then echo -n " --with-coverage"; fi ) \ + || exit 1 + +ccache -s || true + +# Run tests +CFLAGS="-Og -g -fPIC" PYTHONUNBUFFERED=x make test || exit 1 + +python setup.py bdist_wheel || exit 1 + +python setup.py install || exit 1 +python -c "from lxml import etree" || exit 1 + +ccache -s || true |