Continious Integration using github actions

This commit is contained in:
Gabriel Pettier 2019-09-17 15:08:24 +02:00
parent 104ef47d0b
commit fe41ee5bd5
11 changed files with 185 additions and 208 deletions

View File

@ -1,114 +0,0 @@
platform:
-x64
matrix:
fast_finish: true
environment:
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
PYTHON_ARCH: "64"
matrix:
- PYTHON_VERSION: "2.7"
JAVA_VERSION: "8"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- PYTHON_VERSION: "3.6"
JAVA_VERSION: "8"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- PYTHON_VERSION: "3.7"
JAVA_VERSION: "8"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- PYTHON_VERSION: "2.7"
JAVA_VERSION: "9"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- PYTHON_VERSION: "3.6"
JAVA_VERSION: "9"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- PYTHON_VERSION: "3.7"
JAVA_VERSION: "9"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- PYTHON_VERSION: "2.7"
JAVA_VERSION: "10"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- PYTHON_VERSION: "3.6"
JAVA_VERSION: "10"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- PYTHON_VERSION: "3.7"
JAVA_VERSION: "10"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- PYTHON_VERSION: "2.7"
JAVA_VERSION: "11"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- PYTHON_VERSION: "3.6"
JAVA_VERSION: "11"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- PYTHON_VERSION: "3.7"
JAVA_VERSION: "11"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
install:
# Set platform variables
- if "%PYTHON_ARCH%" == "64" set "ARCH_LABEL=-x64"
- if "%PYTHON_ARCH%" == "32" set "PROGRAM_ARCH_LABEL= (x86)"
- echo ARCH_LABEL %ARCH_LABEL%
- echo PROGRAM_ARCH_LABEL %PROGRAM_ARCH_LABEL%
# Use Miniconda already installed on Appveyor
- set "BASE_PYTHON_VERSION=37"
- set "CONDA_ROOT=C:\Miniconda%BASE_PYTHON_VERSION%%ARCH_LABEL%"
- set "PATH=%CONDA_ROOT%;%CONDA_ROOT%\Scripts;%CONDA_ROOT%\Library\bin;%PATH%"
- set PATH
- echo CONDA_PREFIX %CONDA_PREFIX%
- conda config --set always_yes yes
# Update conda
- conda config --add channels conda-forge
- conda install -y conda --no-pin
- "%CONDA_ROOT%\\Scripts\\activate"
- echo CONDA_PREFIX %CONDA_PREFIX%
- conda info -a
# Set the correct compiler version (only for runtime)
# Not sure this is needed.
- set "COMPILER_VERSION=14"
- if "%PYTHON_VERSION%" == "2.7" set "COMPILER_VERSION=9"
# Create project specific environment with specified Python version
- conda create -y -n pyjnius_env python=%PYTHON_VERSION% openjdk=%JAVA_VERSION% vc=%COMPILER_VERSION% ant cython pip six>=1.7.0 setuptools nose
- if errorlevel 1 exit 1
# Skip .NET project specific build phase.
build: false
test_script:
# Activate Conda environment
- "%CONDA_ROOT%\\Scripts\\activate pyjnius_env"
- echo CONDA_PREFIX %CONDA_PREFIX%
- echo PATH %PATH%
# Print some info
- echo PYTHON_VERSION %PYTHON_VERSION%
- echo JAVA_VERSION %JAVA_VERSION%
- echo JAVA_HOME %JAVA_HOME%
- echo JDK_HOME %JDK_HOME%
- python -c "import sys; print(sys.version)"
- python -c "import sys; print(sys.executable)"
- python -c "import sys; print(sys.prefix)"
- python --version
# Build pyjnius
- ant all
- if errorlevel 1 exit 1
- pip install --no-deps -v -e .
- if errorlevel 1 exit 1
# Java needs to be added to PATH
- set "PATH=%JAVA_HOME%\jre\bin\server;%JAVA_HOME%\bin\server;%JAVA_HOME%\bin;%PATH%"
# Run tests
- python -c "import jnius"
- python -c "from jnius import autoclass;print(autoclass('java.lang.System').getProperty('java.version'))"
- if errorlevel 1 exit 1
- set "CLASSPATH=%cd%\build\test-classes;..\build\classes;%CLASSPATH%"
- cd tests/ && nosetests -v
- if errorlevel 1 exit 1

12
.github/actions/scripts/release.sh vendored Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -ex
if [[ "refs/tags/$(git tag | tail -n 1)" = $GITHUB_REF ]]; then
pip install -U setuptools wheel twine
python -m twine check dist/*
if [[ $GITHUB_REF =~ -test$ ]]; then
python -m twine upload -u kivybot --disable-progress-bar --repository-url https://test.pypi.org/legacy/ dist/*
else
python -m twine upload -u kivybot --disable-progress-bar dist/*
fi
fi

4
.github/actions/scripts/setup.sh vendored Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
pip install .[dev]
pytest

18
.github/workflows/create.yml vendored Normal file
View File

@ -0,0 +1,18 @@
on: create
name: Continiuous Delivery
jobs:
Release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: build
run: |
pip install -U setuptools
python setup.py sdist
- name: release
run: .github/actions/scripts/release.sh
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
GITHUB_OAUTH_TOKEN: ${{ secrets.GITHUB_OAUTH_TOKEN }}

100
.github/workflows/push.yml vendored Normal file
View File

@ -0,0 +1,100 @@
on: push
name: Continious Integration
jobs:
Tests:
name: base
strategy:
matrix:
python:
- '2.7'
- '3.6'
- '3.7'
- '3.8'
java:
- '8'
- '9'
- '10'
- '11'
- '12'
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macOs-latest'
architecture:
- 'x64'
- 'x86'
# exclude problematic combinations
exclude:
- os: windows-latest
python: '3.8'
- os: windows-latest
python: '2.7'
- os: macOs-latest
architecture: 'x86'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Setup python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
architecture: ${{ matrix.architecture }}
- name: install-windows
if: matrix.os == 'windows-latest'
run: |
"%VS140COMNTOOLS%../../VC/vcvarsall.bat"
echo "$INCLUDE"
set INCLUDE "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
pip install --timeout=120 -U setuptools cython
pip install --timeout=120 -vv .[dev,ci]
- name: install
if: matrix.os == 'ubuntu-latest'
run: |
pip install --timeout=120 -U setuptools cython
pip install --timeout=120 .[dev,ci]
- name: install-osx
if: matrix.os == 'macOs-latest'
run: |
brew install ant
pip install --timeout=120 --user -U setuptools cython
pip install --timeout=120 --user .[dev,ci]
- name: test-windows
if: matrix.os == 'windows-latest'
run: |
$env:PATH +=";$env:JAVA_HOME\jre\bin\server\;$env:JAVA_HOME\jre\bin\client\;$env:JAVA_HOME\bin\server\"
$env:CLASSPATH ="../build/test-classes;../build/classes"
ant all
cd tests
nosetests -v
- name: test
if: matrix.os == 'ubuntu-latest'
run: |
ant all
cd tests
CLASSPATH=../build/test-classes:../build/classes nosetests -v
- name: test
if: matrix.os == 'macOs-latest'
run: |
ant all
cd tests
CLASSPATH=../build/test-classes:../build/classes python -m nose -v
# - name: coveralls
# run: python -m coveralls
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

View File

@ -1,55 +0,0 @@
language: generic
os:
- linux
- osx
env:
- PYTHON_VERSION="2.7" JAVA_VERSION="8"
- PYTHON_VERSION="3.6" JAVA_VERSION="8" RUN="sdist"
- PYTHON_VERSION="3.7" JAVA_VERSION="8"
- PYTHON_VERSION="2.7" JAVA_VERSION="9"
- PYTHON_VERSION="3.6" JAVA_VERSION="9"
- PYTHON_VERSION="3.7" JAVA_VERSION="9"
- PYTHON_VERSION="2.7" JAVA_VERSION="10"
- PYTHON_VERSION="3.6" JAVA_VERSION="10"
- PYTHON_VERSION="3.7" JAVA_VERSION="10"
- PYTHON_VERSION="2.7" JAVA_VERSION="11"
- PYTHON_VERSION="3.6" JAVA_VERSION="11"
- PYTHON_VERSION="3.7" JAVA_VERSION="11"
matrix:
fast_finish: true
install:
- if [ "$TRAVIS_OS_NAME" = linux ]; then
sudo apt-get update;
MINICONDAVERSION="Linux";
else
MINICONDAVERSION="MacOSX";
fi;
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-$MINICONDAVERSION-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- echo ". $HOME/miniconda/etc/profile.d/conda.sh" >> $HOME/.bashrc
- source $HOME/.bashrc
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda config --add channels conda-forge
- conda update -q conda
- conda info -a
- conda create -n jnius_env python=$PYTHON_VERSION
- conda activate jnius_env
- conda install openjdk=$JAVA_VERSION cython nose ant pip setuptools six
script:
- conda activate jnius_env
- if [ "$RUN" = "sdist" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ "$PYJNIUS_DEPLOY" == "1" ]; then
conda install twine;
python setup_sdist.py sdist;
python -m twine upload dist/*;
fi;
else
make && make tests;
fi;

View File

@ -2,13 +2,8 @@ all: build_ext
.PHONY: build_ext tests
ifdef PYTHON3
PYTHON=python3
NOSETESTS=nosetests-3.4
else
PYTHON=python
NOSETESTS=nosetests
endif
JAVA_TARGET ?= $(shell $(PYTHON) -c "import re; print('1.6' if int(re.findall(r'\d+', '$(shell javac -version 2>&1)')[0]) < 12 else '1.7')" )
JAVAC_OPTS=-target $(JAVA_TARGET) -source $(JAVA_TARGET)

View File

@ -40,27 +40,30 @@ hello
Usage on desktop
----------------
You need a java JDK installed (OpenJDK will do), Cython and make to build it.
Please ensure that your `JDK_HOME` or `JAVA_HOME` environment variable points
to the installed JDK root directory, and that the JVM library (`jvm.so` or
`jvm.dll`) is available from your `PATH` environment variable. **Failure to do
so may result in a failed install, or a successful install but inability to
use the pyjnius library.**
You need a Java Development Kit (JDK) installed (OpenJDK will do), `Cython` and
`make` to build it. Please ensure that your `JDK_HOME` or `JAVA_HOME`
environment variable points to the installed JDK root directory, and that the
JVM library (`jvm.so` or `jvm.dll`) is available from your `PATH` environment
variable. **Failure to do so may result in a failed install, or a successful
install but inability to use the PyJNIus library.**
make
```
make
```
That's it! You can run the tests using
That's it! You can ensure everything is running correctly using::
make tests
to ensure everything is running correctly.
```
make tests
```
Usage with python-for-android
-----------------------------
* Get http://github.com/kivy/python-for-android
* Compile a distribution with kivy (pyjnius will be automatically added)
* Then, you can do this kind of thing:
* Get [http://github.com/kivy/python-for-android]()
* Compile a distribution with kivy (PyJNIus will be automatically added)
Then, you can do this kind of things:
```python
from time import sleep
@ -106,8 +109,8 @@ I/python ( 5983): [0.13407529890537262, 9.4235782623291016, 2.2026655673980713]
Advanced example
----------------
When you use autoclass, it will discover all the methods and fields of the
object and resolve them. For now, it is better to declare and use only what you
When you use `autoclass`, it will discover all the methods and fields of the
class and resolve them. You may want to declare and use only what you
need. The previous example can be done manually as follows:
```python
@ -139,11 +142,9 @@ If you need assistance, you can ask for help on our mailing list:
* User Group : https://groups.google.com/group/kivy-users
* Email : kivy-users@googlegroups.com
We also have an IRC channel:
We also have a Discord server:
* Server : irc.freenode.net
* Port : 6667, 6697 (SSL only)
* Channel : #kivy
[https://chat.kivy.org/](https://chat.kivy.org/)
Contributing
------------
@ -158,17 +159,11 @@ discussions about developing the Kivy framework and its sister projects:
* Dev Group : https://groups.google.com/group/kivy-dev
* Email : kivy-dev@googlegroups.com
IRC channel:
* Server : irc.freenode.net
* Port : 6667, 6697 (SSL only)
* Channel : #kivy-dev
License
-------
PyJNIus is released under the terms of the MIT License. Please refer to the
LICENSE file.
LICENSE file for more information.
## Backers

View File

@ -696,7 +696,10 @@ cdef class JavaMethod(object):
return
cdef JNIEnv *j_env = get_jnienv()
if self.name is None:
raise JavaException('Unable to find a None method!')
raise JavaException(
'Unable to find a None method!\nclassname: {}, definition: {}'
.format(self.classname, self.definition)
)
if self.is_static:
defstr = str_for_c(self.definition)
self.j_method = j_env[0].GetStaticMethodID(

View File

@ -3,10 +3,7 @@ Setup.py for creating a binary distribution.
'''
from __future__ import print_function
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
from setuptools import setup, Extension
try:
import subprocess32 as subprocess
except ImportError:
@ -19,6 +16,7 @@ import sys
from platform import machine
from setup_sdist import SETUP_KWARGS
PY2 = sys.version_info < (3, 0, 0)
@ -212,6 +210,7 @@ else:
MACHINE2CPU = {
"i686": "i386",
"x86_64": "amd64",
"AMD64": "amd64",
"armv7l": "arm",
"sun4u": "sparcv9",
"sun4v": "sparcv9"
@ -271,8 +270,10 @@ else:
with open(join(dirname(__file__), 'jnius', 'config.pxi'), 'w') as fd:
fd.write('DEF JNIUS_PLATFORM = {0!r}\n\n'.format(PLATFORM))
if not PY2:
fd.write('# cython: language_level=3\n\n')
fd.write('DEF JNIUS_PYTHON3 = True\n\n')
else:
fd.write('# cython: language_level=2\n\n')
fd.write('DEF JNIUS_PYTHON3 = False\n\n')
if LIB_LOCATION is not None:
fd.write('DEF JNIUS_LIB_SUFFIX = {0!r}\n\n'.format(LIB_LOCATION))
@ -291,8 +292,13 @@ setup(
libraries=LIBRARIES,
library_dirs=LIBRARY_DIRS,
include_dirs=INCLUDE_DIRS,
extra_link_args=EXTRA_LINK_ARGS
extra_link_args=EXTRA_LINK_ARGS,
# extra_objects=['jnius.{}'.format('pyd' if PLATFORM == 'win32' else 'so')]
)
],
extras_require={
'dev': ['nose', 'wheel', 'pytest-cov', 'pycodestyle'],
'ci': ['coveralls', 'pytest-rerunfailures', 'setuptools>=34.4.0'],
},
**SETUP_KWARGS
)

View File

@ -6,11 +6,15 @@ distribution and the ordinary setup.py for binary distribution. Running this
instead of the default setup.py will create a GitHub-like archive with setup.py
meant for installing via pip.
'''
from io import open
# pylint: disable=import-error,no-name-in-module
from distutils.core import setup
from os.path import join
with open("README.md", encoding='utf8') as f:
README = f.read()
with open(join('jnius', '__init__.py')) as fd:
VERSION = [
@ -22,25 +26,34 @@ with open(join('jnius', '__init__.py')) as fd:
SETUP_KWARGS = {
'name': 'pyjnius',
'version': VERSION,
'url': "https://github.com/kivy/pyjnius",
'packages': ['jnius'],
'py_modules': ['jnius_config', 'setup'],
'ext_package': 'jnius',
'package_data': {
'jnius': ['src/org/jnius/*'],
},
'long_description_content_type': 'text/markdown',
'long_description': README,
'author': 'Kivy Team and other contributors',
'author_email': 'kivy-dev@googlegroups.com',
'short_description': "A Python module to access Java classes as Python classes using JNI.",
'keywords': 'Java JNI Android',
'classifiers': [
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Operating System :: Android',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries :: Application Frameworks'
]
}