Skip to content

Commit efe8990

Browse files
authored
Merge pull request #100 from jayvdb/use-travis-template
🎨 Use travis template
2 parents 5c14d01 + 1a76e21 commit efe8990

File tree

8 files changed

+141
-28
lines changed

8 files changed

+141
-28
lines changed

.moban.dt/local-travis.yml.jj2

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% extends 'travis.yml.jj2' %}
2+
3+
{% block custom_python_versions %}
4+
python:
5+
- 3.7
6+
- 2.7
7+
{% endblock %}
8+
9+
{% block extra_jobs %}
10+
allow_failures:
11+
- stage: test
12+
{% endblock %}
13+
14+
{% block before_script %}
15+
before_script:
16+
- find templates/ -type f -name '*.jj2' -exec echo '{}' \; |{% raw %}
17+
sed -e "s/templates\//{%include \"/" -e "s/$/\" %}/" > test.file
18+
{% endraw %}
19+
{% endblock %}
20+
21+
{% block script %}
22+
- moban -c config/data.yml -t test.file -td templates .
23+
- {{ test_command }}
24+
{% endblock %}

.travis.yml

+31-12
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
11
sudo: false
2+
dist: xenial
23
language: python
3-
python:
4-
- 2.7
5-
- 3.6
64
notifications:
75
email: false
8-
install:
9-
- pip install -r test_requirements.txt -r tests/requirements.txt
6+
python:
7+
- 3.7
8+
- 2.7
9+
1010
stages:
1111
- test
12-
- moban
1312
- lint
13+
- moban
1414

1515
.disable_global: &disable_global
16+
addons: false
17+
cache: false
18+
env: {}
19+
python: false
1620
before_install: false
17-
install: true
21+
install: false
1822
before_script: false
23+
script: false
1924
after_success: false
2025
after_failure: false
26+
before_deploy: false
27+
deploy: false
2128

2229
.lint: &lint
2330
<<: *disable_global
31+
git:
32+
submodules: false
2433
python: 3.6
2534
stage: lint
26-
install: pip install flake8
27-
script: flake8
35+
script: make install_test lint
2836

2937
.moban: &moban
3038
<<: *disable_global
3139
python: 3.6
3240
stage: moban
3341
install: pip install moban>=0.0.4
34-
script:
35-
- make
42+
script: make upstreaming git-diff-check
3643

3744
jobs:
3845
include:
@@ -43,7 +50,19 @@ jobs:
4350

4451
stage: test
4552

53+
before_install:
54+
- if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then
55+
mv min_requirements.txt requirements.txt ;
56+
fi
57+
- test ! -f rnd_requirements.txt ||
58+
pip install --no-deps -r rnd_requirements.txt
59+
- test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ;
60+
- pip install -r tests/requirements.txt
61+
before_script:
62+
- find templates/ -type f -name '*.jj2' -exec echo '{}' \; |
63+
sed -e "s/templates\//{%include \"/" -e "s/$/\" %}/" > test.file
4664
script:
47-
- find templates/ -type f -name '*.jj2' -exec echo '{}' \;|sed -e "s/templates\//{%include \"/" -e "s/$/\" %}/" > test.file
4865
- moban -c config/data.yml -t test.file -td templates .
4966
- pytest
67+
after_success:
68+
codecov

Makefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
all: upstreaming
2-
31
upstreaming:
42
moban -m mobanfile
3+
4+
git-diff-check:
55
git diff
66
git diff --ignore-blank-lines | while read line; do if [ "$line" ]; then exit 1; fi; done
77

8-
lint: flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
8+
install_test:
9+
pip install -r tests/requirements.txt
10+
11+
lint:
12+
flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
13+
yamllint .
914

1015
push:
1116
git config user.email "[email protected]"

config/data.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ rsrcdir: docs/source
1616
rbuilddir: docs/_build
1717
version: 0.1.1rc3
1818
mastertocmaxdepth: 3
19+
lint_command: make install_test lint
20+
moban_command: make upstreaming git-diff-check
21+
test_command: pytest

mobanfile

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ configuration:
88
- sphinx:sphinx/templates/quickstart
99
targets:
1010
- .gitignore: gitignore.jj2
11+
- .travis.yml: local-travis.yml.jj2
1112
- LICENSE: NEW_BSD_LICENSE.jj2
1213
- README.rst: local-README.rst.jj2
1314
- output: CHANGELOG.rst

templates/travis.yml.jj2

+71-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
{% if lint_command %}
2-
{% set lint = lint_command%}
3-
{% else %}
4-
{% set lint = 'flake8' %}
1+
{% if not lint_command and lint_command != False %}
2+
{% set lint_command = 'flake8' %}
3+
{% endif %}
4+
{% if not moban_command and moban_command != False %}
5+
{% if mobanfile %}
6+
{% set moban_command = 'moban -m ' + mobanfile %}
7+
{% else %}
8+
{% set moban_command = 'moban' %}
9+
{% endif %}
510
{% endif %}
6-
711
sudo: false
8-
dist: xenial
12+
dist: {{ travis_dist | default('xenial') }}
913
language: python
1014
notifications:
1115
email: false
@@ -26,42 +30,97 @@ python:
2630
{%block extra_matrix%}
2731
{%endblock%}
2832

33+
{% block stages %}
2934
stages:
3035
- test
36+
{% if lint_command != False %}
3137
- lint
38+
{% endif %}
39+
{% if moban_command != False %}
40+
- moban
41+
{% endif %}
3242

43+
{% endblock %}
3344
.disable_global: &disable_global
45+
addons: false
46+
cache: false
47+
env: {}
48+
python: false
3449
before_install: false
35-
install: true
50+
install: false
3651
before_script: false
52+
script: false
3753
after_success: false
3854
after_failure: false
55+
before_deploy: false
56+
deploy: false
3957

58+
{% if lint_command != False %}
4059
.lint: &lint
4160
<<: *disable_global
61+
git:
62+
submodules: false
4263
python: 3.6
4364
stage: lint
65+
{% if lint_command == 'flake8' %}
4466
install: pip install flake8
45-
script: {{ lint }}
67+
{% endif %}
68+
script: {{ lint_command }}
69+
70+
{% endif %}
71+
{% if moban_command != False %}
72+
.moban: &moban
73+
<<: *disable_global
74+
python: 3.6
75+
stage: moban
76+
install: pip install moban>=0.0.4
77+
{% if moban_command.startswith('moban') and 'exit-code' not in moban_command %}
78+
script:
79+
- {{ moban_command }}
80+
{% if moban_allow_trailing_whitespace %}
81+
- git diff
82+
- git diff --ignore-blank-lines |
83+
while read line; do if [ "$line" ]; then exit 1; fi; done
84+
{% else %}
85+
- git diff --exit-code
86+
{% endif %}
87+
{% else %}
88+
script: {{ moban_command }}
89+
{% endif %}
4690

91+
{% endif %}
92+
{% block extra_dot_blocks %}
93+
{% endblock %}
94+
{% block jobs %}
4795
jobs:
4896
include:
97+
- *moban
4998
- *lint
99+
{% block extra_jobs %}
100+
{% endblock %}
101+
{% endblock %}
50102

51103
stage: test
52104

53-
script: make test
54-
105+
{% block before_install %}
55106
before_install:
56107
{% block custom_install %}
57108
{% endblock%}
58109
- if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then
59110
mv min_requirements.txt requirements.txt ;
60111
fi
61-
- test ! -f rnd_requirements.txt || pip install --no-deps -r rnd_requirements.txt
112+
- test ! -f rnd_requirements.txt ||
113+
pip install --no-deps -r rnd_requirements.txt
62114
- test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ;
63115
- pip install -r tests/requirements.txt
116+
{% endblock %}
117+
{% block before_script %}
118+
{% endblock %}
64119
script:
65-
- make test
120+
{% block script %}
121+
- {{ test_command | default('make test') }}
122+
{% endblock %}
123+
{% block end %}
66124
after_success:
67125
codecov
126+
{% endblock %}

test_requirements.txt

-1
This file was deleted.

tests/requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
codecov
2+
moban>=0.0.4
13
pytest~=3.6.1
24
flake8
5+
yamllint

0 commit comments

Comments
 (0)