test_old_deps.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/env bash
  2. # this script is run by GitHub Actions in a plain `focal` container; it
  3. # - installs the minimal system requirements, and poetry;
  4. # - patches the project definition file to refer to old versions only;
  5. # - creates a venv with these old versions using poetry; and finally
  6. # - invokes `trial` to run the tests with old deps.
  7. # Prevent tzdata from asking for user input
  8. export DEBIAN_FRONTEND=noninteractive
  9. set -ex
  10. apt-get update
  11. apt-get install -y \
  12. python3 python3-dev python3-pip python3-venv pipx \
  13. libxml2-dev libxslt-dev xmlsec1 zlib1g-dev libjpeg-dev libwebp-dev
  14. export LANG="C.UTF-8"
  15. # Prevent virtualenv from auto-updating pip to an incompatible version
  16. export VIRTUALENV_NO_DOWNLOAD=1
  17. # TODO: in the future, we could use an implementation of
  18. # https://github.com/python-poetry/poetry/issues/3527
  19. # https://github.com/pypa/pip/issues/8085
  20. # to select the lowest possible versions, rather than resorting to this sed script.
  21. # Patch the project definitions in-place:
  22. # - Replace all lower and tilde bounds with exact bounds
  23. # - Make the pyopenssl 17.0, which is the oldest version that works with
  24. # a `cryptography` compiled against OpenSSL 1.1.
  25. # - Delete all lines referring to psycopg2 --- so no testing of postgres support.
  26. # - Omit systemd: we're not logging to journal here.
  27. # TODO: also replace caret bounds, see https://python-poetry.org/docs/dependency-specification/#version-constraints
  28. # We don't use these yet, but IIRC they are the default bound used when you `poetry add`.
  29. # The sed expression 's/\^/==/g' ought to do the trick. But it would also change
  30. # `python = "^3.7"` to `python = "==3.7", which would mean we fail because olddeps
  31. # runs on 3.8 (#12343).
  32. sed -i \
  33. -e "s/[~>]=/==/g" \
  34. -e "/psycopg2/d" \
  35. -e 's/pyOpenSSL = "==16.0.0"/pyOpenSSL = "==17.0.0"/' \
  36. -e '/systemd/d' \
  37. pyproject.toml
  38. # Use poetry to do the installation. This ensures that the versions are all mutually
  39. # compatible (as far the package metadata declares, anyway); pip's package resolver
  40. # is more lax.
  41. #
  42. # Rather than `poetry install --no-dev`, we drop all dev dependencies from the
  43. # toml file. This means we don't have to ensure compatibility between old deps and
  44. # dev tools.
  45. pip install --user toml
  46. REMOVE_DEV_DEPENDENCIES="
  47. import toml
  48. with open('pyproject.toml', 'r') as f:
  49. data = toml.loads(f.read())
  50. del data['tool']['poetry']['dev-dependencies']
  51. with open('pyproject.toml', 'w') as f:
  52. toml.dump(data, f)
  53. "
  54. python3 -c "$REMOVE_DEV_DEPENDENCIES"
  55. pipx install poetry==1.1.12
  56. ~/.local/bin/poetry lock
  57. echo "::group::Patched pyproject.toml"
  58. cat pyproject.toml
  59. echo "::endgroup::"
  60. echo "::group::Lockfile after patch"
  61. cat poetry.lock
  62. echo "::endgroup::"
  63. ~/.local/bin/poetry install -E "all test"
  64. ~/.local/bin/poetry run trial --jobs=2 tests