Travis CI -> GitHub Actions (#377)

* Add tests config

* Try run tests on multiple versions

* Add jobs for Python 3.5, 3.6, 3.7

* Add Python 3.4

* Add Python 2.7 job

* Add PyPy and PyPy3 jobs

* Add tests coverage job

* Try to add manual trigger for tests

* Fix coveralls token passing

* Change coverage job name

* Update env sections

* Update run and env sections

* Add COVERALLS_GIT_BRANCH

* Try set branch name

* Set branch name and token

* Update tox.ini to pass env variables

* Update tox.ini

* Re-arrange run actions

* Refactor tests workflow

* Add linters workflow

* Move linters to tests workflow

* Move branch name

* Create common linters job

* Rename tests and linters workflow

* Add pull_request event for tests and linters jobs

* Add publishing workflow

* Try quote asteriks

* Update publishing workflow to publish to test server

* Change publishing workflow name

* Add linux x64 wheels publishing job

* Bump version

* Add publishing wheels on mac and windows

* Fix windows builds

* Refactor to two stages build

* Rename build wheels job

* Add experimental aarch64 builds

* Rename custom archs job

* Add tests & linters to publishing job

* Bump version

* Add docs publishing

* Rename aarch64 job

* Rename aarch64 job

* Revert version change

* Update coveralls job

* Experiment with coveralls

* Experiment with branch name

* Update tox.ini to pass github token

* Update tox.ini to pass all GH vars

* Remove coveralls branch

* Remove travis ci config
This commit is contained in:
Roman Mogylatov 2021-01-26 21:11:27 -05:00 committed by GitHub
parent dfedead4f0
commit 717f7a0497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 188 additions and 138 deletions

127
.github/workflows/publishing.yml vendored Normal file
View File

@ -0,0 +1,127 @@
name: Publishing
on:
push:
tags:
- '*'
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install tox
- run: tox
env:
TOXENV: 3.9
linters:
name: Run linters
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: [flake8, pydocstyle, mypy, pylint]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install tox
- run: tox
env:
TOXENV: ${{ matrix.toxenv }}
build-sdist:
name: Build source tarball
needs: [tests, linters]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: python setup.py sdist
- uses: actions/upload-artifact@v2
with:
path: ./dist/*
build-wheels:
name: Build wheels
needs: [tests, linters]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install cibuildwheel==1.8.0
- name: Install Visual C++ for Python 2.7 on Windows
if: runner.os == 'Windows'
run: |
choco install vcpython27 -f -y
- run: cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
build-wheels-linux-aarch64:
name: Build wheels (ubuntu-latest-aarch64)
needs: [tests, linters]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install cibuildwheel==1.8.0
- run: cibuildwheel --archs aarch64 --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
publish:
name: Publish on PyPI
needs: [build-sdist, build-wheels, build-wheels-linux-aarch64]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
publish-docs:
name: Publish docs
needs: [publish]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install -r requirements-doc.txt
- run: pip install awscli
- run: pip install -e .
- run: (cd docs && make clean html)
- run: |
aws s3 sync docs/_build/html s3://python-dependency-injector-docs --delete
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --path "/*" > /dev/null
echo "Cache invalidation triggered"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}

55
.github/workflows/tests-and-linters.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: Tests and linters
on: [push, pull_request, workflow_dispatch]
jobs:
test-on-different-versions:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, pypy2, pypy3]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: pip install tox
- run: tox
env:
TOXENV: ${{ matrix.python-version }}
test-coverage:
name: Run tests with coverage
runs-on: ubuntu-latest
env:
DEPENDENCY_INJECTOR_DEBUG_MODE: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install tox cython
- run: make cythonize
- run: tox
env:
TOXENV: coveralls
linters:
name: Run linters
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: [flake8, pydocstyle, mypy, pylint]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install tox
- run: tox
env:
TOXENV: ${{ matrix.toxenv }}

View File

@ -1,132 +0,0 @@
os: linux
dist: xenial
language: python
jobs:
include:
- python: 3.9
env: TOXENV=coveralls DEPENDENCY_INJECTOR_DEBUG_MODE=1
install:
- pip install tox
- pip install cython
- make cythonize
script: tox
- python: 3.6
env: TOXENV=pylint
install: pip install tox
script: tox
- python: 3.6
env: TOXENV=flake8
install: pip install tox
script: tox
- python: 3.6
env: TOXENV=pydocstyle
install: pip install tox
script: tox
- python: 3.6
env: TOXENV=mypy
install: pip install tox
script: tox
- python: 2.7
env: TOXENV=py27
install: pip install tox
script: tox
- python: 3.4
env: TOXENV=py34
install: pip install tox
script: tox
- python: 3.5
env: TOXENV=py35
install: pip install tox
script: tox
- python: 3.6
env: TOXENV=py36
install: pip install tox
script: tox
- python: 3.7
env: TOXENV=py37
install: pip install tox
script: tox
- python: 3.8
env: TOXENV=py38
install: pip install tox
script: tox
- python: 3.9
env: TOXENV=py39
install: pip install tox
script: tox
- python: pypy
env: TOXENV=pypy
install: pip install tox
script: tox
- python: pypy3
env: TOXENV=pypy3
install: pip install tox
script: tox
- python: 3.8
if: tag IS present
env: TWINE_USERNAME=__token__
install: pip install pip --upgrade
script: python setup.py sdist
after_success:
- python3 -m pip install twine
- python3 -m twine upload dist/*
- services: docker
if: tag IS present
env: TWINE_USERNAME=__token__
install: python3 -m pip install cibuildwheel==1.6.3
script: python3 -m cibuildwheel --output-dir wheelhouse
after_success:
- python3 -m pip install --upgrade --upgrade-strategy eager twine
- python3 -m twine upload wheelhouse/*.whl
- services: docker
arch: arm64
if: tag IS present
env: TWINE_USERNAME=__token__
install: python3 -m pip install cibuildwheel==1.6.3
script: python3 -m cibuildwheel --output-dir wheelhouse
after_success:
- python3 -m pip install --upgrade --upgrade-strategy eager twine
- python3 -m twine upload wheelhouse/*.whl
- os: osx
if: tag IS present
language: shell
osx_image: xcode10.2
env: TWINE_USERNAME=__token__
install: python3 -m pip install cibuildwheel==1.6.3
script: python3 -m cibuildwheel --output-dir wheelhouse
after_success:
- python3 -m pip install --upgrade --upgrade-strategy eager twine
- python3 -m twine upload wheelhouse/*.whl
- os: windows
if: tag IS present
language: shell
env: TWINE_USERNAME=__token__
before_install:
- choco install python --version 3.8.6
- export PATH="/c/Python38:/c/Python38/Scripts:$PATH"
- ln -s /c/Python38/python.exe /c/Python38/python3.exe
install:
- python3 -m pip install certifi cibuildwheel==1.6.3
- export SSL_CERT_FILE=`python3 -c "import certifi;print(certifi.where())"`
- echo $SSL_CERT_FILE
script: python -m cibuildwheel --output-dir wheelhouse
after_success:
- python -m pip install --upgrade --upgrade-strategy eager twine
- python -m twine upload wheelhouse/*.whl
- python: 3.8
if: branch = master
install:
- pip install -r requirements-doc.txt
- pip install awscli
- pip install -e .
script: (cd docs && make clean html)
after_success:
- aws s3 sync docs/_build/html s3://python-dependency-injector-docs --delete
- aws cloudfront create-invalidation --distribution-id ${AWS_CLOUDFRONT_DISTRIBUTION_ID} --path "/*" > /dev/null
- echo "Cache invalidation triggered"
echo "Result: OK"
- python -m twine upload wheelhouse/*.whl
notifications:
slack:
rooms:
secure: CdWDgKnfYW7vvvoH3nS3yg3TcNZiYLRUyEp6ukQ4rQiiuR4+ltuvyGyFJWgP8r7VVJ9yHkB0jebCKWLUMsAEt1my33B6eMDEVefovpkdh2eJjGswmm80brt0EJULpgwPOtB1U47Mwca8L5jDW4KSv9RypUFRgn8eHDoWw6LKf5g=

12
tox.ini
View File

@ -1,6 +1,6 @@
[tox] [tox]
envlist= envlist=
coveralls, pylint, flake8, pydocstyle, py27, py34, py35, py36, py37, py38, pypy, pypy3 coveralls, pylint, flake8, pydocstyle, 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, pypy2, pypy3
[testenv] [testenv]
deps= deps=
@ -17,7 +17,7 @@ commands=
unit2 discover -s tests/unit -p test_*_py3*.py unit2 discover -s tests/unit -p test_*_py3*.py
[testenv:coveralls] [testenv:coveralls]
passenv=TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH DEPENDENCY_INJECTOR_DEBUG_MODE passenv = GITHUB_* COVERALLS_*
basepython=python3.9 basepython=python3.9
usedevelop=True usedevelop=True
deps= deps=
@ -31,7 +31,7 @@ commands=
coverage report --rcfile=./.coveragerc coverage report --rcfile=./.coveragerc
coveralls coveralls
[testenv:py27] [testenv:2.7]
deps= deps=
unittest2 unittest2
extras= extras=
@ -40,7 +40,7 @@ extras=
commands= commands=
unit2 discover -s tests/unit -p test_*_py2_py3.py unit2 discover -s tests/unit -p test_*_py2_py3.py
[testenv:py34] [testenv:3.4]
deps= deps=
unittest2 unittest2
extras= extras=
@ -48,7 +48,7 @@ extras=
commands= commands=
unit2 discover -s tests/unit -p test_*_py3.py unit2 discover -s tests/unit -p test_*_py3.py
[testenv:py35] [testenv:3.5]
deps= deps=
unittest2 unittest2
extras= extras=
@ -57,7 +57,7 @@ extras=
commands= commands=
unit2 discover -s tests/unit -p test_*_py3.py unit2 discover -s tests/unit -p test_*_py3.py
[testenv:pypy] [testenv:pypy2]
deps= deps=
unittest2 unittest2
extras= extras=