Skip to content

Commit 268e986

Browse files
authored
migrate travis to gh actions (#1440)
1 parent d889394 commit 268e986

File tree

4 files changed

+228
-37
lines changed

4 files changed

+228
-37
lines changed

.github/workflows/main.yml

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# GitHub actions for Autobahn|Python CI/CD
2+
# https://github.com/crossbario/autobahn-python/actions
3+
#
4+
# See also:
5+
#
6+
# * https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
7+
# * https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml
8+
#
9+
name: main
10+
11+
on:
12+
push:
13+
branches:
14+
- master
15+
pull_request:
16+
branches:
17+
- master
18+
19+
jobs:
20+
check:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Install OS package dependencies
26+
run: |
27+
sudo apt update
28+
sudo apt install libenchant-dev libbz2-dev libsnappy-dev libunwind-dev
29+
30+
- name: Set up Python 3.8
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: '3.8'
34+
architecture: 'x64'
35+
36+
- name: Install Python package dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -r requirements-dev.txt
40+
41+
- name: Run Flake8
42+
run: tox -c tox.ini -e flake8
43+
44+
# since we use --parallel-mode to coverage inside Tox we use
45+
# "coverage combine" so the filename is always ".coverage"
46+
- name: Run Coverage
47+
run: |
48+
tox -c tox.ini -e coverage
49+
coverage combine && codecov
50+
51+
test:
52+
env:
53+
CB_FULLTESTS: 1
54+
55+
# Test on Ubuntu, MacOS, Windows using CPython 3.6-3.9, PyPy 3.6-3.7
56+
runs-on: ${{ matrix.os }}
57+
strategy:
58+
matrix:
59+
os: [ubuntu-latest]
60+
# os: [ubuntu-latest, macos-latest, windows-latest]
61+
62+
# https://github.com/actions/setup-python#specifying-a-pypy-version
63+
python-version: ['3.6', '3.7', '3.8', '3.9', 'pypy-3.6', 'pypy-3.7']
64+
65+
# https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
66+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error
67+
continue-on-error: false
68+
69+
steps:
70+
# Checkout sources
71+
- uses: actions/checkout@v2
72+
73+
# Install OS packages, as we install Python packages from source:
74+
# libenchant-dev: needed for pyenchant, needed for sphinx-spellcheck
75+
# libbz2-dev, libsnappy-dev: needed for compression
76+
# libunwind-dev: needed for vmprof
77+
- name: Install OS package dependencies
78+
run: |
79+
sudo apt update
80+
sudo apt install build-essential libssl-dev libffi-dev libunwind-dev \
81+
libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
82+
libsnappy-dev
83+
84+
# Use this Python
85+
# https://github.com/actions/setup-python/blob/main/README.md
86+
- name: Set up Python ${{ matrix.python-version }}
87+
uses: actions/setup-python@v2
88+
with:
89+
python-version: ${{ matrix.python-version }}
90+
91+
- name: Install Python package dependencies
92+
run: |
93+
python -m pip install -U pip
94+
pip install -U -r requirements-dev.txt
95+
96+
- name: Install this package
97+
run: |
98+
pip install .
99+
100+
- name: Run unit tests (PyTest)
101+
run: |
102+
tox -c tox.ini
103+
104+
docs:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v2
108+
109+
- name: Install OS package dependencies
110+
run: |
111+
sudo apt update
112+
sudo apt install libenchant-dev libbz2-dev libsnappy-dev libunwind-dev
113+
114+
- name: Set up Python 3.8
115+
uses: actions/setup-python@v2
116+
with:
117+
python-version: '3.8'
118+
architecture: 'x64'
119+
120+
- name: Install Python package dependencies
121+
run: |
122+
python -m pip install --upgrade pip
123+
pip install -r requirements-dev.txt
124+
125+
- name: Run Sphinx
126+
run: tox -c tox.ini -e sphinx
127+
128+
deploy:
129+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
130+
131+
# https://github.blog/changelog/2020-12-15-github-actions-environments-environment-protection-rules-and-environment-secrets-beta/
132+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/environments
133+
environment: deploy_aws
134+
135+
env:
136+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
137+
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
138+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
139+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
140+
WAMP_PRIVATE_KEY: ${{ secrets.WAMP_PRIVATE_KEY }}
141+
142+
runs-on: ubuntu-latest
143+
steps:
144+
- uses: actions/checkout@v2
145+
146+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
147+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
148+
- name: Set environment
149+
run: |
150+
echo "${HOME}/.local/bin" >> $GITHUB_PATH
151+
echo BUILD_DATE=`date -u +"%Y-%m-%d"` >> $GITHUB_ENV
152+
echo AUTOBAHN_VCS_REF=`git rev-parse --short ${GITHUB_SHA}` >> $GITHUB_ENV
153+
echo AUTOBAHN_BUILD_ID=$(date --utc +%Y%m%d)-$(git rev-parse --short ${GITHUB_SHA}) >> $GITHUB_ENV
154+
echo AUTOBAHN_VERSION=$(grep -E '^(__version__)' ./zlmdb/_version.py | cut -d ' ' -f3 | sed -e 's|[u"'\'']||g') >> $GITHUB_ENV
155+
156+
# - name: Set environment - 2
157+
# run: |
158+
# echo AUTOBAHN_VCS_REF=`git --git-dir="./.git" rev-list -n 1 v${AUTOBAHN_VERSION} --abbrev-commit` >> $GITHUB_ENV
159+
160+
- name: Install OS package dependencies
161+
run: |
162+
sudo apt update
163+
sudo apt install build-essential libssl-dev libffi-dev libunwind-dev \
164+
libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
165+
libsnappy-dev
166+
167+
- name: Set up Python 3.x
168+
uses: actions/setup-python@v2
169+
with:
170+
python-version: '3.x'
171+
architecture: 'x64'
172+
173+
- name: Install Python package dependencies
174+
run: |
175+
python -m pip install --upgrade pip
176+
pip install -r requirements-dev.txt
177+
178+
- name: Deploy (build, package and upload)
179+
run: |
180+
./deploy.sh

.travis-deploy.sh renamed to deploy.sh

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,17 @@
22

33
set +o verbose -o errexit
44

5-
# AUTOBAHN_VERSION : must be set in travis.yml!
6-
export AWS_DEFAULT_REGION=eu-central-1
7-
export AWS_S3_BUCKET_NAME=crossbarbuilder
8-
# AWS_ACCESS_KEY_ID : must be set in Travis CI build context!
9-
# AWS_SECRET_ACCESS_KEY : must be set in Travis CI build context!
10-
# WAMP_PRIVATE_KEY : must be set in Travis CI build context!
5+
# AWS_DEFAULT_REGION : must be set in CI build context!
6+
# AWS_S3_BUCKET_NAME : must be set in CI build context!
7+
# AWS_ACCESS_KEY_ID : must be set in CI build context!
8+
# AWS_SECRET_ACCESS_KEY : must be set in CI build context!
9+
# WAMP_PRIVATE_KEY : must be set in CI build context!
1110

12-
# TRAVIS_BRANCH, TRAVIS_PULL_REQUEST, TRAVIS_TAG
11+
echo 'AWS env vars (should be 4):'
12+
env | grep AWS_ | wc -l
1313

14-
# PR => don't deploy and exit
15-
if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
16-
echo '[1] deploy script called for PR - exiting ..';
17-
exit 0;
18-
19-
# direct push to master => deploy
20-
elif [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
21-
echo '[2] deploy script called for direct push to master: continuing to deploy!';
22-
23-
# tagged release => deploy
24-
elif [ -n "$TRAVIS_TAG" ]; then
25-
echo '[3] deploy script called for tagged release: continuing to deploy!';
26-
27-
# outside travis? => deploy
28-
else
29-
echo '[?] deploy script called outside Travis? continuing to deploy!';
30-
31-
fi
32-
33-
# only show number of env vars .. should be 4 on master branch!
34-
# https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
35-
# Travis CI makes encrypted variables and data available only to pull requests coming from the same repository.
36-
echo 'aws env vars (should be 4 - but only on master branch!):'
37-
env | grep AWS | wc -l
14+
echo 'WAMP_PRIVATE_KEY env var (should be 1):'
15+
env | grep WAMP_PRIVATE_KEY | wc -l
3816

3917
# set up awscli package
4018
echo 'installing aws tools ..'

requirements-dev.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
pip>=9.0.1
2+
bumpversion>=0.5.3
3+
wheel>=0.30.0
4+
watchdog>=0.8.3
5+
flake8>=3.5.0
6+
tox>=2.9.1
7+
tox-gh-actions>=2.2.0
8+
codecov>=2.0.15
9+
sphinx>=1.7.1
10+
twine>=1.10.0
11+
pytest>=3.4.2
12+
pytest-runner>=2.11.1
13+
humanize>=0.5.1
14+
backports.tempfile>=1.0
15+
# https://github.com/google/yapf/issues/712
16+
yapf==0.29.0
17+
pylint>=1.9.2
18+
pyyaml>=4.2b4
19+
mypy>=0.610; python_version >= '3.4' and platform_python_implementation != 'PyPy'
20+
twisted>=18.7.0

tox.ini

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,24 @@ envlist =
1111
py39-{tw189,tw1910,twtrunk,asyncio}
1212

1313
# PyPy
14-
pypy3-{tw189,tw1910,twtrunk,asyncio}
14+
pypy37-{tw189,tw1910,twtrunk,asyncio}
15+
16+
17+
# MAP: GitHub Actions Python Name => Tox Env Name (for Python)
18+
#
19+
# when called without a specific environment ("-e"), detect the
20+
# python version / get from GH action, and map to tox env
21+
#
22+
# https://github.com/ymyzk/tox-gh-actions
23+
#
24+
[gh-actions]
25+
python =
26+
3.6: py36
27+
3.7: py37
28+
3.8: py38
29+
3.9: py39
30+
pypy-3.6: pypy36
31+
pypy-3.7: pypy37
1532

1633

1734
[testenv]
@@ -30,10 +47,7 @@ deps =
3047
{tw189,tw1910,twtrunk}: pytest-twisted
3148

3249
; asyncio dependencies
33-
py36-asyncio: pytest_asyncio
34-
py37-asyncio: pytest_asyncio
35-
py38-asyncio: pytest_asyncio
36-
pypy3-asyncio: pytest_asyncio
50+
asyncio: pytest_asyncio
3751

3852
extras =
3953
encryption
@@ -87,7 +101,6 @@ setenv =
87101

88102

89103
[testenv:flake8]
90-
basepython = python3
91104
skip_install = True
92105
deps =
93106
flake8

0 commit comments

Comments
 (0)