Skip to content

Commit cc23360

Browse files
authored
Merge pull request #34 from Holzhaus/ci-improvements
CI improvements
2 parents b5ebc85 + 10f6652 commit cc23360

File tree

2 files changed

+70
-36
lines changed

2 files changed

+70
-36
lines changed

.pre-commit/version_check.py

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
22
import importlib.util
33
import os
44
import pkgutil
@@ -12,6 +12,8 @@
1212
import docutils.utils
1313
import docutils.frontend
1414

15+
CHANGELOG_PATTERN = re.compile(r"^Version (\S+)((?: \(unreleased\)))?$")
16+
1517

1618
def parse_rst(text: str) -> docutils.nodes.document:
1719
parser = docutils.parsers.rst.Parser()
@@ -51,14 +53,12 @@ def get_sphinxchangelog_version(rootdir):
5153
assert len(visitor.sectiontitles_found) == len(unique_sectiontitles)
5254
assert visitor.sectiontitles_found[0] == "Changelog"
5355

54-
changelog_pattern = re.compile(r"^Version (\S+)((?: \(unreleased\)))?$")
55-
56-
matchobj = changelog_pattern(visitor.sectiontitles_found[1])
56+
matchobj = CHANGELOG_PATTERN.match(visitor.sectiontitles_found[1])
5757
assert matchobj
5858
version = matchobj.group(1)
5959
version_unreleased = matchobj.group(2)
6060

61-
matchobj = changelog_pattern(visitor.sectiontitles_found[2])
61+
matchobj = CHANGELOG_PATTERN.match(visitor.sectiontitles_found[2])
6262
assert matchobj
6363
release = matchobj.group(1)
6464
release_unreleased = matchobj.group(2)
@@ -83,7 +83,7 @@ def get_setuppy_version(rootdir):
8383
"""Get version from setup.py."""
8484
setupfile = os.path.join(rootdir, "setup.py")
8585
cmd = (sys.executable, setupfile, "--version")
86-
release = subprocess.check_output(cmd, text=True).rstrip("\n")
86+
release = subprocess.check_output(cmd).decode().rstrip(os.linesep)
8787
version = release.rpartition(".")[0]
8888
return version, release
8989

@@ -112,43 +112,53 @@ def main():
112112

113113
setuppy_version, setuppy_release = get_setuppy_version(rootdir)
114114
package_version, package_release = get_package_version(rootdir)
115-
confpy_version, confpy_release = get_setuppy_version(rootdir)
116-
changelog_version, changelog_release = get_setuppy_version(rootdir)
115+
confpy_version, confpy_release = get_sphinxconfpy_version(rootdir)
116+
changelog_version, changelog_release = get_sphinxchangelog_version(rootdir)
117117

118118
version_head = "Version"
119119
version_width = max(
120-
[
121-
len(version_head),
122-
len(setuppy_version),
123-
len(package_version),
124-
len(confpy_version),
125-
len(changelog_version),
126-
]
120+
(
121+
len(repr(x))
122+
for x in (
123+
version_head,
124+
setuppy_version,
125+
package_version,
126+
confpy_version,
127+
changelog_version,
128+
)
129+
)
127130
)
128131

129132
release_head = "Release"
130133
release_width = max(
131-
[
132-
len(release_head),
133-
len(setuppy_release),
134-
len(package_release),
135-
len(confpy_release),
136-
len(changelog_release),
137-
]
134+
(
135+
len(repr(x))
136+
for x in (
137+
release_head,
138+
setuppy_release,
139+
package_release,
140+
confpy_release,
141+
changelog_release,
142+
)
143+
)
138144
)
139145

140146
print(
141147
f"File {version_head} {release_head}\n"
142148
f"------------------------------- {'-' * version_width}"
143149
f" {'-' * release_width}\n"
144-
f"setup.py {setuppy_version:>{version_width}}"
145-
f" {setuppy_release:>{release_width}}\n"
146-
f"sphinx_multiversion/__init__.py {package_version:>{version_width}}"
147-
f" {package_release:>{release_width}}\n"
148-
f"docs/conf.py {confpy_version:>{version_width}}"
149-
f" {confpy_release:>{release_width}}\n"
150-
f"docs/changelog.rst {changelog_version:>{version_width}}"
151-
f" {changelog_release:>{release_width}}\n"
150+
f"setup.py "
151+
f" {setuppy_version!r:>{version_width}}"
152+
f" {setuppy_release!r:>{release_width}}\n"
153+
f"sphinx_multiversion/__init__.py"
154+
f" {package_version!r:>{version_width}}"
155+
f" {package_release!r:>{release_width}}\n"
156+
f"docs/conf.py "
157+
f" {confpy_version!r:>{version_width}}"
158+
f" {confpy_release!r:>{release_width}}\n"
159+
f"docs/changelog.rst "
160+
f" {changelog_version!r:>{version_width}}"
161+
f" {changelog_release!r:>{release_width}}\n"
152162
)
153163

154164
assert setuppy_version == confpy_version

.travis.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
language: python
2-
python:
3-
- 3.6
4-
- 3.7
51
os: linux
62
dist: xenial
3+
language: python
4+
5+
jobs:
6+
include:
7+
- name: "Ubuntu / Python 3.6"
8+
python: 3.6
9+
- name: "Ubuntu / Python 3.7"
10+
python: 3.7
11+
- name: "Windows / Python 3.6"
12+
os: windows
13+
language: shell
14+
before_install:
15+
- choco install python --version 3.6.8
16+
env:
17+
- PATH=/c/Python36:/c/Python36/Scripts:$PATH
18+
- SKIP=check-executables-have-shebangs
19+
- name: "Windows / Python 3.7"
20+
os: windows
21+
language: shell
22+
before_install:
23+
- choco install python --version 3.7.8
24+
env:
25+
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
26+
- SKIP=check-executables-have-shebangs
27+
728
cache:
829
pip: true
930

@@ -22,8 +43,8 @@ script:
2243

2344
# Deployment
2445
before_deploy:
25-
- touch html/.nojekyll
26-
- cp assets/gh-pages-redirect.html html/index.html
46+
- touch html/.nojekyll
47+
- cp assets/gh-pages-redirect.html html/index.html
2748
deploy:
2849
# Deploy documentation
2950
- provider: pages
@@ -35,6 +56,7 @@ deploy:
3556
branch: master
3657
repo: Holzhaus/sphinx-multiversion
3758
python: 3.7
59+
os: linux
3860

3961
# Deploy to PyPI
4062
- deploy:
@@ -48,6 +70,7 @@ deploy:
4870
branch: master
4971
repo: Holzhaus/sphinx-multiversion
5072
tags: true
73+
os: linux
5174

5275
# Deploy to Github Releases
5376
- provider: releases
@@ -65,3 +88,4 @@ deploy:
6588
repo: Holzhaus/sphinx-multiversion
6689
tags: true
6790
python: 3.7
91+
os: linux

0 commit comments

Comments
 (0)