Skip to content

Commit

Permalink
Merge pull request #61 from vkottler/dev/2.4.1-retry
Browse files Browse the repository at this point in the history
2.4.1 - Fix bug in format checking
  • Loading branch information
vkottler authored Aug 6, 2023
2 parents 8f6261c + 5c06adb commit d0604a0
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=yambs version=2.4.0
repo=yambs version=2.4.1
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.3
hash=56e5498dfc3e0d2dbd23a5dfbfe11761
hash=2c699e065c46c9a82b34dd32519fb24e
=====================================
-->

# yambs ([2.4.0](https://pypi.org/project/yambs/))
# yambs ([2.4.1](https://pypi.org/project/yambs/))

[![python](https://img.shields.io/pypi/pyversions/yambs.svg)](https://pypi.org/project/yambs/)
![Build Status](https://github.com/vkottler/yambs/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion config
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 2
minor: 4
patch: 0
patch: 1
entry: mbs
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "yambs"
version = "2.4.0"
version = "2.4.1"
description = "Yet another meta build-system."
readme = "README.md"
requires-python = ">=3.11"
Expand Down Expand Up @@ -36,6 +36,8 @@ test = [
"yamllint",
"yambs",
"vmklib",
"sphinx",
"sphinx-book-theme",
"setuptools-wrapper",
"types-setuptools",
"types-requests"
Expand Down
3 changes: 1 addition & 2 deletions tests/commands/test_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ def test_native_command_basic():
assert yambs_main([PKG_NAME, "native"]) == 0

# Try to build (if we can).
# Re-enable this when we fix the third party script.
if platform == "linux" and which("ninja"):
run(["ninja", "all"], check=True)
run(["ninja", "all", "format-check"], check=True)
4 changes: 2 additions & 2 deletions yambs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.3
# hash=97870f506d5d2f9b5b8e3527f76efa07
# hash=24e206542fae6896b37aff43eec1c8ec
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "Yet another meta build-system."
PKG_NAME = "yambs"
VERSION = "2.4.0"
VERSION = "2.4.1"
18 changes: 10 additions & 8 deletions yambs/dependency/handlers/yambs/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ def audit_downloads(

dest = root.joinpath(name)

if dest.is_file():
continue

for suffix in to_download:
if name.endswith(suffix):
# Download the file.
req = requests.get(asset["browser_download_url"], timeout=10)
with dest.open("wb") as dest_fd:
for chunk in req.iter_content(chunk_size=4096):
dest_fd.write(chunk)
# Download if necessary.
if not dest.is_file():
# Download the file.
req = requests.get(
asset["browser_download_url"], timeout=10
)
with dest.open("wb") as dest_fd:
for chunk in req.iter_content(chunk_size=4096):
dest_fd.write(chunk)

data["assets"][suffix] = str(dest)
break
Expand All @@ -73,6 +74,7 @@ def audit_extract(root: Path, data: DependencyData) -> Path:
if "directory" not in data:
# The expected directory is just the name of the tarball with no
# suffix.
assert TARBALL in data["assets"], data["assets"]
expected = Path(data["assets"][TARBALL].replace(TARBALL, ""))

# The name of the project is the directory name without the version
Expand Down
2 changes: 2 additions & 0 deletions yambs/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ isort
yamllint
yambs
vmklib
sphinx
sphinx-book-theme
setuptools-wrapper
types-setuptools
types-requests
2 changes: 1 addition & 1 deletion yambs/generate/ninja/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def write_format_target(

# Just checks formatting.
stream.write("rule clang-format-check" + linesep)
stream.write(" command = {cmd} -n --Werror $in" + linesep)
stream.write(f" command = {cmd} -n --Werror $in" + linesep)

paths = list(paths)
if paths:
Expand Down
46 changes: 30 additions & 16 deletions yambs/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
# internal
from yambs.schemas import YambsDictCodec as _YambsDictCodec

GIHTUB_HEADERS = {
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
}
ReleaseData = Dict[str, Any]


class Github(_YambsDictCodec, _BasicDictCodec):
"""GitHub repository information."""
Expand Down Expand Up @@ -50,12 +56,6 @@ def latest_repo_release_api_url(owner: str, repo: str) -> str:
).geturl()


GIHTUB_HEADERS = {
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
}


def check_api_token() -> None:
"""Check for a GitHub API token set via the environment."""

Expand All @@ -66,20 +66,34 @@ def check_api_token() -> None:
] = f"Bearer {os.environ['GITHUB_API_TOKEN']}"


ReleaseData = Dict[str, Any]


def latest_release_data(
owner: str, repo: str, *args, timeout: float = None, **kwargs
) -> ReleaseData:
"""Get latest-release data."""

check_api_token()

return requests.get( # type: ignore
latest_repo_release_api_url(owner, repo),
*args,
timeout=timeout,
headers=GIHTUB_HEADERS,
**kwargs,
).json()
result: ReleaseData = {}

# codecov was bugging out.
tries = kwargs.get("tries", 5)

while not validate_release(result) and tries:
result = requests.get(
latest_repo_release_api_url(owner, repo),
*args,
timeout=timeout,
headers=GIHTUB_HEADERS,
**kwargs,
).json()
tries -= 1

assert validate_release(result), result

return result


def validate_release(data: ReleaseData) -> bool:
"""Ensure that GitHub release data actually contains data."""

return all(x in data for x in ["name", "html_url", "assets"])

0 comments on commit d0604a0

Please sign in to comment.