Skip to content

Commit

Permalink
Merge pull request #45 from vkottler/dev/2.2.0
Browse files Browse the repository at this point in the history
Add initial GitHub dependency dev
  • Loading branch information
vkottler authored Jul 29, 2023
2 parents db64ed1 + a4c4c04 commit ee5f5da
Show file tree
Hide file tree
Showing 45 changed files with 804 additions and 117 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
system:
- ubuntu-latest
Expand Down Expand Up @@ -65,7 +62,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=yambs version=2.1.1
repo=yambs version=2.2.0
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ htmlcov
*-stubs
coverage*.xml
tags
third-party

ninja
build.ninja
.ninja*
compile_commands.json
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[DESIGN]
max-args=8
max-attributes=8
max-attributes=10

[MESSAGES CONTROL]
disable=too-few-public-methods
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.2
hash=f95824d927cb8814a559ce41e03ebd38
hash=9fd78d02f6bd1c0baddfb2fa7ba65d51
=====================================
-->

# yambs ([2.1.1](https://pypi.org/project/yambs/))
# yambs ([2.2.0](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 All @@ -23,9 +23,6 @@ See also: [generated documentation](https://vkottler.github.io/python/pydoc/yamb

This package is tested with the following Python minor versions:

* [`python3.8`](https://docs.python.org/3.8/)
* [`python3.9`](https://docs.python.org/3.9/)
* [`python3.10`](https://docs.python.org/3.10/)
* [`python3.11`](https://docs.python.org/3.11/)

## Platform Support
Expand Down
4 changes: 3 additions & 1 deletion local/configs/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ time_command: true

requirements:
- datazen
- vcorelib>=2.3.1
- vcorelib>=2.4.2
- rcmpy>=1.5.0
- requests
dev_requirements:
- setuptools-wrapper
- types-setuptools
- types-requests

commands:
- name: dist
Expand Down
2 changes: 1 addition & 1 deletion local/configs/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ author_info:
name: Vaughn Kottler
email: vaughnkottler@gmail.com
username: vkottler
versions: ["3.8", "3.9", "3.10", "3.11"]
versions: ["3.11"]

systems:
- macos-latest
Expand Down
4 changes: 2 additions & 2 deletions local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 2
minor: 1
patch: 1
minor: 2
patch: 0
entry: mbs
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "yambs"
version = "2.1.1"
version = "2.2.0"
description = "Yet another meta build-system."
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.11"
authors = [
{name = "Vaughn Kottler", email = "vaughnkottler@gmail.com"}
]
maintainers = [
{name = "Vaughn Kottler", email = "vaughnkottler@gmail.com"}
]
classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
Expand All @@ -38,7 +35,8 @@ test = [
"isort",
"yamllint",
"setuptools-wrapper",
"types-setuptools"
"types-setuptools",
"types-requests"
]

[project.scripts]
Expand Down
1 change: 1 addition & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
29 changes: 29 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

CURL_ARGS=(curl -L)

add_header() {
CURL_ARGS+=(-H "$1: $2")
}

add_header Accept application/vnd.github+json

API_VERSION=2022-11-28
add_header X-GitHub-Api-Version $API_VERSION

if [ -n "$API_TOKEN" ]; then
add_header Authorization "Bearer $API_TOKEN"
fi

run_curl() {
echo "${CURL_ARGS[@]}" "$@" >&2
"${CURL_ARGS[@]}" "$@"
}

repo_api_url() {
echo "https://api.github.com/repos/$OWNER/$REPO"
}

latest_release_url() {
echo "$(repo_api_url "$1" "$2")/releases/latest"
}
13 changes: 13 additions & 0 deletions scripts/latest_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

REPO=$(git rev-parse --show-toplevel)
CWD=$REPO/scripts

# Set API_TOKEN= to enable header argument.
. "$CWD/common.sh"

OWNER=vkottler
REPO=yambs-sample

run_curl "$(latest_release_url $OWNER $REPO)" > "$CWD/output.json"
cat "$CWD/output.json"
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.2
# hash=7cd5513daf171d1a95f64dc81343a73b
# hash=f3af34a4b5815c617489419b194b30b5
# =====================================

"""
Expand All @@ -28,9 +28,6 @@
"version": VERSION,
"description": DESCRIPTION,
"versions": [
"3.8",
"3.9",
"3.10",
"3.11",
],
}
Expand Down
19 changes: 5 additions & 14 deletions tests/commands/test_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# internal
from tests.resources import resource
from tests.resources import clean_scenario

# module under test
from yambs import PKG_NAME
Expand All @@ -13,16 +13,7 @@
def test_gen_command_basic():
"""Test the 'gen' command."""

assert (
yambs_main(
[
PKG_NAME,
"-C",
str(resource("scenarios", "sample")),
"gen",
"-w",
"-i",
]
)
== 0
)
path = str(clean_scenario("sample"))

assert yambs_main([PKG_NAME, "-C", path, "gen", "-w", "-i"]) == 0
assert yambs_main([PKG_NAME, "-C", path, "gen"]) == 0
32 changes: 18 additions & 14 deletions tests/commands/test_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
Test the 'commands.native' module.
"""

# built-in
from shutil import which
from subprocess import run
from sys import platform

# third-party
from vcorelib.paths.context import in_dir

# internal
from tests.resources import resource
from tests.resources import clean_scenario

# module under test
from yambs import PKG_NAME
Expand All @@ -13,16 +21,12 @@
def test_native_command_basic():
"""Test the 'native' command."""

assert (
yambs_main(
[
PKG_NAME,
"-C",
str(resource("scenarios", "native")),
"native",
"-w",
"-i",
]
)
== 0
)
path = str(clean_scenario("native"))

with in_dir(path):
assert yambs_main([PKG_NAME, "native", "-w", "-i"]) == 0
assert yambs_main([PKG_NAME, "native"]) == 0

# Try to build (if we can).
if platform == "linux" and which("ninja"):
run("ninja", check=True)
4 changes: 0 additions & 4 deletions tests/data/valid/scenarios/native/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions tests/data/valid/scenarios/native/build.ninja

This file was deleted.

7 changes: 7 additions & 0 deletions tests/data/valid/scenarios/native/src/apps/app1.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* toolchain */
#include <iostream>

/* third-party */
#include "yambs-sample/example/sample.h"

int test1(int a, int b) { return a + b; }

int main(void) {
Expand All @@ -13,5 +16,9 @@ int main(void) {
std::cout << a << std::endl;
}

Example::method1();
Example::method2();
Example::method3();

return 0;
}
5 changes: 4 additions & 1 deletion tests/data/valid/scenarios/native/yambs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extra_dist: [extra]
project:
name: yambs
github:
owner: vkottler
owner: &self vkottler

variants:
clang:
Expand All @@ -17,3 +17,6 @@ variants:
clang-opt:
extra_cflags: [--coverage]
cflag_groups: [opt]

dependencies:
- github: {repo: yambs-sample, owner: *self}
2 changes: 0 additions & 2 deletions tests/data/valid/scenarios/sample/.gitignore

This file was deleted.

Empty file added tests/dependency/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions tests/dependency/test_github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Test the 'dependency.github' module.
"""

# internal
from tests.resources import OWNER, REPO

# module under test
from yambs.dependency.github import GithubDependency


def test_github_dependency_basic():
"""Test basic interactions with a GitHub dependency."""

assert GithubDependency(OWNER, REPO)
17 changes: 17 additions & 0 deletions tests/dependency/test_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Test the 'dependency.manager' module.
"""

# built-in
from pathlib import Path
from tempfile import TemporaryDirectory

# module under test
from yambs.dependency.manager import DependencyManager


def test_dependency_manager_basic():
"""Test basic interactions with a dependency manager."""

with TemporaryDirectory() as tmp:
assert DependencyManager(Path(tmp))
Empty file added tests/github/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions tests/github/test_github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Test the 'github' module.
"""

# internal
from tests.resources import OWNER, REPO

# module under test
from yambs.github import (
github_url,
latest_release_data,
latest_repo_release_api_url,
)


def test_github_url_basic():
"""Test URL encoding."""

assert github_url().geturl() == "https://github.com"
assert github_url(netloc_prefix="api").geturl() == "https://api.github.com"
assert (
latest_repo_release_api_url(OWNER, REPO)
== "https://api.github.com/repos/vkottler/yambs-sample/releases/latest"
)
assert latest_release_data(OWNER, REPO)
Loading

0 comments on commit ee5f5da

Please sign in to comment.