mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
Set up Github Actions CI (#440)
* Adjust tests: update Pip URLs, update expected output to match newer code * Test library: improve failure message to eliminate the illusion of extra leading space in "actual" output * Use Bats 1.2.0 like Pyenv * Install greadlink for old MacOS * Delete duplicate test
This commit is contained in:
37
.github/workflows/tests.yml
vendored
Normal file
37
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: tests
|
||||
on: [pull_request, push]
|
||||
jobs:
|
||||
tests:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-22.04
|
||||
- ubuntu-20.04
|
||||
- macos-12
|
||||
- macos-11
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
# Normally, we would use the superbly maintained...
|
||||
# - uses: actions/setup-python@v2
|
||||
# with:
|
||||
# python-version: ${{ matrix.python-version }}
|
||||
# ... but in the repo, we want to test pyenv builds on Ubuntu
|
||||
# - run: |
|
||||
# sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
|
||||
# libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
|
||||
# xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
|
||||
# https://github.com/pyenv/pyenv#installation
|
||||
#- env:
|
||||
# PYENV_ROOT: /home/runner/work/pyenv/pyenv
|
||||
# run: |
|
||||
# echo $PYENV_ROOT
|
||||
# echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
||||
# macos-11 Github Actions env has an old `readlink` and lacks `greadlink` which causes Bats to break
|
||||
- run: |
|
||||
if [[ $RUNNER_OS == "macOS" ]] && [[ $(sw_vers -productVersion | awk -F. '{print $1}') -lt 12 ]]; then
|
||||
brew install coreutils
|
||||
fi
|
||||
- run: git clone https://github.com/bats-core/bats-core.git --depth=1 -b v1.2.0 bats
|
||||
- run: bats/bin/bats --tap test
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bats
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
@@ -54,7 +54,7 @@ EOS
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
export PYENV_ACTIVATE_SHELL=
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate --quit
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate --quiet
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
@@ -110,36 +110,6 @@ fi;
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "deactivate virtualenv (quiet)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
export PYENV_ACTIVATE_SHELL=
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate --quiet
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
unset PYENV_VIRTUAL_ENV;
|
||||
unset VIRTUAL_ENV;
|
||||
if [ -n "\${_OLD_VIRTUAL_PATH:-}" ]; then
|
||||
export PATH="\${_OLD_VIRTUAL_PATH}";
|
||||
unset _OLD_VIRTUAL_PATH;
|
||||
fi;
|
||||
if [ -n "\${_OLD_VIRTUAL_PYTHONHOME:-}" ]; then
|
||||
export PYTHONHOME="\${_OLD_VIRTUAL_PYTHONHOME}";
|
||||
unset _OLD_VIRTUAL_PYTHONHOME;
|
||||
fi;
|
||||
if [ -n "\${_OLD_VIRTUAL_PS1:-}" ]; then
|
||||
export PS1="\${_OLD_VIRTUAL_PS1}";
|
||||
unset _OLD_VIRTUAL_PS1;
|
||||
fi;
|
||||
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||
unset -f deactivate;
|
||||
fi;
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "deactivate virtualenv (with shell activation)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
@@ -72,6 +72,8 @@ EOS
|
||||
run pyenv-virtualenv-init - fish
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
while set index (contains -i -- "${TMP}/pyenv/plugins/pyenv-virtualenv/shims" \$PATH)
|
||||
set -eg PATH[\$index]; end; set -e index
|
||||
set -gx PATH '${TMP}/pyenv/plugins/pyenv-virtualenv/shims' \$PATH;
|
||||
set -gx PYENV_VIRTUALENV_INIT 1;
|
||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
|
||||
@@ -63,7 +63,7 @@ OUT
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION=3.3.6 python3.3 -m venv ${PYENV_ROOT}/versions/3.3.6/envs/venv
|
||||
Installing pip from https://bootstrap.pypa.io/3.3/get-pip.py...
|
||||
Installing pip from https://bootstrap.pypa.io/pip/3.3/get-pip.py...
|
||||
PYENV_VERSION=3.3.6/envs/venv python -s ${TMP}/pyenv/cache/get-pip.py
|
||||
rehashed
|
||||
OUT
|
||||
|
||||
@@ -74,8 +74,10 @@ assert_failure() {
|
||||
|
||||
assert_equal() {
|
||||
if [ "$1" != "$2" ]; then
|
||||
{ echo "expected: $1"
|
||||
echo "actual: $2"
|
||||
{ echo "expected:"
|
||||
echo "$1"
|
||||
echo "actual:"
|
||||
echo "$2"
|
||||
} | flunk
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ unstub_pyenv() {
|
||||
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/venv
|
||||
Installing pip from https://bootstrap.pypa.io/get-pip.py...
|
||||
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
|
||||
rehashed
|
||||
OUT
|
||||
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
|
||||
@@ -67,7 +67,7 @@ OUT
|
||||
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/venv
|
||||
Installing pip from https://bootstrap.pypa.io/get-pip.py...
|
||||
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
|
||||
rehashed
|
||||
OUT
|
||||
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
|
||||
@@ -97,7 +97,7 @@ OUT
|
||||
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION=2.7.11 virtualenv --verbose --python=${TMP}/python ${PYENV_ROOT}/versions/2.7.11/envs/venv
|
||||
Installing pip from https://bootstrap.pypa.io/get-pip.py...
|
||||
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
|
||||
rehashed
|
||||
OUT
|
||||
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
|
||||
@@ -127,7 +127,7 @@ OUT
|
||||
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION=2.7.11 virtualenv --verbose --python=${TMP}/python ${PYENV_ROOT}/versions/2.7.11/envs/venv
|
||||
Installing pip from https://bootstrap.pypa.io/get-pip.py...
|
||||
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
|
||||
rehashed
|
||||
OUT
|
||||
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
|
||||
@@ -192,7 +192,7 @@ OUT
|
||||
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/foo
|
||||
Installing pip from https://bootstrap.pypa.io/get-pip.py...
|
||||
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
|
||||
rehashed
|
||||
OUT
|
||||
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/foo/bin/pydoc" ]
|
||||
|
||||
Reference in New Issue
Block a user