Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version check for README.md #471

Merged
merged 1 commit into from
Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ usage: proxy [-h] [--backlog BACKLOG] [--basic-auth BASIC_AUTH]
[--static-server-dir STATIC_SERVER_DIR] [--threadless]
[--timeout TIMEOUT] [--version]

proxy.py v2.2.0
proxy.py v2.3.0

optional arguments:
-h, --help show this help message and exit
Expand Down
25 changes: 19 additions & 6 deletions version-check.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
proxy.py
~~~~~~~~
Expand All @@ -8,18 +9,30 @@
:license: BSD, see LICENSE for more details.
"""
import sys
import subprocess
from proxy.common.version import __version__ as lib_version
from setup import __version__ as pkg_version

# This script ensures our versions never run out of sync.
#
# 1. setup.py doesn't import proxy and hence they both use
# their own respective __version__
# 2. TODO: Version is hardcoded in homebrew stable package
# 1. TODO: Version is hardcoded in homebrew stable package
# installer file, but it only needs to match with lib
# versions if current git branch is master
# 3. TODO: Version is also hardcoded in README.md flags
# section

# setup.py doesn't import proxy and hence they both use
# their own respective __version__
if lib_version != pkg_version:
print('Version mismatch found. {0} (lib) vs {1} (pkg).'.format(lib_version, pkg_version))
print('Version mismatch found. {0} (lib) vs {1} (pkg).'.format(
lib_version, pkg_version))
sys.exit(1)

# Version is also hardcoded in README.md flags section
readme_version_cmd = 'cat README.md | grep "proxy.py v" | tail -2 | head -1 | cut -d " " -f 2 | cut -c2-'
readme_version_output = subprocess.check_output(
['bash', '-c', readme_version_cmd])
readme_version = readme_version_output.decode().strip()

if readme_version != lib_version:
print('Version mismatch found. {0} (readme) vs {1} (lib).'.format(
readme_version, lib_version))
sys.exit(1)