From 81a874d6b60f4feef60c345dc0d8f01eb715f6c5 Mon Sep 17 00:00:00 2001 From: LiHS Date: Fri, 21 Jul 2023 10:43:16 +0800 Subject: [PATCH] change ci to miniconda for old python compatible --- .github/workflows/ci-test.yml | 44 ++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index e4fce82b..03cad96f 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -6,36 +6,48 @@ jobs: fail-fast: false max-parallel: 1 matrix: - python_version: ['2.7', '3.4.10', '3.5', '3.6', '3.7', '3.8', '3.9'] + python_version: ['2.7', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9'] runs-on: ubuntu-20.04 steps: - name: Checkout repo uses: actions/checkout@v2 with: ref: ${{ github.ref }} - - name: Setup python - if: ${{ matrix.python_version != '3.4.10' }} - uses: actions/setup-python@v2 + - name: Setup miniconda + uses: conda-incubator/setup-miniconda@v2 with: + auto-update-conda: true + channels: conda-forge python-version: ${{ matrix.python_version }} - architecture: x64 - - name: Setup python manually - if: ${{ matrix.python_version == '3.4.10' }} + activate-environment: qiniu-sdk + auto-activate-base: false + - name: Setup pip + shell: bash -l {0} env: - PYTHON_SOURCE_URL: https://www.python.org/ftp/python/${{ matrix.python_version }}/Python-${{ matrix.python_version }}.tgz + PYTHON_VERSION: ${{ matrix.python_version }} + PIP_BOOTSTRAP_SCRIPT_PREFIX: https://bootstrap.pypa.io/pip run: | - cd /tmp - curl -s -L "$PYTHON_SOURCE_URL" | tar -zxf - -C ./ - cd Python-${{ matrix.python_version }} - ./configure --enable-optimizations - make - sudo make install - echo 'export PATH="/opt/python/bin:$PATH"' >> $HOME/.bashrc + MAJOR=$(echo "$PYTHON_VERSION" | cut -d'.' -f1) + MINOR=$(echo "$PYTHON_VERSION" | cut -d'.' -f2) + + # certifi too old for requests in python 3.4 + if [[ "$MAJOR.$MINOR" = "3.4" ]]; then + conda remove -y certifi + fi + + # reinstall pip by some python(<3.7) not compatible + if ! [[ $MAJOR -ge 3 && $MINOR -ge 7 ]]; then + cd /tmp + wget -qLO get-pip.py "$PIP_BOOTSTRAP_SCRIPT_PREFIX/$MAJOR.$MINOR/get-pip.py" + python get-pip.py --user + fi - name: Install dependencies + shell: bash -l {0} run: | python -m pip install --upgrade pip - pip install "coverage<7.2" flake8 pytest pytest-cov freezegun requests scrutinizer-ocular codecov + python -m pip install "coverage<7.2" flake8 pytest pytest-cov freezegun requests scrutinizer-ocular codecov - name: Run cases + shell: bash -l {0} env: QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }} QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}