Skip to content

Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows #36

Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows

Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows #36

name: GitHub CI
on:
push:
branches:
- master
pull_request:
branches:
- master
defaults:
run:
shell: bash -l {0}
env:
PYTHONWARNINGS: ignore::UserWarning
PYTHON_BASE_PKGS: >
coverage xlrd
jobs:
build:
name: ${{ matrix.TARGET }}/${{ matrix.python }}${{ matrix.NAME }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3]
include:
- os: ubuntu-latest
TARGET: linux
PYENV: pip
- os: macos-latest
TARGET: osx
PYENV: pip
- os: windows-latest
TARGET: win
PYENV: conda
PACKAGES: setuptools coverage nose xlrd
exclude:
- {os: macos-latest, python: pypy2}
- {os: macos-latest, python: pypy3}
- {os: windows-latest, python: pypy2}
- {os: windows-latest, python: pypy3}
steps:
- uses: actions/checkout@v2
- name: Pip package cache
uses: actions/cache@v2
if: matrix.PYENV == 'pip'
id: pip-cache
with:
path: cache/pip
key: pip-v2-${{runner.os}}-${{matrix.python}}
- name: Download cache
uses: actions/cache@v2
id: download-cache
with:
path: cache/download
key: download-v4-${{runner.os}}
- name: Configure curl
run: |
CURLRC="$(cat <<EOF
retry = 0
max-time = 30
EOF
)"
echo "$CURLRC" > ${GITHUB_WORKSPACE}/.curlrc
echo "$CURLRC" > ${GITHUB_WORKSPACE}/_curlrc
echo "::set-env name=CURL_HOME::$GITHUB_WORKSPACE"
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Set up Miniconda Python ${{ matrix.python }}
if: matrix.PYENV == 'conda'
uses: goanpeca/setup-miniconda@v1
with:
auto-update-conda: true
python-version: ${{ matrix.python }}
# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
# invoke bash as a login shell ('shell: bash -l {0}') so that the
# conda environment is properly activated. However, running within
# a login shell appears to foul up the link to python from
# setup-python. Further, we have anecdotal evidence that
# subprocesses invoked through $(python -c ...) and `python -c ...`
# will not pick up the python activated by setup-python on OSX.
#
# Our solution is to define a PYTHON_EXE environment variable that
# can be explicitly called within subprocess calls to reach the
# correct interpreter. Note that we must explicitly run in a *non*
# login shell to set up the environment variable for the
# setup-python environments.
- name: Install Python Packages (pip)
if: matrix.PYENV == 'pip'
shell: bash
run: |
python -m pip install --cache-dir cache/pip --upgrade pip
pip install --cache-dir cache/pip ${PYTHON_BASE_PKGS}
if [[ ${{matrix.python}} == pypy ]] || [[ ${{matrix.python}} == 2.7 ]]; then
pip install --cache-dir cache/pip pyro
else
pip install --cache-dir cache/pip pyro4
fi
if [[ ${{matrix.python}} == 3.4 ]]; then
pip install --cache-dir cache/pip pyyaml<=5.2
elif [[ ${{matrix.python}} != 3.6 ]]; then
pip install --cache-dir cache/pip pyyaml
fi
python -c 'import sys; print("::set-env name=PYTHON_EXE::%s" \
% (sys.executable,))'
- name: Install Python packages (conda)
if: matrix.PYENV == 'conda'
run: |
mkdir -p $GITHUB_WORKSPACE/cache/conda
conda config --set always_yes yes
conda config --set auto_update_conda false
conda config --prepend pkgs_dirs $GITHUB_WORKSPACE/cache/conda
conda info
conda config --show-sources
conda list --show-channel-urls
conda install -q -y -c conda-forge -c anaconda ${{matrix.PACKAGES}}
python -c 'import sys; print("::set-env name=PYTHON_EXE::%s" \
% (sys.executable,))'
- name: Install Pyutilib
run: |
$PYTHON_EXE setup.py develop
- name: Set up coverage tracking
run: |
if test "${{matrix.TARGET}}" == win; then
COVERAGE_BASE=${GITHUB_WORKSPACE}\\.cover
else
COVERAGE_BASE=${GITHUB_WORKSPACE}/.cover
fi
COVERAGE_RC=${COVERAGE_BASE}_rc
echo "::set-env name=COVERAGE_RCFILE::$COVERAGE_RC"
echo "::set-env name=COVERAGE_PROCESS_START::$COVERAGE_RC"
cp ${GITHUB_WORKSPACE}/.coveragerc ${COVERAGE_RC}
echo "[run]" >> ${COVERAGE_RC}
echo "data_file=${COVERAGE_BASE}age" >> ${COVERAGE_RC}
SITE_PACKAGES=$($PYTHON_EXE -c "from distutils.sysconfig import \
get_python_lib; print(get_python_lib())")
echo "Python site-packages: $SITE_PACKAGES"
echo 'import coverage; coverage.process_startup()' \
> ${SITE_PACKAGES}/run_coverage_at_startup.pth
cat ${COVERAGE_RC}
- name: Run Pyutilib tests
run: |
if [ ${{matrix.TARGET}} == 'osx' ]; then
PYTHON_DIR=`dirname $PYTHON_EXE`
export PATH=$PYTHON_DIR:$PATH
fi
test.pyutilib --cat=all -v
- name: Process code coverage report
env:
CODECOV_NAME: ${{matrix.TARGET}}/${{matrix.python}}${{matrix.NAME}}
run: |
[ ! -d ${GITHUB_WORKSPACE}/cache/download ] && mkdir -pv ${GITHUB_WORKSPACE}/cache/download
coverage combine || echo "Nothing to combine."
coverage report -i
coverage xml -i
set +e
# Always attempt to update the codecov script, but fall back on
# the previously cached script if it fails
CODECOV="${GITHUB_WORKSPACE}/cache/download/codecov.sh"
for i in `seq 3`; do
echo "Downloading current codecov script (attempt ${i})"
curl -L https://codecov.io/bash -o $CODECOV
if test $? == 0; then
break
fi
DELAY=$(( RANDOM % 30 + 30))
echo "Pausing $DELAY seconds before re-attempting download"
sleep $DELAY
done
i=0
while : ; do
((i+=1))
echo "Uploading coverage to codecov (attempt ${i})"
bash $CODECOV -Z -X gcov -X s3 -f coverage.xml
if test $? == 0; then
echo "PASS" > ${GITHUB_WORKSPACE}/codecov.result
break
elif test $i -ge 2; then
# Do not fail the build just because the codecov upload fails
echo "FAIL" > ${GITHUB_WORKSPACE}/codecov.result
break
fi
DELAY=$(( RANDOM % 30 + 30))
echo "Pausing $DELAY seconds before re-attempting upload"
sleep $DELAY
done
- name: Record build artifacts
uses: actions/upload-artifact@v2
with:
name: ${{github.job}}_${{env.GHA_JOBNAME}}
path: |
codecov.result
# In general, do not record test results as artifacts to
# manage total artifact storage
# TEST-*.xml
post:
name: post-build
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4.1.7
with:
path: artifacts
- name: Check codecov upload success
run: |
FAIL=`grep FAIL artifacts/*/codecov.result | wc -l`
ALL=`ls -1 artifacts/*/codecov.result | wc -l`
# Fail is more than 1/9 codecov uploads fail
echo "$FAIL of $ALL codecov uploads failed"
if test $FAIL -gt 0; then
grep FAIL artifacts/*/codecov.result | sed 's/^/ /'
if test $(( $FAIL * 9 )) -gt $ALL; then
echo "More than 1/9 codecov uploads failed:"
exit 1
fi
fi