简体   繁体   中英

Running `pip` on container in GitHub action fails

I have a simple GitHub action that is supposed to set up a Python environment, install some packages using pip , notably pytest , and then run pytest :

name: CI

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.6"

      - name: Set up testing environment
        run: pip install -r test/requirements.txt

      - name: Run tests
        run: |
          source Setup.bsh
          cd test
          pytest

I'm testing a non-Python application, but using pytest as my test runner, because it's awesome. Everything works great, pytest gets installed, it executes and the tests pass.

I would like to run this test suite on multiple CentOS versions, as this is the environment I'll be using. The only way to do this is using a container. I added the following to the build section to first start running everything in CentOS 7:

  build:
    runs-on: ubuntu-latest
    container: 'centos:7'

I can see the Docker container getting created. The Set up Python step also runs within the container. The Set up testing environment fails, with the following message:"

Run pip install -r test/requirements.txt
  pip install -r test/requirements.txt
  shell: sh -e {0}
  env:
    pythonLocation: /__t/Python/3.6.15/x64
    LD_LIBRARY_PATH: /__t/Python/3.6.15/x64/lib
/__w/_temp/b7792e4c-dfd8-4f80-8787-865351941f66.sh: /__t/Python/3.6.15/x64/bin/pip: /opt/hostedtoolcache/Python/3.6.15/x64/bin/python: bad interpreter: No such file or directory

I don't know whether I'm doing anything wrong or whether this configuration (container and setup-python action) has an issue. Does anyone have any experience with this?

I figured out in the meantime that setup-python is not meant to use with containers. It references a Python that was compiled against the OS of the runner, so referencing that installation will very probably result in errors.

For example, if I try to run python directly in a CentOS 7 container, it will fail because CentOS 7 comes with a much older version of glibc than the one the Python in the tools cache was compiled against.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM