Skip to content

Commit 700fe80

Browse files
authored
Merge pull request #2421 from bagerard/test_github_actions2
Migrate to GitHub actions
2 parents 6b52312 + 49e33b9 commit 700fe80

File tree

10 files changed

+290
-111
lines changed

10 files changed

+290
-111
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: MongoengineCI
2+
on:
3+
# All PR
4+
pull_request:
5+
# master branch merge
6+
push:
7+
branches:
8+
- master
9+
# release tags
10+
create:
11+
tags:
12+
- 'v[0-9]+\.[0-9]+\.[0-9]+*'
13+
env:
14+
MONGODB_3_4: 3.4.19
15+
MONGODB_3_6: 3.6.13
16+
MONGODB_4_0: 4.0.13
17+
18+
PYMONGO_3_4: 3.4
19+
PYMONGO_3_6: 3.6
20+
PYMONGO_3_9: 3.9
21+
PYMONGO_3_11: 3.11
22+
23+
MAIN_PYTHON_VERSION: 3.7
24+
25+
jobs:
26+
linting:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Set up Python 3.7
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: 3.7
34+
- run: bash .github/workflows/install_ci_python_dep.sh
35+
- run: pre-commit run -a
36+
37+
test:
38+
# Test suite run against recent python versions
39+
# and against a few combination of MongoDB and pymongo
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
45+
MONGODB: [$MONGODB_4_0]
46+
PYMONGO: [$PYMONGO_3_11]
47+
include:
48+
- python-version: 3.7
49+
MONGODB: $MONGODB_3_4
50+
PYMONGO: $PYMONGO_3_6
51+
- python-version: 3.7
52+
MONGODB: $MONGODB_3_6
53+
PYMONGO: $PYMONGO_3_9
54+
- python-version: 3.7
55+
MONGODB: $MONGODB_3_6
56+
PYMONGO: $PYMONGO_3_11
57+
steps:
58+
- uses: actions/checkout@v2
59+
- name: Set up Python ${{ matrix.python-version }}
60+
uses: actions/setup-python@v2
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
- name: install mongo and ci dependencies
64+
run: |
65+
bash .github/workflows/install_mongo.sh ${{ matrix.MONGODB }}
66+
bash .github/workflows/install_ci_python_dep.sh
67+
bash .github/workflows/start_mongo.sh ${{ matrix.MONGODB }}
68+
- name: tox dry-run (to pre-install venv)
69+
run: tox -e $(echo py${{ matrix.python-version }}-mg${{ matrix.PYMONGO }} | tr -d . | sed -e 's/pypypy/pypy/') -- -a "-k=test_ci_placeholder"
70+
- name: Run test suite
71+
run: tox -e $(echo py${{ matrix.python-version }}-mg${{ matrix.PYMONGO }} | tr -d . | sed -e 's/pypypy/pypy/') -- -a "--cov=mongoengine"
72+
- name: Send coverage to Coveralls
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
if: ${{ matrix.python-version == env.MAIN_PYTHON_VERSION }}
76+
run: coveralls
77+
78+
build_doc_dryrun:
79+
# ensures that readthedocs can be built continuously
80+
# to avoid that it breaks when new releases are being created
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v2
84+
- name: Set up Python ${{ matrix.python-version }}
85+
uses: actions/setup-python@v2
86+
with:
87+
python-version: 3.7
88+
- name: install python dep
89+
run: |
90+
pip install -e .
91+
pip install -r docs/requirements.txt
92+
- name: build doc
93+
run: |
94+
cd docs
95+
make html-readthedocs
96+
97+
irc_notification:
98+
runs-on: ubuntu-latest
99+
needs: [linting, test]
100+
steps:
101+
- uses: rectalogic/notify-irc@v1
102+
if: success()
103+
with:
104+
channel: "irc.freenode.org#mongoengine"
105+
nickname: github-notifier
106+
message: |
107+
Build ${{ job.status }} - ${{ github.actor }} ${{ github.event_name }} ${{ github.event.ref }}
108+
109+
build-n-publish-dummy:
110+
runs-on: ubuntu-latest
111+
needs: [linting, test]
112+
steps:
113+
- uses: actions/checkout@master
114+
- name: Set up Python 3.7
115+
uses: actions/setup-python@v1
116+
with:
117+
python-version: 3.7
118+
- name: build dummy wheel for test-pypi
119+
run: |
120+
pip install wheel
121+
python setup.py egg_info -b ".dev`date '+%Y%m%d%H%M%S'`" build sdist bdist_wheel
122+
# - name: publish test-pypi
123+
# # Although working and recommended, test-pypi has a limit
124+
# # in the size of projects so it's better to avoid publishing
125+
# # until there is a way to garbage collect these dummy releases
126+
# if: github.event_name != 'pull_request'
127+
# uses: pypa/gh-action-pypi-publish@master
128+
# with:
129+
# password: ${{ secrets.test_pypi_token }}
130+
# repository_url: https://test.pypi.org/legacy/
131+
132+
build-n-publish:
133+
runs-on: ubuntu-latest
134+
needs: [linting, test]
135+
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
136+
steps:
137+
- uses: actions/checkout@master
138+
- name: Set up Python 3.7
139+
uses: actions/setup-python@v1
140+
with:
141+
python-version: 3.7
142+
# todo separate build from publish
143+
# https://stackoverflow.com/questions/59349905/which-properties-does-github-event-in-a-github-workflow-have
144+
- name: build dummy wheel for test-pypi
145+
run: |
146+
pip install wheel
147+
python setup.py sdist bdist_wheel
148+
- name: publish pypi
149+
uses: pypa/gh-action-pypi-publish@master
150+
with:
151+
password: ${{ secrets.pypi_token }}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
pip install --upgrade pip
3+
pip install coveralls
4+
pip install pre-commit
5+
pip install tox

.github/workflows/install_mongo.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
MONGODB=$1
4+
5+
mongo_build=mongodb-linux-x86_64-${MONGODB}
6+
wget http://fastdl.mongodb.org/linux/$mongo_build.tgz
7+
tar xzf $mongo_build.tgz
8+
${PWD}/$mongo_build/bin/mongod --version

.github/workflows/start_mongo.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
MONGODB=$1
4+
5+
mongodb_dir=${PWD}/mongodb-linux-x86_64-${MONGODB}
6+
mkdir $mongodb_dir/data
7+
$mongodb_dir/bin/mongod --dbpath $mongodb_dir/data --logpath $mongodb_dir/mongodb.log --fork
8+
mongo --eval 'db.version();' # Make sure mongo is awake

.travis.yml

Lines changed: 0 additions & 107 deletions
This file was deleted.

.travis_.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
## For full coverage, we'd have to test all supported Python, MongoDB, and
2+
## PyMongo combinations. However, that would result in an overly long build
3+
## with a very large number of jobs, hence we only test a subset of all the
4+
## combinations.
5+
## * Python3.7, MongoDB v3.4 & the latest PyMongo v3.x is currently the "main" setup,
6+
## Other combinations are tested. See below for the details or check the travis jobs
7+
#
8+
## We should periodically check MongoDB Server versions supported by MongoDB
9+
## Inc., add newly released versions to the test matrix, and remove versions
10+
## which have reached their End of Life. See:
11+
## 1. https://www.mongodb.com/support-policy.
12+
## 2. https://docs.mongodb.com/ecosystem/drivers/driver-compatibility-reference/#python-driver-compatibility
13+
##
14+
## Reminder: Update README.rst if you change MongoDB versions we test.
15+
#
16+
#language: python
17+
#dist: xenial
18+
#python:
19+
# - 3.6
20+
# - 3.7
21+
# - 3.8
22+
# - 3.9
23+
# - pypy3
24+
#
25+
#env:
26+
# global:
27+
# - MONGODB_3_4=3.4.19
28+
# - MONGODB_3_6=3.6.13
29+
# - MONGODB_4_0=4.0.13
30+
#
31+
# - PYMONGO_3_4=3.4
32+
# - PYMONGO_3_6=3.6
33+
# - PYMONGO_3_9=3.9
34+
# - PYMONGO_3_11=3.11
35+
#
36+
# - MAIN_PYTHON_VERSION=3.7
37+
# matrix:
38+
# - MONGODB=${MONGODB_3_4} PYMONGO=${PYMONGO_3_11}
39+
#
40+
#matrix:
41+
# # Finish the build as soon as one job fails
42+
# fast_finish: true
43+
#
44+
# include:
45+
# - python: 3.7
46+
# env: MONGODB=${MONGODB_3_6} PYMONGO=${PYMONGO_3_6}
47+
# - python: 3.7
48+
# env: MONGODB=${MONGODB_3_6} PYMONGO=${PYMONGO_3_9}
49+
# - python: 3.7
50+
# env: MONGODB=${MONGODB_3_6} PYMONGO=${PYMONGO_3_11}
51+
# - python: 3.8
52+
# env: MONGODB=${MONGODB_4_0} PYMONGO=${PYMONGO_3_11}
53+
#
54+
#install:
55+
# # Install Mongo
56+
# - wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz
57+
# - tar xzf mongodb-linux-x86_64-${MONGODB}.tgz
58+
# - ${PWD}/mongodb-linux-x86_64-${MONGODB}/bin/mongod --version
59+
# # Install Python dependencies.
60+
# - pip install --upgrade pip
61+
# - pip install coveralls
62+
# - pip install pre-commit
63+
# - pip install tox
64+
# # tox dryrun to setup the tox venv (we run a mock test).
65+
# - tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- -a "-k=test_ci_placeholder"
66+
#
67+
#before_script:
68+
# - mkdir ${PWD}/mongodb-linux-x86_64-${MONGODB}/data
69+
# - ${PWD}/mongodb-linux-x86_64-${MONGODB}/bin/mongod --dbpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/data --logpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/mongodb.log --fork
70+
# # Run pre-commit hooks (black, flake8, etc) on entire codebase
71+
# - if [[ $TRAVIS_PYTHON_VERSION == $MAIN_PYTHON_VERSION ]]; then pre-commit run -a; else echo "pre-commit checks only runs on py37"; fi
72+
# - mongo --eval 'db.version();' # Make sure mongo is awake
73+
#
74+
#script:
75+
# - tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- -a "--cov=mongoengine"
76+
#
77+
#after_success:
78+
# - if [[ $TRAVIS_PYTHON_VERSION == $MAIN_PYTHON_VERSION ]]; then coveralls --verbose; else echo "coveralls only sent for py37"; fi
79+
#
80+
#notifications:
81+
# irc: irc.freenode.org#mongoengine
82+
#
83+
## Only run builds on the master branch and GitHub releases (tagged as vX.Y.Z)
84+
#branches:
85+
# # Only run builds on the master branch and GitHub releases (tagged as vX.Y.Z)
86+
# only:
87+
# - master
88+
# - /^v.*$/
89+
#
90+
## Whenever a new release is created via GitHub, publish it on PyPI.
91+
#deploy:
92+
# provider: pypi
93+
# user: the_drow
94+
# password:
95+
# secure: QMyatmWBnC6ZN3XLW2+fTBDU4LQcp1m/LjR2/0uamyeUzWKdlOoh/Wx5elOgLwt/8N9ppdPeG83ose1jOz69l5G0MUMjv8n/RIcMFSpCT59tGYqn3kh55b0cIZXFT9ar+5cxlif6a5rS72IHm5li7QQyxexJIII6Uxp0kpvUmek=
96+
#
97+
# # Create a source distribution and a pure python wheel for faster installs.
98+
# distributions: "sdist bdist_wheel"
99+
#
100+
# # Only deploy on tagged commits (aka GitHub releases) and only for the parent
101+
# # repo's builds running Python v3.7 along with PyMongo v3.x and MongoDB v3.4.
102+
# # We run Travis against many different Python, PyMongo, and MongoDB versions
103+
# # and we don't want the deploy to occur multiple times).
104+
# on:
105+
# tags: true
106+
# repo: MongoEngine/mongoengine
107+
# condition: ($PYMONGO = ${PYMONGO_3_11}) && ($MONGODB = ${MONGODB_3_4})
108+
# python: 3.7

0 commit comments

Comments
 (0)