You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
2.1 KiB

  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. set -ex
  8. # Prevent virtualenv from auto-updating pip to an incompatible version
  9. export VIRTUALENV_NO_DOWNLOAD=1
  10. # TODO: in the future, we could use an implementation of
  11. # https://github.com/python-poetry/poetry/issues/3527
  12. # https://github.com/pypa/pip/issues/8085
  13. # to select the lowest possible versions, rather than resorting to this sed script.
  14. # Patch the project definitions in-place:
  15. # - Replace all lower and tilde bounds with exact bounds
  16. # - Replace all caret bounds---but not the one that defines the supported Python version!
  17. # - Delete all lines referring to psycopg2 --- so no testing of postgres support.
  18. # - Use pyopenssl 17.0, which is the oldest version that works with
  19. # a `cryptography` compiled against OpenSSL 1.1.
  20. # - Omit systemd: we're not logging to journal here.
  21. sed -i \
  22. -e "s/[~>]=/==/g" \
  23. -e '/^python = "^/!s/\^/==/g' \
  24. -e "/psycopg2/d" \
  25. -e 's/pyOpenSSL = "==16.0.0"/pyOpenSSL = "==17.0.0"/' \
  26. -e '/systemd/d' \
  27. pyproject.toml
  28. # Use poetry to do the installation. This ensures that the versions are all mutually
  29. # compatible (as far the package metadata declares, anyway); pip's package resolver
  30. # is more lax.
  31. #
  32. # Rather than `poetry install --no-dev`, we drop all dev dependencies from the
  33. # toml file. This means we don't have to ensure compatibility between old deps and
  34. # dev tools.
  35. pip install toml wheel
  36. REMOVE_DEV_DEPENDENCIES="
  37. import toml
  38. with open('pyproject.toml', 'r') as f:
  39. data = toml.loads(f.read())
  40. del data['tool']['poetry']['dev-dependencies']
  41. with open('pyproject.toml', 'w') as f:
  42. toml.dump(data, f)
  43. "
  44. python3 -c "$REMOVE_DEV_DEPENDENCIES"
  45. pip install poetry==1.3.2
  46. poetry lock
  47. echo "::group::Patched pyproject.toml"
  48. cat pyproject.toml
  49. echo "::endgroup::"
  50. echo "::group::Lockfile after patch"
  51. cat poetry.lock
  52. echo "::endgroup::"