Skip to content

Commit

Permalink
flake
Browse files Browse the repository at this point in the history
  • Loading branch information
javierggt committed Nov 17, 2022
1 parent 6adb606 commit a5cbec2
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 44 deletions.
18 changes: 11 additions & 7 deletions actions/build/files/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def overwrite_skare3_version(current_version, new_version, pkg_path):
To fix this, I can require that packages are specified as a non-positional argument, but that breaks
all current workflows.
"""


def get_parser():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('package',
Expand Down Expand Up @@ -116,8 +118,8 @@ def main():
condarc_in = condarc.with_suffix('.in')
condarc.replace(condarc_in)
with open(condarc_in) as condarc_in, open(condarc, 'w') as condarc:
for l in condarc_in.readlines():
condarc.write(l.replace('${CONDA_PASSWORD}', os.environ['CONDA_PASSWORD']))
for line in condarc_in.readlines():
condarc.write(line.replace('${CONDA_PASSWORD}', os.environ['CONDA_PASSWORD']))
else:
print('Conda password needs to be given as environmental variable CONDA_PASSWORD')
sys.exit(100)
Expand Down Expand Up @@ -168,15 +170,17 @@ def main():
f.unlink()

# report result
files = (list(build_dir.glob('linux-64/*tar.bz2*')) +
list(build_dir.glob('osx-64/*tar.bz2*')) +
list(build_dir.glob('noarch/*tar.bz2*')) +
list(build_dir.glob('win-64/*tar.bz2*')))
files = (
list(build_dir.glob('linux-64/*tar.bz2*'))
+ list(build_dir.glob('osx-64/*tar.bz2*'))
+ list(build_dir.glob('noarch/*tar.bz2*'))
+ list(build_dir.glob('win-64/*tar.bz2*'))
)
files = ' '.join([str(f) for f in files])

print(f'Built files: {files}')
print(f'::set-output name=files::{files}')


if __name__ == '__main__':
main()
main()
2 changes: 1 addition & 1 deletion scripts/github-runner-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_pid(runner):

if pid is not None:
a = subprocess.run(["ps", "-A"], capture_output=True)
ps = [l for l in a.stdout.decode().split("\n") if re.match(f"{pid}\s", l)]
ps = [line for line in a.stdout.decode().split("\n") if re.match(f"{pid}\\s", line)]
if not ps:
logging.debug(f"process {pid} (runner={runner}) is not running. Resetting.")
pid = None
Expand Down
4 changes: 2 additions & 2 deletions skare3_tools/dashboard/views/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def html(text):
span = {
"\x1b[1m": '<span style="font-weight: bold;">',
"\x1b[4m": '<span style="text-decoration: underline">',
#'\x1b[7m': '<span>', # reverse
# '\x1b[7m': '<span>', # reverse
"\x1b[30m": '<span style="color:black">',
"\x1b[31m": '<span style="color:red">',
"\x1b[32m": '<span style="color:green">',
Expand Down Expand Up @@ -61,7 +61,7 @@ def html(text):
result = ""
depth = 0
i = 0
matches = [m for m in re.finditer("\x1b\[[0-9;]+m", text)]
matches = [m for m in re.finditer(r"\x1b\[[0-9;]+m", text)]
for m in matches:
s, e = m.span()
c = text[s:e]
Expand Down
2 changes: 1 addition & 1 deletion skare3_tools/dashboard/views/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def main():

if not args.b:
file_out = os.path.abspath(args.file_out)
webbrowser.open("file://{file_out}".format(file_out=args.file_out), new=2)
webbrowser.open("file://{file_out}".format(file_out=file_out), new=2)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions skare3_tools/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
>>> from skare3_tools import github
>>> github.init(token='c7hvg6pqi3fhqwv0wvlgp4mk9agwbqk1gxc331iz') # this is optional
.. _`authentication token`: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token
.. _`authentication token`: https://docs.github.com/en/authentication
"""
from . import github, graphql
from .github import Organization, Repository
from .github import Organization, Repository # noqa

GITHUB_API_V3 = github.GITHUB_API
GITHUB_API_V4 = graphql.GITHUB_API
Expand Down
6 changes: 3 additions & 3 deletions skare3_tools/github/scripts/add_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def _get_button(text):
def _get_link(text=None, **attributes):
links = _driver_.find_elements_by_tag_name("a")
if text is not None:
links = [l for l in links if l.text == text]
links = [line for line in links if line.text == text]
for att in attributes:
links = [l for l in links if l.get_attribute(att) == attributes[att]]
links = [line for line in links if line.get_attribute(att) == attributes[att]]
msg = f"link with attributes={attributes}"
if text is not None:
msg += f" and text={text}"
Expand Down Expand Up @@ -183,7 +183,7 @@ def main():
args = the_parser.parse_args()

try:
import selenium
import selenium # noqa
except ModuleNotFoundError:
logging.error(
f"The script requires the selenium module. Run `{sys.argv[0]} -h` for help."
Expand Down
2 changes: 1 addition & 1 deletion skare3_tools/github/scripts/release_merge_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def main():
for commit in commits:
msg = commit["commit"]["message"]
match = re.match(
"Merge pull request (?P<pr>.+) from (?P<branch>\S+)\n\n(?P<description>.+)",
r"Merge pull request (?P<pr>.+) from (?P<branch>\S+)\n\n(?P<description>.+)",
msg,
)
if match:
Expand Down
14 changes: 7 additions & 7 deletions skare3_tools/packages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""
r"""
A module to keep track of all package information (repository, conda package info, etc).
Package List
Expand Down Expand Up @@ -93,7 +93,7 @@ class NetworkException(Exception):


def json_cache(name, directory="", ignore=None, expires=None, update_policy=None):
"""
r"""
Decorator to cache function results in json format.
This decorator adds an 'update' argument to decorated functions. update is False by default,
Expand Down Expand Up @@ -231,9 +231,9 @@ def _conda_package_list(update=True):
if "about" in info and "home" in info["about"]:
home = info["about"]["home"].strip()
matches = [
re.match("git@github.com:(?P<org>[^/]+)/(?P<repo>\S+)\.git$", home),
re.match("git@github.com:(?P<org>[^/]+)/(?P<repo>\S+)$", home),
re.match("https?://github.com/(?P<org>[^/]+)/(?P<repo>[^/]+)/?", home),
re.match(r"git@github.com:(?P<org>[^/]+)/(?P<repo>\S+)\.git$", home),
re.match(r"git@github.com:(?P<org>[^/]+)/(?P<repo>\S+)$", home),
re.match(r"https?://github.com/(?P<org>[^/]+)/(?P<repo>[^/]+)/?", home),
]
m = {}
for m in matches:
Expand Down Expand Up @@ -479,7 +479,7 @@ def _get_repository_info_v4(
)
release_info[-1]["commits"].append(commit)
match = re.match(
"Merge pull request #(?P<pr_number>.+) from (?P<branch>\S+)\n\n(?P<title>.+)",
r"Merge pull request #(?P<pr_number>.+) from (?P<branch>\S+)\n\n(?P<title>.+)",
commit["message"],
)
if match:
Expand Down Expand Up @@ -799,7 +799,7 @@ def _get_repository_info_v3(
}
)
match = re.match(
"Merge pull request #(?P<pr_number>.+) from (?P<branch>\S+)\n\n(?P<title>.+)",
r"Merge pull request #(?P<pr_number>.+) from (?P<branch>\S+)\n\n(?P<title>.+)",
commit["commit"]["message"],
)
if match:
Expand Down
7 changes: 4 additions & 3 deletions skare3_tools/scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def main():
version_info["label"] = (
f'+{version_info["label"]}' if version_info["label"] else ""
)
args.ska3_overwrite_version = f'{version_info["release"]}{version_info["label"]}:{version_info["version"]}'
args.ska3_overwrite_version = \
f'{version_info["release"]}{version_info["label"]}:{version_info["version"]}'

print("skare3 build args:", args)
print("skare3 build unknown args:", unknown_args)
Expand All @@ -159,9 +160,9 @@ def main():
condarc_in = condarc.with_suffix(".in")
condarc.replace(condarc_in)
with open(condarc_in) as condarc_in, open(condarc, "w") as condarc:
for l in condarc_in.readlines():
for line in condarc_in.readlines():
condarc.write(
l.replace("${CONDA_PASSWORD}", os.environ["CONDA_PASSWORD"])
line.replace("${CONDA_PASSWORD}", os.environ["CONDA_PASSWORD"])
)
else:
print(
Expand Down
2 changes: 1 addition & 1 deletion skare3_tools/scripts/bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def parser():
def main():
args, extra = parser().parse_known_args()
args.cmd += extra
packages = [l.strip() for l in open(args.repositories).readlines()]
packages = [line.strip() for line in open(args.repositories).readlines()]
for package in packages:
header = f"\n\n{package}\n{'-'*len(package)}" ""
print(header)
Expand Down
32 changes: 27 additions & 5 deletions skare3_tools/scripts/skare3_promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def promote(package, args, platforms=None):
# was not found.
if pkgs == []:
logging.warning(
f'package {package["name"]}=={package["version"]} not found for platform {platform}.'
f'package {package["name"]}=={package["version"]}'
f' not found for platform {platform}.'
)
continue

Expand Down Expand Up @@ -148,7 +149,8 @@ def promote(package, args, platforms=None):
pkg_files += pkgs
if not pkgs:
logging.warning(
f"package {requirement['name']}=={requirement['version']} was not found"
f"package {requirement['name']}=={requirement['version']}"
" was not found"
)
else:
logging.error(f'Could not parse requirement: "{requirement}"')
Expand All @@ -168,7 +170,13 @@ def promote(package, args, platforms=None):
name: [p for p in pkg_files if p["name"] == name] for name in package_names
}

row = "| {package:30s} | {noarch:24s} {noarch-src:7s} | {linux-64:24s} {linux-64-src:7s} | {osx-64:24s} {osx-64-src:7s} | {win-64:24s} {win-64-src:7s} |"
row = (
"| {package:30s} "
"| {noarch:24s} {noarch-src:7s} "
"| {linux-64:24s} {linux-64-src:7s} "
"| {osx-64:24s} {osx-64-src:7s} "
"| {win-64:24s} {win-64-src:7s} |"
)
div = {"package": "", "noarch": "", "linux-64": "", "osx-64": "", "win-64": ""}
div.update(
{k: "" for k in ["noarch-src", "linux-64-src", "osx-64-src", "win-64-src"]}
Expand Down Expand Up @@ -227,12 +235,26 @@ def promote(package, args, platforms=None):


def parser():
usage = "%(prog)s [-h] [--ska3-conda SKA3_CONDA] [--from FROM_CHANNEL [--from FROM_CHANNEL ...] ] [--to TO_CHANNEL] [--dry-run] [--move] [--skare3-local-copy SKARE3] [--log-level {error,warning,info,debug}] [-v] <package name>==<version> [<package name>==<version> ...]"
usage = (
"%(prog)s [-h]"
" [--ska3-conda SKA3_CONDA]"
" [--from FROM_CHANNEL [--from FROM_CHANNEL ...] ]"
" [--to TO_CHANNEL]"
" [--dry-run]"
" [--move]"
" [--skare3-local-copy SKARE3]"
" [--log-level {error,warning,info,debug}]"
" [-v]"
" <package name>==<version> [<package name>==<version> ...]"
)
parse = argparse.ArgumentParser(description=__doc__, usage=usage)
parse.add_argument("package", nargs="+", metavar="<package name>==<version>")
parse.add_argument(
"--ska3-conda",
help="ska3-conda directory containing source and target channels (defaults to the standard location)",
help=(
"ska3-conda directory containing source and target channels"
" (defaults to the standard location)"
),
default=SKA3_CONDA,
)
parse.add_argument(
Expand Down
7 changes: 4 additions & 3 deletions skare3_tools/scripts/skare3_release_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def main():
] # versions can be git refs like refs/tags/V2
# regular expression (mostly) matching PEP-0440 version format
fmt = (
"(?P<final_version>((?P<epoch>[0-9]+)!)?(?P<release>[0-9]+(.[0-9]+(.[0-9]+)?)?))"
"((a|b|rc)(?P<rc>[0-9]+))?(\+(?P<label>[a-zA-Z]+))?$"
r"(?P<final_version>((?P<epoch>[0-9]+)!)?(?P<release>[0-9]+(.[0-9]+(.[0-9]+)?)?))"
r"((a|b|rc)(?P<rc>[0-9]+))?(\+(?P<label>[a-zA-Z]+))?$"
)
version_info = re.match(fmt, tag_name)
if not version_info:
Expand Down Expand Up @@ -198,7 +198,8 @@ def main():
for pkg in possible_error:
logging.warning(f" - {pkg}")
logging.warning(
f'This can happen if YAML interprets version {version_info["final_version"]} as a float.'
'This can happen if YAML interprets version'
f' {version_info["final_version"]} as a float.'
)
logging.warning("They will not be built.")

Expand Down
4 changes: 2 additions & 2 deletions skare3_tools/scripts/skare3_update_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ def repository_change_summary(pkgs_repo_info, initial_versions={}, final_version

if version_1 in releases and version_1:
releases = releases[
releases.index(version_2) : releases.index(version_1)
releases.index(version_2): releases.index(version_1)
]
else:
releases = releases[releases.index(version_2) :]
releases = releases[releases.index(version_2):]
release_info = {
_clean_version(r["release_tag"]): r["merges"]
for r in p["release_info"]
Expand Down
12 changes: 6 additions & 6 deletions skare3_tools/scripts/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
def test_results(directory):
filename = os.path.join(directory, "test.log")
with open(filename) as f:
for l in f:
if re.match("\*\*\*\s+Package\s+Script\s+Status\s+\*\*\*", l):
for line in f:
if re.match(r"\*\*\*\s+Package\s+Script\s+Status\s+\*\*\*", line):
break
results = []
for l in f:
if re.search("fail", l.lower()) or re.search("pass", l.lower()):
results.append(l.split()[1:-1])
for line in f:
if re.search("fail", line.lower()) or re.search("pass", line.lower()):
results.append(line.split()[1:-1])
result_dict = {k[0]: {"tests": {}} for k in results}
for k in results:
try:
module = importlib.import_module(k[0])
version = module.__version__
except:
except Exception:
version = ""
result_dict[k[0]]["tests"][k[1]] = k[2].upper()
res = result_dict[k[0]]["tests"].values()
Expand Down

0 comments on commit a5cbec2

Please sign in to comment.