Skip to content

Commit

Permalink
Switch to GitHub actions (#544)
Browse files Browse the repository at this point in the history
* Add ci_osx action

* Add ci_ubuntu action

* Remove Travis and AppVeyor
Both are now replaced with Github Actions. Although Travis and AppVeyor 
were working fine, the main reason to do this is because with Github 
Actions the continuous integration can be run without creating a Pull 
Request.

* Add plyer_deploy action

* Add GitHub Actions Badges to README

* Add ci_windows action

* Add ci_ubuntu.sh

* Add ci_osx.sh

* Add ci_windows.ps1

* Remove Style from ci_osx and ci_windows
Style is needed only once (in this case, in ci_ubuntu)

* Remove `twine` from `devrequirements`
`twine` is used in the `plyer_deploy` action and is installed using `deployment_dependencies`, located in `ci_ubuntu.sh`

* Add style_dependencies in ci_ubuntu.sh
This because `style` will run in a separate job, so just the needed dependencies are installed in there.

* Create a job for `style` only
Considering that `style` only needs to run using a single Python version and uses less dependencies, having it as a separate job should finish faster and let the user know quicker if any linter warning appears.

* Rename `build` job to `tests`

* Check style with flake8

* Create artifacts in plyer_deploy

* Create a draft release in plyer_deploy

* Add upload coverage step

* Build the package before creating the artifacts

* Generalize the Python version used in plyer_deploy

* Run tests job with Python 3.x instead of using matrix
In order to avoid the `Upload Coverage` step to run in three different Python version, the `tests` job now runs with Python 3.x, just like in Kivy. To keep consistency, this change is also applied in `ci_osx` and `ci_windows`.
  • Loading branch information
Francisco authored Mar 26, 2020
1 parent 63b8192 commit bdaaa87
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 90 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci_osx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Continuous Integration with OSX

on: [push, pull_request]

jobs:
tests:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x

- name: Install dependencies
run: |
source ci/ci_osx.sh
dependencies
- name: Tests
run: |
source ci/ci_osx.sh
tests
55 changes: 55 additions & 0 deletions .github/workflows/ci_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Continuous Integration with Ubuntu

on: [push, pull_request]

jobs:

style:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x

- name: Install Dependencies
run: |
source ci/ci_ubuntu.sh
style_dependencies
- name: Style
run: |
source ci/ci_ubuntu.sh
style
tests:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x

- name: Install dependencies
run: |
source ci/ci_ubuntu.sh
dependencies
- name: Tests
run: |
source ci/ci_ubuntu.sh
tests
- name: Upload Coverage
if: github.event_name == 'push' && github.ref == 'refs/head/master'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
source ci/ci_ubuntu.sh
upload_coverage
25 changes: 25 additions & 0 deletions .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Continuous Integration with Windows

on: [push, pull_request]

jobs:
tests:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x

- name: Install dependencies
run: |
. .\ci\ci_windows.ps1
Dependencies
- name: Tests
run: |
. .\ci\ci_windows.ps1
Tests
51 changes: 51 additions & 0 deletions .github/workflows/plyer_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy to PyPI

on:
create

jobs:
deploy:
if: startsWith(github.ref, 'refs/tags/')

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'

- name: Install dependencies
run: |
source ci/ci_ubuntu.sh
deployment_dependencies
- name: Build Package
run: |
source ci/ci_ubuntu.sh
build
- name: Create artifacts
uses: actions/upload-artifact@v1
with:
name: plyer_artifact
path: dist

- name: Upload to GitHub Releases
uses: softprops/[email protected]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_RELEASE }}

with:
files: dist/*
draft: true

- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

run: |
source ci/ci_ubuntu.sh
deploy
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Plyer is a platform-independent api to use features commonly found on various
platforms, notably mobile ones, in Python.

[![coverage](https://coveralls.io/repos/kivy/plyer/badge.svg?branch=master)](https://coveralls.io/r/kivy/plyer?branch=master)
[![travis](https://travis-ci.org/kivy/plyer.svg?branch=master)](https://travis-ci.org/kivy/plyer)
[![appveyor](https://ci.appveyor.com/api/projects/status/k1bwhdie0tfmdq96?svg=true)](https://ci.appveyor.com/project/KivyOrg/plyer)
[![Backers on Open Collective](https://opencollective.com/kivy/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/kivy/sponsors/badge.svg)](#sponsors)
![Continuous Integration with Ubuntu](https://github.com/kivy/plyer/workflows/Continuous%20Integration%20with%20Ubuntu/badge.svg)
![Continuous Integration with OSX](https://github.com/kivy/plyer/workflows/Continuous%20Integration%20with%20OSX/badge.svg)
![Continuous Integration with Windows](https://github.com/kivy/plyer/workflows/Continuous%20Integration%20with%20Windows/badge.svg)
![Deploy to PyPI](https://github.com/kivy/plyer/workflows/Deploy%20to%20PyPI/badge.svg)


## How
Expand Down Expand Up @@ -117,5 +119,3 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
<a href="https://opencollective.com/kivy/sponsor/7/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/kivy/sponsor/8/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/kivy/sponsor/9/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/9/avatar.svg"></a>


18 changes: 0 additions & 18 deletions appveyor.yml

This file was deleted.

21 changes: 21 additions & 0 deletions ci/ci_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

dependencies()
{
python -m pip install --upgrade pip

pip install --upgrade -r devrequirements.txt
pip install https://github.com/kivy/pyobjus/zipball/master
}

tests()
{
pip install --editable .
coverage run \
--source ./plyer \
-m unittest discover \
--start-directory ./plyer/tests \
--top-level-directory . \
--failfast
coverage report -m
}
80 changes: 80 additions & 0 deletions ci/ci_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/sh
set -ex

dependencies()
{
# install default packages
sudo apt-get update && \
sudo apt-get -y --force-yes install \
build-essential \
openjdk-8-jdk \
lshw \
wget \
git \
&& apt-get -y autoremove \
&& apt-get -y clean

# generate user folder locations (Pictures, Downloads, ...)
xdg-user-dirs-update

# install PIP
python -V
python -m pip install --upgrade pip

# install dev packages
python -m pip install \
--upgrade \
--requirement devrequirements.txt
python -m pip install pyjnius

python -m pip install .
}

deployment_dependencies()
{
python -m pip install --upgrade pip

pip install setuptools wheel twine
}

style_dependencies()
{
python -m pip install --upgrade pip

pip install flake8
}

style()
{
python -m flake8 . --show-source
}

tests()
{
# tests and coverage for plyer package
python -m coverage run \
--source plyer \
-m unittest discover \
--start-directory plyer/tests \
--top-level-directory . \
--failfast

coverage report -m
}

upload_coverage()
{
python -m coveralls
}

build()
{
python setup.py sdist
python setup.py bdist_wheel --universal
}

deploy()
{
# deploy to PyPI
python -m twine upload dist/*
}
19 changes: 19 additions & 0 deletions ci/ci_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function Dependencies {
python -m pip install --requirement devrequirements.txt
python -m pip install .
echo Plyer version is
python -c "import plyer;print(plyer.__version__)"
}

function Tests {
$current_directory = (pwd).Path

python -m coverage run `
--source "$current_directory\plyer" `
-m unittest discover `
--start-directory "$current_directory\plyer\tests" `
--top-level-directory "$current_directory" `
--failfast

python -m coverage report -m
}
3 changes: 0 additions & 3 deletions devrequirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
mock
pycodestyle
pylint
coverage
coveralls
cython
twine

0 comments on commit bdaaa87

Please sign in to comment.