Skip to content

Commit

Permalink
Merge pull request #17 from oremanj/modernize-ci
Browse files Browse the repository at this point in the history
Modernize CI
  • Loading branch information
oremanj authored Jun 5, 2023
2 parents 3cce0b7 + e284d5c commit 55f619c
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 176 deletions.
54 changes: 43 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: CI

on:
push:
branches:
- master
pull_request:

jobs:
Expand All @@ -17,10 +20,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python }}'
# This allows the matrix to specify just the major.minor version while still
# expanding it to get the latest patch version including alpha releases.
# This avoids the need to update for each new alpha, beta, release candidate,
# and then finally an actual release version. actions/setup-python doesn't
# support this for PyPy presently so we get no help there.
#
# CPython -> 3.9.0-alpha - 3.9.X
# PyPy -> pypy-3.7
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
architecture: '${{ matrix.arch }}'
cache: pip
cache-dependency-path: test-requirements.txt
- name: Run tests
run: ./ci.sh
shell: bash
Expand All @@ -35,28 +48,40 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
check_docs: ['0']
python: ['pypy-3.8', 'pypy-3.9', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12-dev']
check_lint: ['0']
extra_name: ['']
include:
- python: '3.8'
check_docs: '1'
extra_name: ', check docs'
- python: '3.8'
check_lint: '1'
extra_name: ', formatting and linting'
continue-on-error: >-
${{
(
matrix.check_formatting == '1'
|| endsWith(matrix.python, '-dev')
)
&& true
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
if: "!endsWith(matrix.python, '-dev')"
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
cache: pip
cache-dependency-path: test-requirements.txt
- name: Setup python (dev)
uses: deadsnakes/[email protected]
if: endsWith(matrix.python, '-dev')
with:
python-version: '${{ matrix.python }}'
- name: Run tests
run: ./ci.sh
env:
CHECK_DOCS: '${{ matrix.check_docs }}'
CHECK_LINT: '${{ matrix.check_lint }}'
# Should match 'name:' up above
JOB_NAME: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
Expand All @@ -69,13 +94,20 @@ jobs:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
include:
- python: '3.8' # <- not actually used
arch: 'x64'
pypy_nightly_branch: 'py3.8'
extra_name: ', pypy 3.8 nightly'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python }}'
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
cache: pip
cache-dependency-path: test-requirements.txt
- name: Run tests
run: ./ci.sh
env:
Expand Down
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cleanliness and good test coverage, please be advised that
good idea at the time, and should be treated with according skepticism
if you're contemplating using it in production. It hasn't necessarily
been reviewed or tested to Trio's standards, it supports at minimum
Python 3.6, and some features might not be available on PyPy or on
Python 3.7, and some features might not be available on PyPy or on
Windows.

* If you find that it meets your needs, you're welcome to use it. We'll
Expand Down
6 changes: 4 additions & 2 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set -ex
EXIT_STATUS=0

# Autoformatter *first*, to avoid double-reporting errors
black --check setup.py tricycle \
|| EXIT_STATUS=$?
if ! black --check setup.py tricycle; then
EXIT_STATUS=1
black --diff setup.py tricycle
fi

# Run flake8 without pycodestyle and import-related errors
flake8 tricycle/ \
Expand Down
75 changes: 5 additions & 70 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,14 @@
set -ex -o pipefail

# Log some general info about the environment
uname -a
env | sort

if [ "$SYSTEM_JOBIDENTIFIER" != "" ]; then
# azure pipelines
CODECOV_NAME="$SYSTEM_JOBIDENTIFIER"
else
CODECOV_NAME="${TRAVIS_OS_NAME}-${TRAVIS_PYTHON_VERSION:-unknown}"
fi

################################################################
# Bootstrap python environment, if necessary
################################################################

### Azure pipelines + Windows ###

# On azure pipeline's windows VMs, to get reasonable performance, we need to
# jump through hoops to avoid touching the C:\ drive as much as possible.
if [ "$AGENT_OS" = "Windows_NT" ]; then
# By default temp and cache directories are on C:\. Fix that.
export TEMP="${AGENT_TEMPDIRECTORY}"
export TMP="${AGENT_TEMPDIRECTORY}"
export TMPDIR="${AGENT_TEMPDIRECTORY}"
export PIP_CACHE_DIR="${AGENT_TEMPDIRECTORY}\\pip-cache"

# Download and install Python from scratch onto D:\, instead of using the
# pre-installed versions that azure pipelines provides on C:\.
# Also use -DirectDownload to stop nuget from caching things on C:\.
nuget install "${PYTHON_PKG}" -Version "${PYTHON_VERSION}" \
-OutputDirectory "$PWD/pyinstall" -ExcludeVersion \
-Source "https://api.nuget.org/v3/index.json" \
-Verbosity detailed -DirectDownload -NonInteractive

pydir="$PWD/pyinstall/${PYTHON_PKG}"
export PATH="${pydir}/tools:${pydir}/tools/scripts:$PATH"

# Fix an issue with the nuget python 3.5 packages
# https://github.com/python-trio/trio/pull/827#issuecomment-457433940
rm -f "${pydir}/tools/pyvenv.cfg" || true
fi

### Travis + macOS ###

if [ "$TRAVIS_OS_NAME" = "osx" ]; then
CODECOV_NAME="osx_${MACPYTHON}"
curl -Lo macpython.pkg https://www.python.org/ftp/python/${MACPYTHON}/python-${MACPYTHON}-macosx10.6.pkg
sudo installer -pkg macpython.pkg -target /
ls /Library/Frameworks/Python.framework/Versions/*/bin/
PYTHON_EXE=/Library/Frameworks/Python.framework/Versions/*/bin/python3
# The pip in older MacPython releases doesn't support a new enough TLS
curl https://bootstrap.pypa.io/get-pip.py | sudo $PYTHON_EXE
sudo $PYTHON_EXE -m pip install virtualenv
$PYTHON_EXE -m virtualenv testenv
source testenv/bin/activate
fi

### PyPy nightly (currently on Travis) ###
### PyPy nightly ###

if [ "$PYPY_NIGHTLY_BRANCH" != "" ]; then
CODECOV_NAME="pypy_nightly_${PYPY_NIGHTLY_BRANCH}"
Expand Down Expand Up @@ -101,14 +53,7 @@ python -m pip --version
python setup.py sdist --formats=zip
python -m pip install dist/*.zip

if [ "$CHECK_DOCS" = "1" ]; then
python -m pip install -r docs-requirements.txt
towncrier --yes # catch errors in newsfragments
cd docs
# -n (nit-picky): warn on missing references
# -W: turn warnings into errors
sphinx-build -nW -b html source build
elif [ "$CHECK_LINT" = "1" ]; then
if [ "$CHECK_LINT" = "1" ]; then
python -m pip install -r test-requirements.txt
source check.sh
else
Expand All @@ -119,16 +64,6 @@ else
cd empty

INSTALLDIR=$(python -c "import os, tricycle; print(os.path.dirname(tricycle.__file__))")
cp ../setup.cfg $INSTALLDIR
pytest -W error -ra --junitxml=../test-results.xml -o faulthandler_timeout=60 ${INSTALLDIR} --cov="$INSTALLDIR" --cov-config=../.coveragerc --verbose

# Disable coverage on 3.8 until we run 3.8 on Windows CI too
# https://github.com/python-trio/trio/pull/784#issuecomment-446438407
if [[ "$(python -V)" != Python\ 3.8* ]]; then
# Disable coverage on pypy py3.6 nightly for now:
# https://bitbucket.org/pypy/pypy/issues/2943/
if [ "$PYPY_NIGHTLY_BRANCH" != "py3.6" ]; then
bash <(curl -s https://codecov.io/bash) -n "${CODECOV_NAME}"
fi
fi
cp ../pyproject.toml $INSTALLDIR
pytest -ra --junitxml=../test-results.xml ${INSTALLDIR} --cov="$INSTALLDIR" --cov-report=xml --cov-config=../.coveragerc --verbose
fi
Loading

0 comments on commit 55f619c

Please sign in to comment.