release: bump version to 0.84.2
This commit is contained in:
1 parent
5e6352f524
commit
30b44ec00d
77 files changed
+3312
-1039
No files matched your search
@@ -107,6 +107,8 @@ function readRepoText(relativePath) {
|
||||
return readFileSync(new URL(`../../${relativePath}`, import.meta.url), 'utf8')
|
||||
}
|
||||
|
||||
const smokeAppVersion = readRepoText('VERSION').trim() || '0.0.0'
|
||||
|
||||
function extractBalanced(text, start, openChar, closeChar) {
|
||||
let depth = 0
|
||||
let quote = null
|
||||
@@ -932,8 +934,14 @@ function tokenResponse() {
|
||||
})
|
||||
}
|
||||
|
||||
function apiPayloadFor(requestUrl, method) {
|
||||
// Single opaque RGB (128, 0, 0) pixel encodes sea level in Terrarium.
|
||||
const smokeTerrainPng = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNoYGAAAAGEAIH5/mWIAAAAAElFTkSuQmCC'
|
||||
|
||||
function apiPayloadFor(requestUrl, method, postData) {
|
||||
const url = new URL(requestUrl)
|
||||
if (method === 'GET' && url.pathname === '/api/health') {
|
||||
return jsonResponse({ status: 'healthy', version: smokeAppVersion })
|
||||
}
|
||||
const path = url.pathname.replace(/^\/api\/v1/, '') || '/'
|
||||
|
||||
if (method === 'GET' && earthGeoJsonPaths.has(path)) {
|
||||
@@ -1546,6 +1554,19 @@ function apiPayloadFor(requestUrl, method) {
|
||||
if (method === 'DELETE' && /^\/earth\/tiles\/[a-z0-9_]+\/cache$/.test(path)) {
|
||||
return jsonResponse({ removed_files: 5 })
|
||||
}
|
||||
if (method === 'POST' && path === '/visualization/terrain/terrarium/batch') {
|
||||
const { tiles } = JSON.parse(postData ?? '{}')
|
||||
if (!Array.isArray(tiles) || tiles.length === 0) {
|
||||
return jsonResponse({ detail: 'Expected terrain tile coordinates' }, 422)
|
||||
}
|
||||
return jsonResponse({
|
||||
tiles: tiles.map(({ z, x, y }) => ({ z, x, y, content_type: 'image/png', data: smokeTerrainPng })),
|
||||
errors: [],
|
||||
})
|
||||
}
|
||||
if (method === 'GET' && /^\/visualization\/terrain\/terrarium\/\d+\/\d+\/\d+\.png$/.test(path)) {
|
||||
return { status: 200, contentType: 'image/png', body: Buffer.from(smokeTerrainPng, 'base64') }
|
||||
}
|
||||
if (path === '/earth/wind/meta') {
|
||||
return jsonResponse({
|
||||
available: true,
|
||||
@@ -1921,7 +1942,8 @@ function apiPayloadFor(requestUrl, method) {
|
||||
|
||||
async function installApiMocks(context) {
|
||||
await context.route('**/api/**', async (route) => {
|
||||
const response = apiPayloadFor(route.request().url(), route.request().method())
|
||||
const request = route.request()
|
||||
const response = apiPayloadFor(request.url(), request.method(), request.postData())
|
||||
await route.fulfill(response)
|
||||
})
|
||||
}
|
||||
@@ -3141,7 +3163,7 @@ async function main() {
|
||||
&& !english.classList.contains('is-active')
|
||||
&& getComputedStyle(segmented).getPropertyValue('--active-index').trim() === '0'
|
||||
)
|
||||
}, null, { timeout: 5000 })
|
||||
}, null, { polling: 100, timeout: SMOKE_RENDER_TIMEOUT_MS })
|
||||
const zhSystemText = await earthFrame.evaluate(() => (
|
||||
document.querySelector('.earth-settings-sheet [data-settings-tab-panel="system"]')?.innerText || ''
|
||||
))
|
||||
@@ -3164,7 +3186,7 @@ async function main() {
|
||||
&& !chinese.classList.contains('is-active')
|
||||
&& getComputedStyle(segmented).getPropertyValue('--active-index').trim() === '1'
|
||||
)
|
||||
}, null, { timeout: 5000 })
|
||||
}, null, { polling: 100, timeout: SMOKE_RENDER_TIMEOUT_MS })
|
||||
const hdTextureStatus = await earthFrame.evaluate(async () => {
|
||||
const { earthMessage, formatEarthMessage } = await import('/earth/js/i18n.js?frontend_smoke_i18n')
|
||||
const ui = await import('/earth/js/ui.js?frontend_smoke_i18n')
|
||||
@@ -3383,7 +3405,7 @@ async function main() {
|
||||
const ui = await import('/earth/js/ui.js')
|
||||
ui.setLoading(false)
|
||||
ui.showStatusMessage('成功加载 12 条电缆', 'success')
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 360))
|
||||
// Read the temporary toast before a startup notification can replace it.
|
||||
const status = document.getElementById('status-message')
|
||||
const brand = document.getElementById('brand-panel')
|
||||
const ticker = document.getElementById('desktop-news-ticker')
|
||||
@@ -3396,7 +3418,7 @@ async function main() {
|
||||
stacked: status?.classList.contains('earth-status-message--ticker-stack') === true,
|
||||
left: rect?.left || 0,
|
||||
right: rect?.right || 0,
|
||||
top: rect?.top || 0,
|
||||
top: status?.offsetTop || 0,
|
||||
brandRight: brandRect?.right || 0,
|
||||
tickerLeft: tickerRect?.left || 0,
|
||||
tickerTop: tickerRect?.top || 0,
|
||||
@@ -3408,9 +3430,8 @@ async function main() {
|
||||
status.style.minWidth = '260px'
|
||||
window.dispatchEvent(new Event('resize'))
|
||||
}
|
||||
const stackedRect = status?.getBoundingClientRect()
|
||||
const stackedWhenConstrained = status?.classList.contains('earth-status-message--ticker-stack') === true
|
||||
const stackedTop = stackedRect?.top || 0
|
||||
const stackedTop = status?.offsetTop || 0
|
||||
if (status instanceof HTMLElement) {
|
||||
status.style.minWidth = ''
|
||||
window.dispatchEvent(new Event('resize'))
|
||||
|
||||
@@ -473,7 +473,7 @@ class ScopedReleaseTests(unittest.TestCase):
|
||||
self.assertEqual(rc, 0)
|
||||
stdout = out.getvalue()
|
||||
self.assertIn("scope_client_mode: hotfix", stdout)
|
||||
self.assertIn("gitea_release: create", stdout)
|
||||
self.assertIn("gitea_release: skip", stdout)
|
||||
self.assertIn("assets_count: 1", stdout)
|
||||
self.assertIn("planet-earth-bundle-0.80.1.tar.gz", stdout)
|
||||
self.assertNotIn("Planet-0.80.1.exe", stdout)
|
||||
@@ -515,6 +515,236 @@ class ScopedReleaseTests(unittest.TestCase):
|
||||
pub_mock.assert_not_called()
|
||||
self.assertIn("skipped Gitea Release: no client update", out.getvalue())
|
||||
|
||||
def test_release_publish_hotfix_skips_gitea_release(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
manifest = {
|
||||
"schema_version": 1,
|
||||
"tag": "v0.84.2",
|
||||
"commit": "a" * 40,
|
||||
"previous_tag": "v0.84.0",
|
||||
"components": ["earth-hotfix"],
|
||||
"changed_services": [],
|
||||
"services": {
|
||||
k: f"gitea.rclaw.top/linkong/planet/{k}:v0.84.0@sha256:{'1' * 64}"
|
||||
for k in registry.SERVICES
|
||||
},
|
||||
"client": {
|
||||
"mode": "hotfix",
|
||||
"shell_version": "0.84.0",
|
||||
"min_shell_version": "0.84.0",
|
||||
"bundle": "planet-earth-bundle-0.84.2.tar.gz",
|
||||
"bundle_sha256": "a" * 64,
|
||||
"bundle_storage": "oci",
|
||||
},
|
||||
}
|
||||
(root / registry.MANIFEST_NAME).write_text(json.dumps(manifest))
|
||||
changelog = root / "CHANGELOG.md"
|
||||
changelog.write_text("# Changelog\n")
|
||||
|
||||
@contextmanager
|
||||
def fake_prepare(*_args, **_kwargs):
|
||||
yield root, changelog
|
||||
|
||||
out = io.StringIO()
|
||||
with (
|
||||
patch.object(
|
||||
publish,
|
||||
"run_git_origin_url",
|
||||
return_value="https://gitea.rclaw.top/linkong/planet.git",
|
||||
),
|
||||
patch.object(publish, "git_credential_authorization", return_value="token test"),
|
||||
patch.object(publish, "api_request", return_value=(404, None)),
|
||||
patch.object(publisher, "prepare", side_effect=fake_prepare),
|
||||
patch.object(publish, "publish_release") as pub_mock,
|
||||
redirect_stdout(out),
|
||||
):
|
||||
rc = publish.main(["--tag", "v0.84.2", "--scope", "hotfix", "--use-git-credential"])
|
||||
self.assertEqual(rc, 0)
|
||||
pub_mock.assert_not_called()
|
||||
self.assertIn("skipped Gitea Release to preserve /releases/latest", out.getvalue())
|
||||
|
||||
def test_resolve_release_bundle_oci_extracts_and_verifies_bundle_and_notes(self):
|
||||
tag = "v1.1.0"
|
||||
commit = "f" * 40
|
||||
bundle_name = "planet-earth-bundle-1.1.0.tar.gz"
|
||||
bundle_data = hotfix(tag)
|
||||
bundle_sha = hashlib.sha256(bundle_data).hexdigest()
|
||||
|
||||
layer_buf = io.BytesIO()
|
||||
with tarfile.open(fileobj=layer_buf, mode="w:gz") as layer_tar:
|
||||
for name, content in {
|
||||
bundle_name: bundle_data,
|
||||
registry.RELEASE_NOTES_NAME: b"## 1.1.0\n\n- Fixed cloud shader",
|
||||
}.items():
|
||||
info = tarfile.TarInfo(name)
|
||||
info.size = len(content)
|
||||
layer_tar.addfile(info, io.BytesIO(content))
|
||||
layer_bytes = layer_buf.getvalue()
|
||||
layer_digest = registry.digest(layer_bytes)
|
||||
|
||||
cfg = json.dumps(
|
||||
{
|
||||
"os": "linux",
|
||||
"architecture": "amd64",
|
||||
"config": {"Labels": {"org.opencontainers.image.revision": commit}},
|
||||
}
|
||||
).encode()
|
||||
oci_manifest = json.dumps(
|
||||
{
|
||||
"config": {"digest": registry.digest(cfg)},
|
||||
"layers": [{"digest": layer_digest}],
|
||||
}
|
||||
).encode()
|
||||
release_manifest = {
|
||||
"schema_version": 1,
|
||||
"tag": tag,
|
||||
"commit": commit,
|
||||
"services": {
|
||||
k: f"gitea.rclaw.top/linkong/planet/{k}:v1.0.0@sha256:{'1' * 64}"
|
||||
for k in registry.SERVICES
|
||||
},
|
||||
"client": {
|
||||
"mode": "hotfix",
|
||||
"shell_version": "1.0.0",
|
||||
"min_shell_version": "1.0.0",
|
||||
"bundle": bundle_name,
|
||||
"bundle_sha256": bundle_sha,
|
||||
"bundle_storage": "oci",
|
||||
},
|
||||
}
|
||||
|
||||
with patch.object(
|
||||
registry,
|
||||
"read_url",
|
||||
side_effect=[b'{"token":"read"}', oci_manifest, cfg, layer_bytes],
|
||||
):
|
||||
name, data, sha, notes = registry.resolve_release_bundle_oci(tag, commit, release_manifest)
|
||||
self.assertEqual(name, bundle_name)
|
||||
self.assertEqual(data, bundle_data)
|
||||
self.assertEqual(sha, bundle_sha)
|
||||
self.assertIn("Fixed cloud shader", notes)
|
||||
|
||||
bad_manifest = {
|
||||
**release_manifest,
|
||||
"client": {**release_manifest["client"], "bundle_sha256": "0" * 64},
|
||||
}
|
||||
with (
|
||||
patch.object(
|
||||
registry,
|
||||
"read_url",
|
||||
side_effect=[b'{"token":"read"}', oci_manifest, cfg, layer_bytes],
|
||||
),
|
||||
self.assertRaisesRegex(ValueError, "SHA-256"),
|
||||
):
|
||||
registry.resolve_release_bundle_oci(tag, commit, bad_manifest)
|
||||
|
||||
empty_buf = io.BytesIO()
|
||||
with tarfile.open(fileobj=empty_buf, mode="w:gz") as empty_tar:
|
||||
info = tarfile.TarInfo("release-manifest.json")
|
||||
info.size = 2
|
||||
empty_tar.addfile(info, io.BytesIO(b"{}"))
|
||||
empty_layer = empty_buf.getvalue()
|
||||
empty_oci = json.dumps(
|
||||
{
|
||||
"config": {"digest": registry.digest(cfg)},
|
||||
"layers": [{"digest": registry.digest(empty_layer)}],
|
||||
}
|
||||
).encode()
|
||||
with patch.object(
|
||||
registry,
|
||||
"read_url",
|
||||
side_effect=[b'{"token":"read"}', empty_oci, cfg, empty_layer],
|
||||
):
|
||||
self.assertIsNone(registry.resolve_release_bundle_oci(tag, commit, release_manifest))
|
||||
|
||||
def test_deploy_discovers_and_rolls_out_oci_hotfix_without_gitea_release(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
base = Path(temp)
|
||||
host = deploy.Host(base / "host", base / "settings", base / "state")
|
||||
host.state.mkdir()
|
||||
(host.directory("v1.0.0")).mkdir(parents=True)
|
||||
for name in deploy.HOST_FILES:
|
||||
(host.directory("v1.0.0") / name).write_text("host-managed")
|
||||
deploy.point_current(host, "v1.0.0")
|
||||
|
||||
old_refs = {
|
||||
"aiprovider": f"gitea.rclaw.top/linkong/planet/aiprovider:v1.0.0@sha256:{'1' * 64}",
|
||||
"backend": f"gitea.rclaw.top/linkong/planet/backend:v1.0.0@sha256:{'2' * 64}",
|
||||
"admin": f"gitea.rclaw.top/linkong/planet/admin:v1.0.0@sha256:{'3' * 64}",
|
||||
}
|
||||
bundle_name = "planet-earth-bundle-1.1.0.tar.gz"
|
||||
bundle_data = hotfix("v1.1.0")
|
||||
bundle_sha = hashlib.sha256(bundle_data).hexdigest()
|
||||
manifest = {
|
||||
"schema_version": 1,
|
||||
"tag": "v1.1.0",
|
||||
"commit": "f" * 40,
|
||||
"previous_tag": "v1.0.0",
|
||||
"components": ["earth-hotfix"],
|
||||
"changed_services": [],
|
||||
"services": old_refs,
|
||||
"client": {
|
||||
"mode": "hotfix",
|
||||
"shell_version": "1.0.0",
|
||||
"min_shell_version": "1.0.0",
|
||||
"bundle": bundle_name,
|
||||
"bundle_sha256": bundle_sha,
|
||||
"bundle_storage": "oci",
|
||||
},
|
||||
}
|
||||
host.env.write_text(
|
||||
"\n".join(
|
||||
[f"{registry.SERVICES[k]}={v}" for k, v in old_refs.items()]
|
||||
+ ["CLIENT_UPDATE_PUBLISH_TOKEN=tok"]
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
live_manifest = base / "manifest.json"
|
||||
live_manifest.write_bytes(b"{}")
|
||||
tags_payload = json.dumps(
|
||||
[
|
||||
{"name": "v1.1.0", "commit": {"sha": "f" * 40}},
|
||||
{"name": "v1.0.0", "commit": {"sha": "a" * 40}},
|
||||
]
|
||||
).encode()
|
||||
|
||||
with (
|
||||
patch.object(deploy, "read_url", return_value=tags_payload),
|
||||
patch.object(deploy, "resolve_release_manifest_oci", return_value=manifest),
|
||||
patch.object(deploy, "release_by_tag") as release_by_tag_mock,
|
||||
patch.object(deploy, "resolved_images", return_value=old_refs),
|
||||
patch.object(
|
||||
deploy,
|
||||
"resolve_release_bundle_oci",
|
||||
return_value=(bundle_name, bundle_data, bundle_sha, "OCI notes"),
|
||||
),
|
||||
patch.object(deploy, "inspect", side_effect=lambda name: {"Config": {"Image": old_refs[name]}, "State": {"Health": {"Status": "healthy"}}}),
|
||||
patch.object(deploy, "data_containers", return_value={"postgres": "same", "redis": "same"}),
|
||||
patch.object(deploy, "live_manifest_path", return_value=live_manifest),
|
||||
patch.object(deploy, "docker") as docker_mock,
|
||||
patch.object(deploy, "backup_database", side_effect=lambda p: p.write_bytes(b"ok")),
|
||||
patch.object(deploy, "rollout_services") as rollout_mock,
|
||||
patch.object(deploy, "check_routes"),
|
||||
patch.object(deploy, "publish_hotfix_bundle") as hotfix_mock,
|
||||
patch.object(deploy, "check_hotfix") as check_hotfix_mock,
|
||||
):
|
||||
deploy.reconcile(host)
|
||||
deploy.reconcile(host, check=True)
|
||||
|
||||
self.assertEqual(host.current(), "v1.1.0")
|
||||
release_by_tag_mock.assert_not_called()
|
||||
docker_mock.assert_not_called()
|
||||
rollout_mock.assert_not_called()
|
||||
self.assertEqual(hotfix_mock.call_args.kwargs["notes"], "OCI notes")
|
||||
self.assertEqual(hotfix_mock.call_args.kwargs["shell_version"], "1.0.0")
|
||||
self.assertEqual(
|
||||
hotfix_mock.call_args.kwargs["release_html_url"],
|
||||
"https://gitea.rclaw.top/linkong/planet/releases/tag/v1.0.0",
|
||||
)
|
||||
self.assertEqual(check_hotfix_mock.call_count, 2)
|
||||
check_hotfix_mock.assert_called_with("v1.1.0", bundle_sha, shell_version="1.0.0")
|
||||
|
||||
def test_deploy_discovers_server_only_release_from_tags_and_oci_without_gitea_release(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
base = Path(temp)
|
||||
|
||||
Reference in new issue
Block a user