Skip to content

Commit

Permalink
feat: add a python script for auto update package versions according … (
Browse files Browse the repository at this point in the history
#85)

Co-authored-by: Hu Yueh-Wei <[email protected]>
  • Loading branch information
sunxilin and halajohn authored Oct 10, 2024
1 parent 27f7369 commit 0d9a8b6
Show file tree
Hide file tree
Showing 116 changed files with 964 additions and 510 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/build_linux_ubuntu1804.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@ name: Build - linux ubuntu1804
on:
release:
types: [created]
push:
branches:
- "**"
paths-ignore:
- "tools/**"
- "docs/**"
- ".vscode/**"
- ".devcontainer/**"
- ".github/**"
- "!.github/workflows/build_linux_ubuntu1804.yml"
- "**.md"
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "tools/**"
- "docs/**"
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/build_linux_ubuntu2204.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@ name: Build - linux ubuntu2204
on:
release:
types: [created]
push:
branches:
- "**"
paths-ignore:
- "tools/**"
- "docs/**"
- ".vscode/**"
- ".devcontainer/**"
- ".github/**"
- "!.github/workflows/build_linux_ubuntu2204.yml"
- "**.md"
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "tools/**"
- "docs/**"
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/build_mac.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
name: Build - mac

on:
push:
branches:
- "**"
paths-ignore:
- "tools/**"
- "docs/**"
- ".vscode/**"
- ".devcontainer/**"
- ".github/**"
- "!.github/workflows/build_mac.yml"
- "**.md"
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "tools/**"
- "docs/**"
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
name: Build - win

on:
push:
branches:
- "**"
paths-ignore:
- "tools/**"
- "docs/**"
- ".vscode/**"
- ".devcontainer/**"
- ".github/**"
- "!.github/workflows/build_win.yml"
- "**.md"
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "tools/**"
- "docs/**"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ packages/private_extensions
tests/private
third_party/private
build/private

# zlib auto-generated files
third_party/zlib/zconf.h.included
30 changes: 30 additions & 0 deletions build/ten_runtime/feature/install_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ def __init__(self):
self.depfile_target: str
self.log_level: int
self.pkg_type: str
self.local_registry_path: str


def get_pkgs_from_local_registry(
local_registry_path: str, pkg_type: str, pkg_name: str
) -> list[str]:
# Find directories under <local_registry_path>/<pkg_type>/<pkg_name> and
# return their names.
pkg_dir = os.path.join(local_registry_path, pkg_type, pkg_name)
if not os.path.exists(pkg_dir):
return []

return os.listdir(pkg_dir)


def process_possible_published_results(file_paths: list[str]) -> list[str]:
Expand Down Expand Up @@ -90,6 +103,12 @@ def process_possible_published_results(file_paths: list[str]) -> list[str]:
parser.add_argument(
"--log-level", type=int, required=True, help="specify log level"
)
parser.add_argument(
"--local-registry-path",
type=str,
required=False,
help="Path to local registry",
)

arg_info = ArgumentInfo()
args = parser.parse_args(namespace=arg_info)
Expand Down Expand Up @@ -125,6 +144,17 @@ def process_possible_published_results(file_paths: list[str]) -> list[str]:
if args.config_file is not None:
list.append(cmd, "--config-file=" + args.config_file)

if args.local_registry_path is not None:
versions = get_pkgs_from_local_registry(
args.local_registry_path, args.pkg_type, args.src_pkg
)

if len(versions) == 1:
# If there is only one version, install using that specific
# version number to avoid installation failures due to it being
# a pre-release version.
args.src_pkg += f"@{versions[0]}"

cmd += [
"install",
args.pkg_type,
Expand Down
10 changes: 10 additions & 0 deletions build/ten_runtime/feature/test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ template("ten_package_test_prepare_app") {
"${log_level}",
]

args += [
"--local-registry-path",
rebase_path("${root_out_dir}/tests/local_registry"),
]

if (invoker.deps != []) {
foreach(dep, invoker.deps) {
args += [
Expand Down Expand Up @@ -574,6 +579,11 @@ template("ten_package_standalone_pkg") {
"${log_level}",
]

args += [
"--local-registry-path",
rebase_path("${root_out_dir}/tests/local_registry"),
]

if (invoker.deps != []) {
foreach(dep, invoker.deps) {
args += [
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_manager/src/version.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub const VERSION: &str = "0.2.0";
pub const VERSION: &str = "0.3.0-alpha";
1 change: 1 addition & 0 deletions core/src/ten_manager/src/version.rs.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub const VERSION: &str = "{{ VERSION }}";
4 changes: 2 additions & 2 deletions core/src/ten_runtime/binding/go/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "system",
"name": "ten_runtime_go",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
}
],
"package": {
Expand Down
4 changes: 2 additions & 2 deletions core/src/ten_runtime/binding/python/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "system",
"name": "ten_runtime_python",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
}
],
"package": {
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_runtime/build_template/preserved_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
#include "include_internal/ten_runtime/common/preserved_metadata.h"

static char metadata[] = "version=0.2.0";
static char metadata[] = "version=0.3.0-alpha";

void ten_preserved_metadata(void) {
((char volatile *)metadata)[0] = metadata[0];
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_runtime/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0",
"version": "0.3.0-alpha",
"dependencies": [],
"package": {
"include": [
Expand Down
4 changes: 2 additions & 2 deletions packages/core_apps/default_app_cpp/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "app",
"name": "default_app_cpp",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
}
]
}
4 changes: 2 additions & 2 deletions packages/core_apps/default_app_cpp/manifest.json.tent
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "app",
"name": "{{package_name}}",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
}
]
}
6 changes: 3 additions & 3 deletions packages/core_apps/default_app_go/manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"type": "app",
"name": "default_app_go",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
},
{
"type": "system",
"name": "ten_runtime_go",
"version": "0.1.0"
"version": "0.3.0-alpha"
}
]
}
9 changes: 5 additions & 4 deletions packages/core_apps/default_app_go/manifest.json.tent
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"type": "app",
"name": "{{package_name}}",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
},
{
"type": "system",
"name": "ten_runtime_go",
"version": "0.1.0"
"version": "0.3.0-alpha"
}
]}
]
}
6 changes: 3 additions & 3 deletions packages/core_apps/default_app_python/manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"type": "app",
"name": "default_app_python",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
},
{
"type": "system",
"name": "ten_runtime_python",
"version": "0.1.0"
"version": "0.3.0-alpha"
}
]
}
9 changes: 5 additions & 4 deletions packages/core_apps/default_app_python/manifest.json.tent
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"type": "app",
"name": "{{package_name}}",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
},
{
"type": "system",
"name": "ten_runtime_python",
"version": "0.1.0"
"version": "0.3.0-alpha"
}
]}
]
}
4 changes: 2 additions & 2 deletions packages/core_extensions/default_extension_cpp/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "extension",
"name": "default_extension_cpp",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
}
],
"package": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "extension",
"name": "{{package_name}}_extension_cpp",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.2.0"
"version": "0.3.0-alpha"
}
],
"package": {
Expand Down
4 changes: 0 additions & 4 deletions packages/core_extensions/default_extension_go/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
// Licensed under the Apache License, Version 2.0.
// See the LICENSE file for more information.
//
// Note that this is just an example extension written in the GO programming
// language, so the package name does not equal to the containing directory
// name. However, it is not common in Go.
//

package default_extension_go

Expand Down
4 changes: 2 additions & 2 deletions packages/core_extensions/default_extension_go/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "extension",
"name": "default_extension_go",
"version": "0.1.0",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime_go",
"version": "0.1.0"
"version": "0.3.0-alpha"
}
],
"package": {
Expand Down
Loading

0 comments on commit 0d9a8b6

Please sign in to comment.