Skip to content

Commit

Permalink
Enable testing installed Kivy and test wheels and sdist from CI [buil…
Browse files Browse the repository at this point in the history
…d wheel].
  • Loading branch information
matham committed Dec 28, 2019
1 parent 0867471 commit 0ea6fe6
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 48 deletions.
45 changes: 45 additions & 0 deletions .ci/ubuntu_ci.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
set -e -x

generate_sdist() {
python3 -m pip install cython
python3 setup.py sdist --formats=gztar
python3 -m pip uninstall cython -y
}

install_kivy_test_run_apt_deps() {
sudo apt-get update
sudo apt-get -y install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
Expand All @@ -27,6 +33,13 @@ install_kivy_test_run_pip_deps() {
python3 -m pip install -I "$CYTHON_INSTALL" coveralls
}

install_kivy_test_wheel_run_pip_deps() {
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --user

python3 -m pip install --upgrade pip setuptools wheel
}

prepare_env_for_unittest() {
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background \
--exec /usr/bin/Xvfb -- :99 -screen 0 1280x720x24 -ac +extension GLX
Expand All @@ -40,11 +53,43 @@ install_kivy() {
cd "$path"
}

install_kivy_manylinux_wheel() {
root="$(pwd)"
python3 setup.py install --build_examples
cd ~

version=$(python3 -c "import sys; print('{}{}'.format(sys.version_info.major, sys.version_info.minor))")
kivy_fname=$(ls $root/dist/Kivy-*$version*.whl | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2- | head -n1)
python3 -m pip install "$kivy_fname[full,dev]"
}

install_kivy_sdist() {
root="$(pwd)"
cd ~

kivy_fname=$(ls $root/dist/Kivy-*.tar.gz)
python3 -m pip install "$kivy_fname[full,dev]"
}

test_kivy() {
rm -rf kivy/tests/build || true
KIVY_NO_ARGS=1 python3 -m pytest --cov=kivy --cov-report term --cov-branch "$(pwd)/kivy/tests"
}

test_kivy_install() {
cd ~
python3 -c 'import kivy'
test_path=$(KIVY_NO_CONSOLELOG=1 python3 -c 'import kivy.tests as tests; print(tests.__path__[0])' --config "kivy:log_level:error")
cd "$test_path"

cat > .coveragerc << 'EOF'
[run]
plugins = kivy.tools.coverage
EOF
KIVY_TEST_AUDIO=0 KIVY_NO_ARGS=1 python3 -m pytest .
}

upload_coveralls() {
python3 -m coveralls
}
Expand Down
67 changes: 55 additions & 12 deletions .ci/windows_ci.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
function raise-only-error{
Param([scriptblock]$Func)
# powershell interprets writing to stderr as an error, so only raise error if the return code is none-zero
try {
$Func.Invoke()
} catch {
if ($LastExitCode -ne 0) {
throw $_
} else {
echo $_
}
}
}

function Generate-sdist {
python -m pip install cython
python setup.py sdist --formats=gztar
python setup.py bdist_wheel --build_examples --universal
raise-only-error -Func {python setup.py bdist_wheel --build_examples --universal}
python -m pip uninstall cython -y
}

function Generate-windows-wheels {
Expand All @@ -17,16 +33,7 @@ function Rename-windows-wheels {
echo "Wheel date is: $WHEEL_DATE"
$GIT_TAG = git rev-parse --short HEAD
echo "Git tag is: $GIT_TAG"
# powershell interprets writing to stderr as an error, so only raise error if the return code is none-zero
try {
python -c "import kivy" --config "kivy:log_level:error"
} catch {
if ($LastExitCode -ne 0) {
throw $_
} else {
echo $_
}
}
raise-only-error -Func {python -c "import kivy" --config "kivy:log_level:error"}
$WHEEL_VERSION = python -c "import kivy;print(kivy.__version__)" --config "kivy:log_level:error"
echo "Kivy version is: $WHEEL_VERSION"
$TAG_NAME = python -c "import kivy; _, tag, n = kivy.parse_kivy_version(kivy.__version__); print(tag + n) if n is not None else print(tag or 'something')" --config "kivy:log_level:error"
Expand All @@ -53,7 +60,7 @@ function Install-kivy-test-run-win-deps {
}

function Install-kivy-test-run-pip-deps {
python -m pip install pip wheel setuptools cython --upgrade
python -m pip install pip wheel setuptools --upgrade
# workaround for https://github.com/pyinstaller/pyinstaller/issues/4265 until next release
python -m pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
}
Expand All @@ -66,6 +73,42 @@ function Install-kivy {
cd "$old"
}

function Install-kivy-wheel {
$root=(pwd).Path
cd "$HOME"

python -m pip install pip wheel setuptools --upgrade
# workaround for https://github.com/pyinstaller/pyinstaller/issues/4265 until next release
python -m pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

$version=python -c "import sys; print('{}{}'.format(sys.version_info.major, sys.version_info.minor))"
$kivy_fname=(ls $root/dist/Kivy-*$version*win_amd64*.whl | Sort-Object -property @{Expression={$_.name.tostring().Length}} | Select-Object -First 1).name
$kivy_examples_fname=(ls $root/dist/Kivy_examples-*.whl | Sort-Object -property @{Expression={$_.name.tostring().Length}} | Select-Object -First 1).name
python -m pip install "$root/dist/$kivy_fname[full,dev]" "$root/dist/$kivy_examples_fname"
}

function Install-kivy-sdist {
$root=(pwd).Path
cd "$HOME"

python -m pip install pip wheel setuptools --upgrade
# workaround for https://github.com/pyinstaller/pyinstaller/issues/4265 until next release
python -m pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

$kivy_fname=(ls $root/dist/Kivy-*.tar.gz).name
python -m pip install "$root/dist/$kivy_fname[full,dev]"
}

function Test-kivy {
python -m pytest --cov=kivy --cov-report term --cov-branch "$(pwd)/kivy/tests"
}

function Test-kivy-installed {
cd "$HOME"
python -c 'import kivy'
$test_path=python -c 'import kivy.tests as tests; print(tests.__path__[0])' --config "kivy:log_level:error"
cd "$test_path"

echo "[run]`nplugins = kivy.tools.coverage`n" > .coveragerc
raise-only-error -Func {python -m pytest .}
}
70 changes: 63 additions & 7 deletions .github/workflows/manylinux_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
DOCKER_IMAGE: 'quay.io/pypa/manylinux2010_x86_64'

jobs:
manylinux2010:
manylinux:
runs-on: ubuntu-18.04
if: github.event_name == 'schedule' || (github.event_name == 'create' && github.event.ref_type == 'tag') || contains(github.event.head_commit.message, '[build wheel]') || contains(github.event.head_commit.message, '[build wheel linux]') || contains(github.event.pull_request.title, '[build wheel]') || contains(github.event.pull_request.title, '[build wheel linux]')
steps:
Expand All @@ -40,7 +40,6 @@ jobs:
upload_file_to_server "$SERVER_IP" "linux/kivy/"
- name: Upload wheels as artifact
uses: actions/upload-artifact@master
if: github.event_name == 'pull_request'
with:
name: manylinux_wheels
path: dist
Expand All @@ -59,11 +58,68 @@ jobs:
files: dist/*
draft: true

always_job:
name: Always run job
manylinux_wheel_test:
runs-on: ubuntu-18.04
needs: manylinux
env:
DISPLAY: ':99.0'
steps:
- name: Always run
- uses: actions/checkout@v1
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x
- uses: actions/download-artifact@master
with:
name: manylinux_wheels
- name: Install dependencies
run: |
echo "This is run to prevent the workflow from showing an error if the wheels job is not run and no jobs run is an error."
echo "See https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38085"
mv manylinux_wheels dist
source .ci/ubuntu_ci.sh
install_kivy_test_run_apt_deps
install_kivy_test_wheel_run_pip_deps
- name: Setup env
run: |
source .ci/ubuntu_ci.sh
prepare_env_for_unittest
- name: Install Kivy
run: |
source .ci/ubuntu_ci.sh
install_kivy_manylinux_wheel
- name: Test Kivy
run: |
source .ci/ubuntu_ci.sh
test_kivy_install
sdist_test:
runs-on: ubuntu-18.04
env:
DISPLAY: ':99.0'
KIVY_SPLIT_EXAMPLES: 0
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x
- name: Generate sdist
run: |
source .ci/ubuntu_ci.sh
generate_sdist
- name: Install dependencies
run: |
source .ci/ubuntu_ci.sh
install_kivy_test_run_apt_deps
install_kivy_test_wheel_run_pip_deps
- name: Setup env
run: |
source .ci/ubuntu_ci.sh
prepare_env_for_unittest
- name: Install Kivy
run: |
source .ci/ubuntu_ci.sh
install_kivy_sdist
- name: Test Kivy
run: |
source .ci/ubuntu_ci.sh
test_kivy_install
27 changes: 26 additions & 1 deletion .github/workflows/osx_wheels_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ jobs:
upload_file_to_server "$SERVER_IP" "osx/kivy/"
- name: Upload wheels as artifact
uses: actions/upload-artifact@master
if: github.event_name == 'pull_request'
with:
name: osx_wheels
path: dist
Expand All @@ -89,6 +88,32 @@ jobs:
files: dist/*
draft: true

osx_wheel_test:
runs-on: macOS-latest
needs: osx_wheels
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x
- uses: actions/download-artifact@master
with:
name: osx_wheels
- name: Install dependencies
run: |
mv osx_wheels dist
source .ci/ubuntu_ci.sh
install_kivy_test_wheel_run_pip_deps
- name: Install Kivy
run: |
source .ci/ubuntu_ci.sh
install_kivy_manylinux_wheel
- name: Test Kivy
run: |
source .ci/ubuntu_ci.sh
test_kivy_install
osx_app:
runs-on: macOS-latest
if: false && github.event_name != 'pull_request' && (github.event_name == 'schedule' || (github.event_name == 'create' && github.event.ref_type == 'tag') || contains(github.event.head_commit.message, '[build app osx]')) || contains(github.event.pull_request.title, '[build app osx]')
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test_windows_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Windows Unittests
on: [push, pull_request]

env:
USE_SDL2: 1
USE_GSTREAMER: 1
GST_REGISTRY: '~/registry.bin'
KIVY_GL_BACKEND: 'angle_sdl2'
KIVY_SPLIT_EXAMPLES: 1
Expand Down
51 changes: 48 additions & 3 deletions .github/workflows/windows_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
env:
KIVY_SPLIT_EXAMPLES: 1
SERVER_IP: '159.203.106.198'
USE_SDL2: 1
USE_GSTREAMER: 1
GST_REGISTRY: '~/registry.bin'
KIVY_GL_BACKEND: 'angle_sdl2'

jobs:
windows_wheels:
Expand Down Expand Up @@ -64,7 +64,6 @@ jobs:
Upload-windows-wheels-to-server -ip "$env:SERVER_IP"
- name: Upload wheels as artifact
uses: actions/upload-artifact@master
if: github.event_name == 'pull_request'
with:
name: windows_wheels
path: dist
Expand All @@ -83,6 +82,52 @@ jobs:
files: dist/*
draft: true

windows_wheel_test:
runs-on: windows-latest
needs: windows_wheels
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.x
- uses: actions/download-artifact@v1
with:
name: windows_wheels
- name: Install Kivy Wheel
run: |
mv windows_wheels dist
. .\.ci\windows_ci.ps1
Install-kivy-wheel
- name: Test Kivy Wheel
run: |
. .\.ci\windows_ci.ps1
Test-kivy-installed
windows_sdist_test:
runs-on: windows-latest
needs: windows_wheels
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.x
- uses: actions/download-artifact@v1
with:
name: windows_wheels
- name: Install Kivy sdist
env:
KIVY_SPLIT_EXAMPLES: 0
run: |
mv windows_wheels dist
. .\.ci\windows_ci.ps1
Install-kivy-sdist
- name: Test Kivy sdist
run: |
. .\.ci\windows_ci.ps1
Test-kivy-installed
always_job:
name: Always run job
runs-on: windows-latest
Expand Down
Loading

0 comments on commit 0ea6fe6

Please sign in to comment.