feat(release,ui): accelerate pulse rendering and automate Homebrew tap publishing
- add cached pulse metrics keyed by context/namespace/store revision to avoid recomputing heavy counts on every frame - wire render loop to consume cached pulse metrics and invalidate only when underlying store revision changes - add regression test for pulse cache reuse/invalidation behavior - improve release workflow with manual dispatch support, deterministic tag/version resolution, checksum artifact generation, and idempotent release asset publishing - add Homebrew tap sync workflow that generates and pushes Formula/krust.rb from release SHA256SUMS - add formula generator script for macOS arm64/amd64 and linux amd64 release tarballs - update README Homebrew install flow to short tap syntax and ignore .idea in repo
This commit is contained in:
1 parent
57c8a73591
commit
08a75daf23
7 files changed
+399
-19
No files matched your search
@@ -0,0 +1,104 @@
|
||||
name: Homebrew Tap Sync
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release tag to sync (for example: v0.1.0)"
|
||||
required: true
|
||||
type: string
|
||||
tap_repo:
|
||||
description: "Tap repo (owner/name), defaults to ErfanY/homebrew-krust"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: homebrew-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
name: Update tap formula
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Resolve release metadata
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
if [[ -z "${TAG}" ]]; then
|
||||
TAG="${{ github.event.release.tag_name }}"
|
||||
fi
|
||||
if [[ -z "${TAG}" ]]; then
|
||||
echo "Unable to resolve release tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
VERSION="${TAG#v}"
|
||||
TAP_REPO="${{ github.event.inputs.tap_repo }}"
|
||||
if [[ -z "${TAP_REPO}" ]]; then
|
||||
TAP_REPO="ErfanY/homebrew-krust"
|
||||
fi
|
||||
echo "tag=${TAG}" >> "${GITHUB_OUTPUT}"
|
||||
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
||||
echo "tap_repo=${TAP_REPO}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Download SHA256SUMS from release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p dist
|
||||
gh release download "${{ steps.meta.outputs.tag }}" \
|
||||
--repo "${{ github.repository }}" \
|
||||
--pattern "SHA256SUMS" \
|
||||
--dir dist
|
||||
|
||||
- name: Generate formula
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
scripts/release/generate_homebrew_formula.sh \
|
||||
--version "${{ steps.meta.outputs.version }}" \
|
||||
--checksums dist/SHA256SUMS \
|
||||
--output dist/krust.rb
|
||||
|
||||
- name: Push formula to tap
|
||||
env:
|
||||
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
|
||||
VERSION: ${{ steps.meta.outputs.version }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [[ -z "${TAP_TOKEN}" ]]; then
|
||||
echo "Missing HOMEBREW_TAP_GITHUB_TOKEN secret" >&2
|
||||
exit 1
|
||||
fi
|
||||
TAP_REPO="${{ steps.meta.outputs.tap_repo }}"
|
||||
git clone "https://x-access-token:${TAP_TOKEN}@github.com/${TAP_REPO}.git" tap
|
||||
mkdir -p tap/Formula
|
||||
cp dist/krust.rb tap/Formula/krust.rb
|
||||
|
||||
cd tap
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
if git diff --quiet -- Formula/krust.rb; then
|
||||
echo "No tap update required"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git add Formula/krust.rb
|
||||
git commit -m "krust ${VERSION}"
|
||||
git push
|
||||
@@ -4,6 +4,13 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- '*.*.*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Tag name to publish (for example: v0.1.0)"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -67,6 +74,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download packaged artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
@@ -74,8 +84,44 @@ jobs:
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: Create release and upload artifacts
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: dist/*.tar.gz
|
||||
generate_release_notes: true
|
||||
- name: Resolve release tag/version
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
if [[ -z "${TAG}" ]]; then
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
fi
|
||||
VERSION="${TAG#v}"
|
||||
echo "tag=${TAG}" >> "${GITHUB_OUTPUT}"
|
||||
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Generate SHA256SUMS
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd dist
|
||||
shasum -a 256 *.tar.gz > SHA256SUMS
|
||||
|
||||
- name: Generate Homebrew formula
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
scripts/release/generate_homebrew_formula.sh \
|
||||
--version "${{ steps.meta.outputs.version }}" \
|
||||
--checksums dist/SHA256SUMS \
|
||||
--output dist/krust.rb
|
||||
|
||||
- name: Create or update release and upload assets
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="${{ steps.meta.outputs.tag }}"
|
||||
if gh release view "${TAG}" >/dev/null 2>&1; then
|
||||
gh release upload "${TAG}" dist/*.tar.gz dist/SHA256SUMS dist/krust.rb --clobber
|
||||
else
|
||||
gh release create "${TAG}" dist/*.tar.gz dist/SHA256SUMS dist/krust.rb --generate-notes --title "${TAG}"
|
||||
fi
|
||||
+1
-1
@@ -18,7 +18,7 @@ target
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
.idea/
|
||||
|
||||
|
||||
# Added by cargo
|
||||
|
||||
@@ -84,6 +84,13 @@ sudo install krust-x86_64-unknown-linux-gnu/krust /usr/local/bin/krust
|
||||
cargo install --git https://github.com/ErfanY/krust.git --locked krust
|
||||
```
|
||||
|
||||
### Homebrew (tap-based)
|
||||
|
||||
```bash
|
||||
brew tap ErfanY/krust
|
||||
brew install krust
|
||||
```
|
||||
|
||||
### Build locally
|
||||
|
||||
```bash
|
||||
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/release/generate_homebrew_formula.sh \
|
||||
--version <version> \
|
||||
--checksums <SHA256SUMS path> \
|
||||
--output <output formula path>
|
||||
|
||||
Example:
|
||||
scripts/release/generate_homebrew_formula.sh \
|
||||
--version 0.1.0 \
|
||||
--checksums dist/SHA256SUMS \
|
||||
--output dist/krust.rb
|
||||
EOF
|
||||
}
|
||||
|
||||
VERSION=""
|
||||
CHECKSUMS=""
|
||||
OUTPUT=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--version)
|
||||
VERSION="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--checksums)
|
||||
CHECKSUMS="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--output)
|
||||
OUTPUT="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "${VERSION}" || -z "${CHECKSUMS}" || -z "${OUTPUT}" ]]; then
|
||||
echo "missing required arguments" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "${CHECKSUMS}" ]]; then
|
||||
echo "checksums file not found: ${CHECKSUMS}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sum_for() {
|
||||
local filename="$1"
|
||||
local sum
|
||||
sum="$(awk -v f="${filename}" '$2 == f {print $1}' "${CHECKSUMS}" | head -n1)"
|
||||
if [[ -z "${sum}" ]]; then
|
||||
echo "missing checksum for ${filename}" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "${sum}"
|
||||
}
|
||||
|
||||
DARWIN_ARM64_TGZ="krust-aarch64-apple-darwin.tar.gz"
|
||||
DARWIN_AMD64_TGZ="krust-x86_64-apple-darwin.tar.gz"
|
||||
LINUX_AMD64_TGZ="krust-x86_64-unknown-linux-gnu.tar.gz"
|
||||
|
||||
DARWIN_ARM64_SHA="$(sum_for "${DARWIN_ARM64_TGZ}")"
|
||||
DARWIN_AMD64_SHA="$(sum_for "${DARWIN_AMD64_TGZ}")"
|
||||
LINUX_AMD64_SHA="$(sum_for "${LINUX_AMD64_TGZ}")"
|
||||
|
||||
mkdir -p "$(dirname "${OUTPUT}")"
|
||||
cat > "${OUTPUT}" <<EOF
|
||||
class Krust < Formula
|
||||
desc "Latency-first Kubernetes terminal navigator"
|
||||
homepage "https://github.com/ErfanY/krust"
|
||||
version "${VERSION}"
|
||||
license "MIT"
|
||||
|
||||
on_macos do
|
||||
if Hardware::CPU.arm?
|
||||
url "https://github.com/ErfanY/krust/releases/download/v#{version}/${DARWIN_ARM64_TGZ}"
|
||||
sha256 "${DARWIN_ARM64_SHA}"
|
||||
else
|
||||
url "https://github.com/ErfanY/krust/releases/download/v#{version}/${DARWIN_AMD64_TGZ}"
|
||||
sha256 "${DARWIN_AMD64_SHA}"
|
||||
end
|
||||
end
|
||||
|
||||
on_linux do
|
||||
url "https://github.com/ErfanY/krust/releases/download/v#{version}/${LINUX_AMD64_TGZ}"
|
||||
sha256 "${LINUX_AMD64_SHA}"
|
||||
end
|
||||
|
||||
def install
|
||||
bin.install "krust"
|
||||
end
|
||||
|
||||
test do
|
||||
assert_match "krust", shell_output("#{bin}/krust --help")
|
||||
end
|
||||
end
|
||||
EOF
|
||||
+108
@@ -302,6 +302,7 @@ struct App {
|
||||
readonly: bool,
|
||||
theme: UiTheme,
|
||||
color_support: ColorSupport,
|
||||
pulse_metrics_cache: Option<CachedPulseMetrics>,
|
||||
pulse_snapshot: Option<PulseSnapshot>,
|
||||
pulse_last_change_at: Instant,
|
||||
pulse_last_revision: u64,
|
||||
@@ -348,6 +349,33 @@ struct PulseSnapshot {
|
||||
failed: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
struct PulseMetrics {
|
||||
running: usize,
|
||||
pending: usize,
|
||||
failed: usize,
|
||||
other: usize,
|
||||
scope_pods: PodResourceTotals,
|
||||
cluster_pods: PodResourceTotals,
|
||||
node_caps: NodeCapacityTotals,
|
||||
deployments: usize,
|
||||
replicasets: usize,
|
||||
statefulsets: usize,
|
||||
daemonsets: usize,
|
||||
services: usize,
|
||||
ingresses: usize,
|
||||
jobs: usize,
|
||||
cronjobs: usize,
|
||||
pods: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct CachedPulseMetrics {
|
||||
key: UtilScopeKey,
|
||||
revision: u64,
|
||||
metrics: PulseMetrics,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
struct CachedPodTotals {
|
||||
totals: PodResourceTotals,
|
||||
@@ -604,6 +632,49 @@ impl App {
|
||||
(running, pending, failed, other)
|
||||
}
|
||||
|
||||
fn pulse_metrics_for_tab(&mut self, tab: &ContextTabState) -> PulseMetrics {
|
||||
let cache_key = UtilScopeKey {
|
||||
context: tab.context.clone(),
|
||||
namespace: tab.namespace.clone(),
|
||||
};
|
||||
let revision = self.store.revision();
|
||||
if let Some(cached) = &self.pulse_metrics_cache
|
||||
&& cached.revision == revision
|
||||
&& cached.key == cache_key
|
||||
{
|
||||
return cached.metrics;
|
||||
}
|
||||
|
||||
let (running, pending, failed, other) = self.pod_phase_counts_for_tab(tab);
|
||||
let scope_pods = self.pod_resource_totals(&tab.context, tab.namespace.as_deref());
|
||||
let cluster_pods = self.pod_resource_totals(&tab.context, None);
|
||||
let node_caps = self.node_capacity_totals(&tab.context);
|
||||
let metrics = PulseMetrics {
|
||||
running,
|
||||
pending,
|
||||
failed,
|
||||
other,
|
||||
scope_pods,
|
||||
cluster_pods,
|
||||
node_caps,
|
||||
deployments: self.count_kind_for_tab(tab, ResourceKind::Deployments),
|
||||
replicasets: self.count_kind_for_tab(tab, ResourceKind::ReplicaSets),
|
||||
statefulsets: self.count_kind_for_tab(tab, ResourceKind::StatefulSets),
|
||||
daemonsets: self.count_kind_for_tab(tab, ResourceKind::DaemonSets),
|
||||
services: self.count_kind_for_tab(tab, ResourceKind::Services),
|
||||
ingresses: self.count_kind_for_tab(tab, ResourceKind::Ingresses),
|
||||
jobs: self.count_kind_for_tab(tab, ResourceKind::Jobs),
|
||||
cronjobs: self.count_kind_for_tab(tab, ResourceKind::CronJobs),
|
||||
pods: self.count_kind_for_tab(tab, ResourceKind::Pods),
|
||||
};
|
||||
self.pulse_metrics_cache = Some(CachedPulseMetrics {
|
||||
key: cache_key,
|
||||
revision,
|
||||
metrics,
|
||||
});
|
||||
metrics
|
||||
}
|
||||
|
||||
fn active_filter_value(&self) -> String {
|
||||
if let Some(overlay) = &self.overlay {
|
||||
match overlay {
|
||||
@@ -757,6 +828,7 @@ impl App {
|
||||
readonly,
|
||||
theme: ui_theme_for(color_support),
|
||||
color_support,
|
||||
pulse_metrics_cache: None,
|
||||
pulse_snapshot: None,
|
||||
pulse_last_change_at: now,
|
||||
pulse_last_revision: 0,
|
||||
@@ -2665,6 +2737,42 @@ mod tests {
|
||||
let _ = ui_theme_for(ColorSupport::TrueColor);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pulse_metrics_cache_reuses_revision_and_invalidates_on_store_change() {
|
||||
let mut app = test_app();
|
||||
app.store.apply(StateDelta::Upsert(mk_entity(
|
||||
"ctx-dev",
|
||||
ResourceKind::Pods,
|
||||
Some("default"),
|
||||
"pod-a",
|
||||
"Running",
|
||||
)));
|
||||
let tab = app.current_tab().clone();
|
||||
let first = app.pulse_metrics_for_tab(&tab);
|
||||
assert_eq!(first.pods, 1);
|
||||
|
||||
{
|
||||
let cache = app
|
||||
.pulse_metrics_cache
|
||||
.as_mut()
|
||||
.expect("pulse metrics cache after first compute");
|
||||
cache.metrics.pods = 777;
|
||||
}
|
||||
|
||||
let cached = app.pulse_metrics_for_tab(&tab);
|
||||
assert_eq!(cached.pods, 777);
|
||||
|
||||
app.store.apply(StateDelta::Upsert(mk_entity(
|
||||
"ctx-dev",
|
||||
ResourceKind::Pods,
|
||||
Some("default"),
|
||||
"pod-b",
|
||||
"Running",
|
||||
)));
|
||||
let recomputed = app.pulse_metrics_for_tab(&tab);
|
||||
assert_eq!(recomputed.pods, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_table_pane_has_light_icons_and_status_tags() {
|
||||
let mut app = test_app();
|
||||
|
||||
+17
-13
@@ -84,22 +84,26 @@ impl App {
|
||||
));
|
||||
}
|
||||
|
||||
let (running, pending, failed, _other) = self.pod_phase_counts_for_tab(&active);
|
||||
let scope_pods = self.pod_resource_totals(&active.context, active.namespace.as_deref());
|
||||
let cluster_pods = self.pod_resource_totals(&active.context, None);
|
||||
let node_caps = self.node_capacity_totals(&active.context);
|
||||
let pulse_metrics = self.pulse_metrics_for_tab(&active);
|
||||
let running = pulse_metrics.running;
|
||||
let pending = pulse_metrics.pending;
|
||||
let failed = pulse_metrics.failed;
|
||||
let _other = pulse_metrics.other;
|
||||
let scope_pods = pulse_metrics.scope_pods;
|
||||
let cluster_pods = pulse_metrics.cluster_pods;
|
||||
let node_caps = pulse_metrics.node_caps;
|
||||
let cpu_pct = percent(cluster_pods.cpu_request_m, node_caps.cpu_alloc_m);
|
||||
let mem_pct = percent(cluster_pods.mem_request_b, node_caps.mem_alloc_b);
|
||||
let pod_pct = percent(cluster_pods.pods as u64, node_caps.pod_alloc);
|
||||
let deployments = self.count_kind_for_tab(&active, ResourceKind::Deployments);
|
||||
let replicasets = self.count_kind_for_tab(&active, ResourceKind::ReplicaSets);
|
||||
let statefulsets = self.count_kind_for_tab(&active, ResourceKind::StatefulSets);
|
||||
let daemonsets = self.count_kind_for_tab(&active, ResourceKind::DaemonSets);
|
||||
let services = self.count_kind_for_tab(&active, ResourceKind::Services);
|
||||
let ingresses = self.count_kind_for_tab(&active, ResourceKind::Ingresses);
|
||||
let jobs = self.count_kind_for_tab(&active, ResourceKind::Jobs);
|
||||
let cronjobs = self.count_kind_for_tab(&active, ResourceKind::CronJobs);
|
||||
let pods = self.count_kind_for_tab(&active, ResourceKind::Pods);
|
||||
let deployments = pulse_metrics.deployments;
|
||||
let replicasets = pulse_metrics.replicasets;
|
||||
let statefulsets = pulse_metrics.statefulsets;
|
||||
let daemonsets = pulse_metrics.daemonsets;
|
||||
let services = pulse_metrics.services;
|
||||
let ingresses = pulse_metrics.ingresses;
|
||||
let jobs = pulse_metrics.jobs;
|
||||
let cronjobs = pulse_metrics.cronjobs;
|
||||
let pods = pulse_metrics.pods;
|
||||
|
||||
let scope_label = active.namespace.as_deref().unwrap_or("all namespaces");
|
||||
let watch_error = self.store.error_for_context(&active.context);
|
||||
|
||||
Reference in new issue
Block a user