CI: Bump CI Lint base image from bionic to jammy #26581

pull robigan wants to merge 2 commits into bitcoin:master from robigan:ci-bump changing 2 files +24 −11
  1. robigan commented at 8:44 AM on November 26, 2022: none

    As the title says, this PR aims to address #26548 by switching the lint CI job from ubuntu's bionic base image which has python 3.6.5 to ubuntu jammy and use pyenv to install the correct python version as dictated in the project's .python-version file.

    DISCLAIMER: This PR is a copy of #26572 as there were issues with that PR and how merging and squashing from the master branch were done

  2. Bump lint task base image
    Bump lint task base image from bionic to jammy
    b701c9a793
  3. DrahtBot commented at 8:44 AM on November 26, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #26716 (ci: Build python from source in "lint" task by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. DrahtBot added the label Tests on Nov 26, 2022
  5. robigan commented at 8:45 AM on November 26, 2022: none
  6. robigan force-pushed on Nov 26, 2022
  7. in ci/lint/04_install.sh:17 in d9ad2908ff outdated
      12 | -  # Temporary workaround for https://github.com/bitcoin/bitcoin/pull/26130#issuecomment-1260499544
      13 | -  # Can be removed once the underlying image is bumped to something that includes git2.34 or later
      14 | -  sed -i -e 's/bionic/jammy/g' /etc/apt/sources.list
      15 | -  ${CI_RETRY_EXE} apt-get update
      16 | -  ${CI_RETRY_EXE} apt-get install -y --reinstall git
      17 | -)
    


    hebasto commented at 8:59 AM on November 26, 2022:

    Shouldn't this removal be a part of the first commit?


    robigan commented at 9:04 AM on November 26, 2022:

    No, as the first commit just addresses bumping the version. This addresses actually removing the sources for making way for pyenv


    hebasto commented at 9:43 AM on November 26, 2022:

    The removed lines were a workaround to deal with an old/broken git version in Ubuntu Bionic. After bumping to Bionic, it is no longer required. And it has nothing to do with pyenv. That's why I still believe this change belongs to the first commit.

  8. in .cirrus.yml:76 in d9ad2908ff outdated
      74 | +    cpu: 2 # Assign 2 cores and 4G of ram in case .python-version has changed and cirrus has to rebuild python
      75 | +    memory: 4G
      76 | +  python_cache:
      77 | +    folder: /tmp/python-build # Uses intermediary directory for python caching. See the install.sh script in ci/lint/
      78 | +    fingerprint_script:
      79 | +      - echo $CIRRUS_OS
    


    hebasto commented at 9:00 AM on November 26, 2022:

    This task is the only user of python_cache. So why echo $CIRRUS_OS?


    robigan commented at 9:06 AM on November 26, 2022:

    Portability/future-proofing, the Cirrus docs also say that it is preferable to use it when caching content that is OS specific, and the python builds are OS specific

  9. Use pyenv for python 3.6.15
    This patch:
    - Sets up a cache in .cirrus.yml for pyenv's building of python 3.6.15 at the location /tmp/python-build/
    - Uses Operating System ($CIRRUS_OS), .python-version and checks the contents of the install scripts for calculating the hash of the cache
    - Installs necessary build libraries for building python with pyenv
    - Installs pyenv, runs init scripts and adds it to the path
    - Checks if a python cache is available and copies it to pyenv's version directories. If not, install it
    - And copies the python version in pyenv to the intermediary cache directory (It's up to Cirrus to decide if to cache it or not)
    ced77c2997
  10. robigan force-pushed on Nov 26, 2022
  11. robigan commented at 9:07 AM on November 26, 2022: none

    Just quickly amended my commit as I forgot pyenv complains about python versions being already present

  12. in .cirrus.yml:79 in ced77c2997
      78 | +    folder: /tmp/python-build # Uses intermediary directory for python caching. See the install.sh script in ci/lint/
      79 | +    fingerprint_script:
      80 | +      - echo $CIRRUS_OS
      81 | +      - cat .python-version
      82 | +      - cat ./ci/lint_run_all.sh
      83 | +      - cat ./ci/lint/*.sh
    


    hebasto commented at 9:46 AM on November 26, 2022:

    Why?


    robigan commented at 9:47 AM on November 26, 2022:

    If you change the lint scripts (which might change how you interact with the cache), you'd want to be able to test that no? And if you do end up changing how caching works. You'd want a new cache uploaded wouldn't you?


    hebasto commented at 9:58 AM on November 26, 2022:

    Still trying to understand you, but we don't want to consume resources to rebuild python after every change in linter scripts. What kind of such changes could lead to different python binaries?


    robigan commented at 12:53 AM on November 27, 2022:

    Consume? I wouldn't say so, 2 cores and 4G of RAM are small amounts nowadays. If you really want to be specific, then I could put the python build scripts into a separate file and cat only that. Or if you really really want to make sure you don't waist any resources, then a separate task which builds python in the Cirrus CI is needed

  13. hebasto commented at 1:39 PM on November 26, 2022: member

    This:

    /root/.pyenv/plugins/python-build/bin/python-build: line 1790: 17770 Segmentation fault      (core dumped) "$PYTHON_BIN" -c "import $1" > /dev/null 2>&1
    WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
    /root/.pyenv/plugins/python-build/bin/python-build: line 2001: 17777 Segmentation fault      (core dumped) "$PYTHON_BIN" -s -m ensurepip ${ensurepip_opts} > /dev/null 2>&1
    

    does not look correct, does it?

  14. hebasto commented at 7:16 PM on November 26, 2022: member

    Here is an alternative implementation, which:

    NOTE: To test the lint CI task in a personal Cirrus account, the patch from #20728 is required. For example:

  15. robigan commented at 12:59 AM on November 27, 2022: none

    Both implementations are just as good. But I'll provide further comment in the morning, it's late and I am tipsy so I need some good sleep before I do anything

  16. robigan commented at 11:11 AM on November 27, 2022: none

    This:

    /root/.pyenv/plugins/python-build/bin/python-build: line 1790: 17770 Segmentation fault      (core dumped) "$PYTHON_BIN" -c "import $1" > /dev/null 2>&1
    WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
    /root/.pyenv/plugins/python-build/bin/python-build: line 2001: 17777 Segmentation fault      (core dumped) "$PYTHON_BIN" -s -m ensurepip ${ensurepip_opts} > /dev/null 2>&1
    

    does not look correct, does it?

    Here is an alternative implementation, which:

    * uses pyenv's `python-build` [standalone](https://github.com/pyenv/pyenv/tree/master/plugins/python-build#using-python-build-standalone); no other tools required
    
    * switches from gcc to clang to avoid issues like [Segmentation fault when installing Python 3.6.15 on Ubuntu 22.04 pyenv/pyenv#2359](https://github.com/pyenv/pyenv/issues/2359)
    
    * avoids copying of the cache
    
    * requires no additional computational resources

    @robigan Feel free to cherry-pick it into this PR.

    NOTE: To test the lint CI task in a personal Cirrus account, the patch from #20728 is required. For example:

    * https://cirrus-ci.com/task/6626175015976960
    
    * https://cirrus-ci.com/task/6276286176296960

    Yes I noticed this, I ignored it because it wasn't affecting the linting process in any way, but is worth addressing. Clang could be a good alternative. And we can skip using python-build from pyenv and set the flags right from the pyenv install script. Although it doesn't address the fact that it seems it has got to do with openssl instead of fixing it with clang, as pointed out by the issue you linked.

  17. robigan commented at 11:14 AM on November 27, 2022: none

    Here is an alternative implementation, which:

    * uses pyenv's `python-build` [standalone](https://github.com/pyenv/pyenv/tree/master/plugins/python-build#using-python-build-standalone); no other tools required
    
    * switches from gcc to clang to avoid issues like [Segmentation fault when installing Python 3.6.15 on Ubuntu 22.04 pyenv/pyenv#2359](https://github.com/pyenv/pyenv/issues/2359)
    
    * avoids copying of the cache
    
    * requires no additional computational resources

    @robigan Feel free to cherry-pick it into this PR.

    NOTE: To test the lint CI task in a personal Cirrus account, the patch from #20728 is required. For example:

    * https://cirrus-ci.com/task/6626175015976960
    
    * https://cirrus-ci.com/task/6276286176296960

    Python-build can be used if we so wish, as I have said, using pyenv executable just makes maintaining this easier. And if we so wish to use clang, we can still use pyenv. And what do you mean by it doesn't use other tools? It's all the same thing.

  18. robigan commented at 11:17 AM on November 27, 2022: none

    Here is an alternative implementation, which:

    * uses pyenv's `python-build` [standalone](https://github.com/pyenv/pyenv/tree/master/plugins/python-build#using-python-build-standalone); no other tools required
    
    * switches from gcc to clang to avoid issues like [Segmentation fault when installing Python 3.6.15 on Ubuntu 22.04 pyenv/pyenv#2359](https://github.com/pyenv/pyenv/issues/2359)
    
    * avoids copying of the cache
    
    * requires no additional computational resources

    @robigan Feel free to cherry-pick it into this PR.

    NOTE: To test the lint CI task in a personal Cirrus account, the patch from #20728 is required. For example:

    * https://cirrus-ci.com/task/6626175015976960
    
    * https://cirrus-ci.com/task/6276286176296960

    Copying of the cache is hardly an issue, copy takes less than a second. That's if you're coming from a resource waste point of view. If it's for simplicity's sake, then yes I agree. And for the record it was @MarcoFalke's idea to bump resources used by the linting task. If we want to do this the right way, then the building of python itself should be done in a separate Cirrus CI Task, and then by using caches, deploy the caches as needed to other tasks

  19. in ci/lint/04_install.sh:13 in ced77c2997
      15 | -  ${CI_RETRY_EXE} apt-get update
      16 | -  ${CI_RETRY_EXE} apt-get install -y --reinstall git
      17 | -)
      18 | +${CI_RETRY_EXE} apt-get install -y make build-essential libssl-dev zlib1g-dev \
      19 | +libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
      20 | +libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
    


    hebasto commented at 1:49 PM on November 27, 2022:

    Assuming that those packages are required to build the Python, why are they installed every time, regardless of using of the cached Python?

    The curl package was installed two lines above.

    Why are llvm, xz-utils and libffi-dev packages required?


    robigan commented at 3:08 PM on November 27, 2022:

    The packages listed there is an exact copy as detailed by the pyenv docs. As I have said, my concern is making it as maintainable as possible

  20. hebasto commented at 1:58 PM on November 27, 2022: member

    As we have a self-compiled Python, the python3-pip package can be dropped now, right?

    After the first commit, the lint task uses the system Python which is not v3.6.15. It is the reason to re-order commits.

    Regarding resources, I'll try to clarify my statement. It is not about resources actually consumed by a task. Rather about the requested amount of resources, because they do affect the scheduling time when using Cirrus Community Cluster. See: https://cirrus-ci.org/guide/linux/

  21. hebasto commented at 2:04 PM on November 27, 2022: member

    Going to re-run the lint task manually, to check it with the cached Python.

  22. robigan commented at 3:09 PM on November 27, 2022: none

    As we have a self-compiled Python, the python3-pip package can be dropped now, right?

    After the first commit, the lint task uses the system Python which is not v3.6.15. It is the reason to re-order commits.

    Regarding resources, I'll try to clarify my statement. It is not about resources actually consumed by a task. Rather about the requested amount of resources, because they do affect the scheduling time when using Cirrus Community Cluster. See: https://cirrus-ci.org/guide/linux/

    Then in that case I do strongly believe that making a separate task which only builds python is the best way

  23. fanquake renamed this:
    CI: Bump CI Lint base image from bionic to jammy [Properly]
    CI: Bump CI Lint base image from bionic to jammy
    on Nov 28, 2022
  24. maflcko commented at 4:28 PM on December 13, 2022: member

    Are you still working on this? See also https://github.com/bitcoin/bitcoin/pull/26637

  25. hebasto commented at 1:40 PM on December 17, 2022: member

    Are you still working on this? See also #26637

    See #26716.

  26. fanquake commented at 4:04 PM on December 20, 2022: member

    No response here, so closing in favour of #26716.

  27. fanquake closed this on Dec 20, 2022

  28. robigan commented at 1:04 AM on January 2, 2023: none

    Yeah no haven't been able to work on this given that I have family

  29. maflcko referenced this in commit 01ec5308bf on Jan 17, 2023
  30. sidhujag referenced this in commit c4990322a2 on Jan 17, 2023
  31. bitcoin locked this on Jan 2, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 00:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me