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

Move scripts to match Core at v0.15b0 #126

Merged
merged 25 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1bc956f
Add test coverage collecting (#128)
Jamim Nov 7, 2019
d8434bf
Add eachdist.py to simplify build (#291)
Oberon00 Dec 10, 2019
331aeb3
Adding Zipkin exporter (#320)
codeboten Dec 30, 2019
5b282c3
Metrics export pipeline + metrics stdout exporter (#341)
lzchen Feb 11, 2020
6a56ce4
Improve docs structure (#467)
mauriciovasquezbernal Mar 10, 2020
9278d5e
lint: Add test for package readme syntax errors (#492)
ffe4 Mar 28, 2020
da77a73
requests: Rename http_requests to requests (#619)
mauriciovasquezbernal May 3, 2020
35f1e5b
aiohttp: aiohttp client (#421)
joshuahlang May 7, 2020
157f6ba
Add exporter to Datadog (#572)
majorgreys May 13, 2020
45a003f
asgi: Add ASGI middleware (#716)
majorgreys May 27, 2020
4047cf4
opentracing-shim: add testbed for otshim (#727)
toumorokoshi Jun 3, 2020
1536a86
cloud-trace: Cloud Trace exporter (#698)
Jun 4, 2020
d672ca2
chore: installation of test packages in eachdist (#794)
toumorokoshi Jun 10, 2020
34f0e88
chore: add test coverage for Cloud Monitoring exporter (#804)
Jun 11, 2020
b2aa82c
starlette instrumentation (#777)
toumorokoshi Jun 15, 2020
d219699
chore: moving code to prepare the release to eachdist (#808)
Jun 16, 2020
277bcee
Initial elasticsearch instrumentation (#747)
owais Jun 17, 2020
aab6c9c
chore: Making eachdist release catch more deps (#867)
toumorokoshi Jul 2, 2020
52c2719
remove google exporter files (#918)
Jul 16, 2020
9367a25
Rename exporter packages from "ext" to "exporter" (#953)
lzchen Jul 29, 2020
76d1cee
Rename web framework packages from "ext" to "instrumentation" (#961)
lzchen Aug 3, 2020
55064ba
Rename remaining framework packages from "ext" to "instrumentation" (…
lzchen Aug 5, 2020
7de931f
Add Global Error Handler (#1080)
ocelotl Sep 30, 2020
78eafde
Merge branch 'core-scripts-v0.15b0'
NathanielRN Nov 2, 2020
1dd16c3
Update scripts for contrib repo
NathanielRN Nov 2, 2020
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 scripts/check_for_valid_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def is_valid_rst(path):
"""Checks if RST can be rendered on PyPI."""
with open(path) as readme_file:
markup = readme_file.read()
return readme_renderer.rst.render(markup) is not None
return readme_renderer.rst.render(markup, stream=sys.stderr) is not None


def parse_args():
Expand Down
17 changes: 16 additions & 1 deletion scripts/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ function cov {
${1}
}

PYTHON_VERSION=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
PYTHON_VERSION_INFO=(${PYTHON_VERSION//./ })

coverage erase

coverage report
cov exporter/opentelemetry-exporter-datadog
cov instrumentation/opentelemetry-instrumentation-flask
cov instrumentation/opentelemetry-instrumentation-requests
cov instrumentation/opentelemetry-instrumentation-wsgi

# aiohttp is only supported on Python 3.5+.
if [ ${PYTHON_VERSION_INFO[1]} -gt 4 ]; then
cov instrumentation/opentelemetry-instrumentation-aiohttp-client
# ext-asgi is only supported on Python 3.5+.
if [ ${PYTHON_VERSION_INFO[1]} -gt 4 ]; then
cov instrumentation/opentelemetry-instrumentation-asgi
fi

coverage report --show-missing
coverage xml
144 changes: 141 additions & 3 deletions scripts/eachdist.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/usr/bin/env python3

import argparse
import os
import re
import shlex
import shutil
import subprocess
import sys
from collections import namedtuple
from configparser import ConfigParser
from datetime import datetime
from inspect import cleandoc
from itertools import chain
from pathlib import Path, PurePath
Expand Down Expand Up @@ -205,6 +208,7 @@ def setup_instparser(instparser):

setup_instparser(instparser)
instparser.add_argument("--editable", "-e", action="store_true")
instparser.add_argument("--with-test-deps", action="store_true")
instparser.add_argument("--with-dev-deps", action="store_true")
instparser.add_argument("--eager-upgrades", action="store_true")

Expand All @@ -214,7 +218,10 @@ def setup_instparser(instparser):
)
setup_instparser(devparser)
devparser.set_defaults(
editable=True, with_dev_deps=True, eager_upgrades=True
editable=True,
with_dev_deps=True,
eager_upgrades=True,
with_test_deps=True,
)

lintparser = subparsers.add_parser(
Expand All @@ -232,6 +239,15 @@ def setup_instparser(instparser):
"pytestargs", nargs=argparse.REMAINDER, help=extraargs_help("pytest")
)

releaseparser = subparsers.add_parser(
"release", help="Prepares release, used by maintainers and CI",
)
releaseparser.set_defaults(func=release_args)
releaseparser.add_argument("--version", required=True)
releaseparser.add_argument(
"releaseargs", nargs=argparse.REMAINDER, help=extraargs_help("pytest")
)

return parser.parse_args(args)


Expand Down Expand Up @@ -322,7 +338,7 @@ def filter_func(path):
if ".egg-info" not in str(newentry) and newentry.exists()
]

return targets
return list(unique(targets))


def runsubprocess(dry_run, params, *args, **kwargs):
Expand Down Expand Up @@ -436,7 +452,17 @@ def install_args(args):
check=True,
)

allfmt = "-e 'file://{}'" if args.editable else "'file://{}'"
allfmt = "-e 'file://{}" if args.editable else "'file://{}"
# packages should provide an extra_requires that is named
# 'test', to denote test dependencies.
extras = []
if args.with_test_deps:
extras.append("test")
if extras:
allfmt += "[{}]".format(",".join(extras))
# note the trailing single quote, to close the quote opened above.
allfmt += "'"

execute_args(
parse_subargs(
args,
Expand Down Expand Up @@ -502,6 +528,118 @@ def lint_args(args):
)


def update_changelog(path, version, new_entry):
unreleased_changes = False
try:
with open(path) as changelog:
text = changelog.read()
if "## Version {}".format(version) in text:
raise AttributeError(
"{} already contans version {}".format(path, version)
)
with open(path) as changelog:
for line in changelog:
if line.startswith("## Unreleased"):
unreleased_changes = False
elif line.startswith("## "):
break
elif len(line.strip()) > 0:
unreleased_changes = True

except FileNotFoundError:
print("file missing: {}".format(path))
return

if unreleased_changes:
print("updating: {}".format(path))
text = re.sub("## Unreleased", new_entry, text)
with open(path, "w") as changelog:
changelog.write(text)


def update_changelogs(targets, version):
print("updating CHANGELOG")
today = datetime.now().strftime("%Y-%m-%d")
new_entry = "## Unreleased\n\n## Version {}\n\nReleased {}".format(
version, today
)
errors = False
for target in targets:
try:
update_changelog(
"{}/CHANGELOG.md".format(target), version, new_entry
)
except Exception as err: # pylint: disable=broad-except
print(str(err))
errors = True

if errors:
sys.exit(1)


def find(name, path):
for root, _, files in os.walk(path):
if name in files:
return os.path.join(root, name)
return None


def update_version_files(targets, version):
print("updating version.py files")
update_files(
targets,
version,
"version.py",
"__version__ .*",
'__version__ = "{}"'.format(version),
)


def update_dependencies(targets, version):
print("updating dependencies")
update_files(
targets,
version,
"setup.cfg",
r"(opentelemetry-.*)==(.*)",
r"\1== " + version,
)


def update_files(targets, version, filename, search, replace):
errors = False
for target in targets:
curr_file = find(filename, target)
if curr_file is None:
print("file missing: {}/{}".format(target, filename))
continue

with open(curr_file) as _file:
text = _file.read()

if version in text:
print("{} already contans version {}".format(curr_file, version))
errors = True
continue

with open(curr_file, "w") as _file:
_file.write(re.sub(search, replace, text))

if errors:
sys.exit(1)


def release_args(args):
print("preparing release")

rootpath = find_projectroot()
targets = list(find_targets_unordered(rootpath))
version = args.version
update_dependencies(targets, version)
update_version_files(targets, version)
update_changelogs(targets, version)


def test_args(args):
clean_remainder_args(args.pytestargs)
execute_args(
Expand Down