Skip to content

Commit 268c332

Browse files
authored
Merge pull request #713 from zapta/develop
Simplified the remote config file format
2 parents 2fec959 + ab5b5fd commit 268c332

File tree

9 files changed

+119
-47
lines changed

9 files changed

+119
-47
lines changed

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"files.exclude": {
3+
".tox": true,
4+
".pytest_cache": true,
5+
"**/__pycache__": true,
6+
},
27
"python.testing.pytestArgs": [
38
"test"
49
],
@@ -61,12 +66,14 @@
6166
"FGPA",
6267
"fomu",
6368
"fpgas",
69+
"fpgawars",
6470
"ftdi",
6571
"FTDIUSB",
6672
"Fumo",
6773
"GENCODE",
6874
"González",
6975
"gowin",
76+
"graphviz",
7077
"gtkwave",
7178
"helpfull",
7279
"htmlcov",
@@ -153,4 +160,4 @@
153160
"yosys",
154161
"Zadig"
155162
]
156-
}
163+
}

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
[![][apio-logo]][wiki]
1+
![][apio-logo]
22

33
[![License][license-image]][license-url]
4-
[![apio-test](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)]()
4+
[![python](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://github.com/FPGAwars/apio)
5+
[![](https://img.shields.io/badge/VS%20Code-compatible-blue?logo=visual-studio-code)](https://marketplace.visualstudio.com/items?itemName=FPGAwars.apio)
56

67
[![apio-test](https://img.shields.io/github/actions/workflow/status/fpgawars/apio/test.yaml?label=apio-test)](https://github.com/fpgawars/apio/actions/workflows/test.yaml)
78
[![apio-dev-build](https://img.shields.io/github/actions/workflow/status/fpgawars/apio-dev-builds/build-and-release.yaml?label=apio-dev-build)](https://github.com/fpgawars/apio-dev-builds/actions/workflows/build-and-release.yaml)

apio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# --------------------------------------------
1212

1313
# -- Developer: Change this number when releasing a new version
14-
VERSION = (1, 0, 1)
14+
VERSION = (1, 0, 2)
1515

1616
# -- Get the version as a string. Ex: "0.10.1"
1717
__version__ = ".".join([str(s) for s in VERSION])

apio/managers/packages.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,14 @@ def __post_init__(self):
5050

5151
def _construct_package_download_url(
5252
packages_ctx: PackagesContext,
53-
target_version: str,
5453
package_remote_config: PackageRemoteConfig,
5554
) -> str:
5655
"""Construct the download URL for the given package name and version."""
5756

58-
# -- Convert the version to "YYYY-MM-DD"
59-
# -- Move to a function in util.py.
60-
version_tokens = target_version.split(".")
61-
assert len(version_tokens) == 3, version_tokens
62-
yyyy_mm_dd = (
63-
f"{int(version_tokens[0]):04d}"
64-
+ "-"
65-
+ f"{int(version_tokens[1]):02d}"
66-
+ "-"
67-
+ f"{int(version_tokens[2]):02d}"
68-
)
69-
7057
# -- Create vars mapping.
7158
url_vars = {
7259
"${PLATFORM}": packages_ctx.platform_id,
73-
"${YYYY-MM-DD}": yyyy_mm_dd,
74-
"${YYYYMMDD}": yyyy_mm_dd.replace("-", ""),
60+
"${YYYYMMDD}": package_remote_config.release_tag.replace("-", ""),
7561
}
7662
if util.is_debug(1):
7763
cout(f"Package URL vars: {url_vars}")
@@ -91,7 +77,7 @@ def _construct_package_download_url(
9177
if util.is_debug(1):
9278
cout(f"package url parts = {url_parts}")
9379

94-
# -- Concatanate the URL parts.
80+
# -- Concatenate the URL parts.
9581
url = "".join(url_parts)
9682

9783
if util.is_debug(1):
@@ -338,7 +324,7 @@ def install_package(
338324

339325
# -- Construct the download URL.
340326
download_url = _construct_package_download_url(
341-
packages_ctx, target_version, package_config
327+
packages_ctx, package_config
342328
)
343329
if verbose:
344330
cout(f"Download URL: {download_url}")

apio/profile.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,17 @@
5050
"release": {
5151
"type": "object",
5252
"required": [
53-
"version",
54-
"release-tag",
55-
"package-file",
53+
"tag",
54+
"package",
5655
],
5756
"properties": {
58-
# -- Version
59-
"version": {
57+
# -- Tag
58+
"tag": {
6059
"type": "string",
61-
"pattern": r"^\d{4}\.\d{2}\.\d{2}$",
60+
"pattern": r"^\d{4}\-\d{2}\-\d{2}$",
6261
},
63-
# -- Release tag
64-
"release-tag": {"type": "string"},
65-
# -- Package file
66-
"package-file": {"type": "string"},
62+
# -- Package
63+
"package": {"type": "string"},
6764
},
6865
"additionalProperties": False,
6966
},
@@ -407,9 +404,9 @@ def get_package_config(
407404
package_config = self.remote_config["packages"][package_name]
408405
repo_name = package_config["repository"]["name"]
409406
repo_organization = package_config["repository"]["organization"]
410-
release_version = package_config["release"]["version"]
411-
release_tag = package_config["release"]["release-tag"]
412-
release_file = package_config["release"]["package-file"]
407+
release_tag = package_config["release"]["tag"]
408+
release_version = release_tag.replace("-", ".")
409+
release_file = package_config["release"]["package"]
413410

414411
return PackageRemoteConfig(
415412
repo_name=repo_name,

apio/resources/config.jsonc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
// The value of the remote config field here can be overridden for testing
2121
// using the env var APIO_REMOTE_CONFIG_URL, including for reading from
2222
// a local file using the "file://" protocol spec.
23+
//
24+
// For testing using the remote config at zapta:
25+
// export APIO_REMOTE_CONFIG_URL="https://github.com/zapta/apio/raw/develop/remote-config/apio-{V}.jsonc"
2326

2427
"remote-config-url": "https://github.com/fpgawars/apio/raw/develop/remote-config/apio-{V}.jsonc"
2528
}

remote-config/apio-1.0.2.jsonc

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Remote config file for Apio 1.0.2
2+
//
3+
// Supported vars (see installer.py for details):
4+
//
5+
// ${PLATFORM} - platform id (from platforms.jsonc)
6+
// ${YYYYMMDD} - the YYYY-MM_DD tag converted to YYYYMMDD
7+
//
8+
// NOTE: Github has a cache propagation of about 1 min between the
9+
// time this file is submitted and until it's available for download.
10+
{
11+
"packages": {
12+
// -- Definitions package
13+
"definitions": {
14+
"repository": {
15+
"organization": "fpgawars",
16+
"name": "apio-definitions"
17+
},
18+
"release": {
19+
"tag": "2025-10-20",
20+
"package": "apio-definitions-${YYYYMMDD}.tgz"
21+
}
22+
},
23+
// -- Examples package
24+
"examples": {
25+
"repository": {
26+
"organization": "fpgawars",
27+
"name": "apio-examples"
28+
},
29+
"release": {
30+
"tag": "2025-12-01",
31+
"package": "apio-examples-${YYYYMMDD}.tgz"
32+
}
33+
},
34+
// -- OSS Cad Suite package (Yosys)
35+
"oss-cad-suite": {
36+
"repository": {
37+
"organization": "fpgawars",
38+
"name": "tools-oss-cad-suite"
39+
},
40+
"release": {
41+
"tag": "2025-09-24",
42+
"package": "apio-oss-cad-suite-${PLATFORM}-${YYYYMMDD}.tgz"
43+
}
44+
},
45+
// -- Graphviz package
46+
"graphviz": {
47+
"repository": {
48+
"organization": "fpgawars",
49+
"name": "tools-graphviz"
50+
},
51+
"release": {
52+
"tag": "2025-06-13",
53+
"package": "apio-graphviz-${PLATFORM}-${YYYYMMDD}.tgz"
54+
}
55+
},
56+
// -- Verible package
57+
"verible": {
58+
"repository": {
59+
"organization": "fpgawars",
60+
"name": "tools-verible"
61+
},
62+
"release": {
63+
"tag": "2025-06-13",
64+
"package": "apio-verible-${PLATFORM}-${YYYYMMDD}.tgz"
65+
}
66+
},
67+
// -- Drivers package
68+
"drivers": {
69+
"repository": {
70+
"organization": "fpgawars",
71+
"name": "tools-drivers"
72+
},
73+
"release": {
74+
"tag": "2025-06-13",
75+
"package": "apio-drivers-${PLATFORM}-${YYYYMMDD}.tgz"
76+
}
77+
}
78+
}
79+
}

scripts/genereate-repo-cleaner.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ delete_tag() {
3838
gh api --method DELETE "/repos/\$REPO/git/refs/tags/\$tag" --silent 2>/dev/null || echo " → Tag already gone or not found"
3939
}
4040
41+
delete_release_and_tag() {
42+
local tag="\$1"
43+
delete_release "\$tag"
44+
delete_tag "\$tag"
45+
}
46+
4147
echo "DRY RUN — No deletions will happen until you uncomment the lines below"
42-
echo "Repo: \$REPO"
48+
echo "Repo: $REPO"
4349
echo "========================================================================"
4450
echo
4551
echo "# 1. Releases + their tags (release first, then tag)"
@@ -52,7 +58,7 @@ gh release list --repo "$REPO" --limit 1000 --json tagName -q '.[].tagName' |
5258
sort -V |
5359
while read -r tag; do
5460
[[ -n "$tag" ]] || continue
55-
echo "# delete_release \"$tag\"; delete_tag \"$tag\""
61+
echo "# delete_release_and_tag \"$tag\""
5662
done
5763

5864
# Step 2: All tags that are NOT attached to any release
@@ -69,7 +75,7 @@ comm -23 \
6975
<(gh api "repos/$REPO/tags?per_page=100" --paginate --jq '.[].name' | sort -u) \
7076
<(gh release list --repo "$REPO" --limit 1000 --json tagName -q '.[].tagName' | sort -u) |
7177
while read -r tag; do
72-
[[ -n "$tag" ]] && echo "# delete_tag \"$tag\""
78+
[[ -n "$tag" ]] && echo "# delete_tag \"$tag\""
7379
done
7480

7581
cat <<'EOF'

tests/unit_tests/test_profile.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
)
2020

2121

22-
def get_remote_config_url(apio_ctx: ApioContext) -> str:
23-
"""Returns a test remote config URL."""
24-
url = apio_ctx.config["remote-config-url"]
25-
url = url.replace("{V}", util.get_apio_version())
26-
return url
27-
28-
2922
def get_test_data(
3023
apio_ctx: ApioContext,
3124
loaded_by_apio_version: str,
@@ -43,7 +36,7 @@ def get_test_data(
4336
"metadata": {
4437
"loaded-at": loaded_at_stamp,
4538
"loaded-by": loaded_by_apio_version,
46-
"loaded-from": get_remote_config_url(apio_ctx),
39+
"loaded-from": apio_ctx.profile.remote_config_url,
4740
},
4841
"packages": {
4942
"drivers": {
@@ -103,7 +96,7 @@ def test_profile_loading_config_ok(apio_runner: ApioRunner):
10396
profile = Profile(
10497
sb.home_dir,
10598
sb.packages_dir,
106-
get_remote_config_url(apio_ctx),
99+
apio_ctx.profile.remote_config_url,
107100
5, # TTL in days
108101
60, # Remote config retry mins.
109102
RemoteConfigPolicy.CACHED_OK,
@@ -146,7 +139,7 @@ def test_profile_loading_config_stale_version(apio_runner: ApioRunner):
146139
profile = Profile(
147140
sb.home_dir,
148141
sb.packages_dir,
149-
get_remote_config_url(apio_ctx),
142+
apio_ctx.profile.remote_config_url,
150143
5, # TTL in days
151144
60, # Remote config retry mins.
152145
RemoteConfigPolicy.CACHED_OK,

0 commit comments

Comments
 (0)