Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI/CD testing via github actions #670

Merged
merged 22 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# This action generates wheel files for python 2 and 3.
name: build wheels

on:
push:
branches:
- 'master'

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
# windows-latest is currently excluded, because
# (a) In 2.7 shapely causes an install error
# (b) numpy seems to not know float128 in windows, but that datatype
# is required for many test cases. Not having it will cause the
# test to error, even if the tested function is correct.
os: [ubuntu-latest, macos-latest]
# see supported versions at
# https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json
python-version: [2.7, 3.8]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2

# ----------------
# Install python and base packages
# ----------------
- name: Set up Python ${{ matrix.python-version }} on ${{ runner.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Upgrade basic packages
run: |
python -m pip install --upgrade pip setuptools wheel

# ----------------
# Set up pip cache
# ----------------
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- uses: actions/cache@v1
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- uses: actions/cache@v1
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- uses: actions/cache@v1
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

# ----------------
# Install dependencies
# ----------------
- name: Install dependencies
run: |
pip install -r requirements.txt

# ----------------
# Generate wheels
# ----------------
- name: Generate wheels
run: |
python setup.py sdist
python setup.py bdist_wheel

# ----------------
# Upload artifacts
# ----------------
- uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-py${{ matrix.python-version }}-dist
path: dist/
139 changes: 139 additions & 0 deletions .github/workflows/test_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# This is effectively identical to pr_or_push.yml, with the exceptions of:
# (1) This is only executed upon pushes to master
# (2) This executes tests for more different python versions
name: test master

on:
push:
branches:
- 'master'

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
# windows-latest is currently excluded, because
# (a) In 2.7 shapely causes an install error
# (b) numpy seems to not know float128 in windows, but that datatype
# is required for many test cases. Not having it will cause the
# test to error, even if the tested function is correct.
os: [ubuntu-latest, macos-latest]
# see supported versions at
# https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2

# ----------------
# Install python and base packages
# ----------------
- name: Set up Python ${{ matrix.python-version }} on ${{ runner.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Upgrade basic packages
run: |
python -m pip install --upgrade pip setuptools wheel

# ----------------
# Set up pip cache
# ----------------
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- uses: actions/cache@v1
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- uses: actions/cache@v1
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- uses: actions/cache@v1
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

# ----------------
# Install dependencies
# ----------------
- name: Install dependencies
run: |
pip install -r requirements.txt

- name: Install test dependencies
run: |
pip install --upgrade -r test/requirements.txt

- name: Install further test tools
run: |
pip install coverage pytest-cov flake8

# ----------------
# Install library
# ----------------
- name: Install library
run: |
pip install .

# ----------------
# Run checks and tests
# ----------------
- name: Run flake8
run: |
flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude=".svn,CVS,.bzr,.hg,.git,__pycache__,poly_point_isect.py"

- name: Run tests
run: |
python -m pytest --verbose --xdoctest-modules -s --durations=50 -Walways

# ----------------
# Code coverage reports
# ----------------
# Add 'coverage html -d out_foldername' to add html reports
- name: Generate code coverage report
run: |
coverage run --source imgaug -m pytest --verbose
coverage xml
coverage report

#- name: Upload coverage report to codacy
# uses: codacy/codacy-coverage-reporter-action@master
# with:
# project-token: ${{ secrets.CODACY_TOKEN }}
# coverage-reports: coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
# right now the env_vars argument causes a warning, see
# https://github.com/codecov/codecov-action/issues/80
#env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
145 changes: 145 additions & 0 deletions .github/workflows/test_pull_requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: test pull requests

on:
push:
branches:
- '!master'
pull_request:

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
# windows-latest is currently excluded, because
# (a) In 2.7 shapely causes an install error
# (b) numpy seems to not know float128 in windows, but that datatype
# is required for many test cases. Not having it will cause the
# test to error, even if the tested function is correct.
os: [ubuntu-latest, macos-latest]
# see supported versions at
# https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
# test only 2.7 and the latest 3.x on mac
exclude:
- os: macos-latest
python-version: 3.5
- os: macos-latest
python-version: 3.6
- os: macos-latest
python-version: 3.7
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2

# ----------------
# Install python and base packages
# ----------------
- name: Set up Python ${{ matrix.python-version }} on ${{ runner.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Upgrade basic packages
run: |
python -m pip install --upgrade pip setuptools wheel

# ----------------
# Set up pip cache
# ----------------
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- uses: actions/cache@v1
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- uses: actions/cache@v1
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- uses: actions/cache@v1
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

# ----------------
# Install dependencies
# ----------------
- name: Install dependencies
run: |
pip install -r requirements.txt

- name: Install test dependencies
run: |
pip install --upgrade -r test/requirements.txt

- name: Install further test tools
run: |
pip install coverage pytest-cov flake8

# ----------------
# Install library
# ----------------
- name: Install library
run: |
pip install .

# ----------------
# Run checks and tests
# ----------------
- name: Run flake8
run: |
flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude=".svn,CVS,.bzr,.hg,.git,__pycache__,poly_point_isect.py"

- name: Run tests
run: |
python -m pytest --verbose --xdoctest-modules -s --durations=50 -Walways

# ----------------
# Code coverage reports
# ----------------
# Add 'coverage html -d out_foldername' to add html reports
- name: Generate code coverage report
run: |
coverage run --source imgaug -m pytest --verbose
coverage xml
coverage report

#- name: Upload coverage report to codacy
# uses: codacy/codacy-coverage-reporter-action@master
# with:
# project-token: ${{ secrets.CODACY_TOKEN }}
# coverage-reports: coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
# right now the env_vars argument causes a warning, see
# https://github.com/codecov/codecov-action/issues/80
#env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ script:
- python -m pytest --verbose --xdoctest-modules --ignore="test/run_all.py" -s --durations=50 -Walways
- coverage run --source imgaug -m pytest --verbose --xdoctest-modules --ignore="test/run_all.py" -Walways


# some steps are now done in github action
after_success:
- codecov -t feeff9b2-3750-4246-befb-8cde60dc28aa
# - codecov -t feeff9b2-3750-4246-befb-8cde60dc28aa
- coverage xml
- python-codacy-coverage -r coverage.xml
- coverage report
# - coverage report
Loading