Skip to content

Commit 4677784

Browse files
committed
feat: updating docs again
0 parents  commit 4677784

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+6865
-0
lines changed

.crush.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://charm.land/crush.json",
3+
"lsp": {
4+
"go": {
5+
"command": "gopls",
6+
"env": {
7+
"GOTOOLCHAIN": "go1.24.5"
8+
}
9+
}
10+
}
11+
}

.envrc

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env bash
2+
# shellcheck shell=bash
3+
4+
################################################################################
5+
# Portable direnv bootstrap for Nix flakes – NixOS, Ubuntu/Debian and Alpine
6+
# Author: Benji (adapted)
7+
################################################################################
8+
set -euo pipefail
9+
10+
###############################################################################
11+
# Helper functions
12+
###############################################################################
13+
warn() { printf '\e[33m%s\e[0m\n' "$*" >&2; }
14+
fail() { printf '\e[31m%s\e[0m\n' "$*" >&2; exit 1; }
15+
need() { command -v "$1" &>/dev/null || return 1; }
16+
17+
# Detect OS
18+
if [ -r /etc/os-release ]; then
19+
. /etc/os-release
20+
else
21+
fail "Unsupported system – no /etc/os-release"
22+
fi
23+
24+
###############################################################################
25+
# Minimal prerequisites (curl & git) – only if Nix is missing
26+
###############################################################################
27+
if ! need nix; then
28+
pkgs=""
29+
need curl || pkgs+=" curl"
30+
need git || pkgs+=" git"
31+
32+
if [ -n "$pkgs" ]; then
33+
if need sudo; then SUDO=sudo; else SUDO=""; fi
34+
case "$ID" in
35+
alpine) $SUDO apk add --no-cache $pkgs ;;
36+
debian|ubuntu) $SUDO apt-get update -y && $SUDO apt-get install -y $pkgs ;;
37+
naxos) ;; # already has nix
38+
*) warn "Unknown distro $ID – please install:$pkgs";;
39+
esac
40+
fi
41+
fi
42+
43+
###############################################################################
44+
# Install Nix (if needed)
45+
###############################################################################
46+
if ! need nix; then
47+
warn "Installing Nix package manager..."
48+
case "$ID" in
49+
alpine) sh <(curl -L https://nixos.org/nix/install) --no-daemon ;;
50+
*) sh <(curl -L https://nixos.org/nix/install) --daemon ;;
51+
esac
52+
# Load Nix into current shell – works for both install modes
53+
if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
54+
# shellcheck source=/dev/null
55+
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
56+
elif [ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then
57+
# shellcheck source=/dev/null
58+
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
59+
fi
60+
fi
61+
62+
###############################################################################
63+
# Ensure helper CLIs via Nix (gh, vault, cachix)
64+
###############################################################################
65+
ensure_cli() {
66+
local cmd="$1" attr="$2"
67+
need "$cmd" || nix-env -iA "nixpkgs.$attr" >/dev/null
68+
}
69+
export NIXPKGS_ALLOW_UNFREE=1
70+
ensure_cli gh gh
71+
ensure_cli vault vault
72+
ensure_cli cachix cachix
73+
74+
###############################################################################
75+
# GitHub Token
76+
###############################################################################
77+
if [ -z "${GITHUB_TOKEN-}" ]; then
78+
warn "Fetching GitHub token via GitHub CLI..."
79+
GITHUB_TOKEN="$(gh auth token 2>/dev/null || true)"
80+
[ -n "$GITHUB_TOKEN" ] || fail "No GITHUB_TOKEN found – set env var or run: gh auth login"
81+
export GITHUB_TOKEN
82+
else
83+
warn "Using existing GITHUB_TOKEN"
84+
fi
85+
86+
###############################################################################
87+
# Vault login & secret retrieval
88+
###############################################################################
89+
export VAULT_ADDR=https://pki.devnw.com
90+
if ! vault token lookup -no-print &>/dev/null; then
91+
vault login -no-print -method=github token="$GITHUB_TOKEN" || warn "Vault login failed"
92+
fi
93+
94+
OPENAI_API_KEY="$(vault kv get -mount=secret -field=token /dev/openai/actions-primary 2>/dev/null || echo '')"
95+
export OPENAI_API_KEY
96+
CACHIX_AUTH_TOKEN="$(vault kv get -mount=secret -field=token /cicd/gh/cachix 2>/dev/null || echo '')"
97+
export CACHIX_AUTH_TOKEN
98+
99+
###############################################################################
100+
# Nix configuration & Cachix
101+
###############################################################################
102+
NIX_CONFIG="experimental-features = nix-command flakes
103+
access-tokens = github.com=${GITHUB_TOKEN}
104+
trusted-users = root $(whoami)"
105+
export NIX_CONFIG
106+
107+
# Configure trusted users in nix.conf if not already configured
108+
if ! grep -q "trusted-users.*$(whoami)" /etc/nix/nix.conf 2>/dev/null; then
109+
warn "Adding $(whoami) as trusted user for Nix..."
110+
echo "trusted-users = root $(whoami)" | sudo tee -a /etc/nix/nix.conf >/dev/null
111+
sudo pkill nix-daemon 2>/dev/null || true
112+
sleep 2
113+
fi
114+
115+
# Setup Cachix auth and binary cache
116+
if [ -n "${CACHIX_AUTH_TOKEN-}" ]; then
117+
cachix authtoken "$CACHIX_AUTH_TOKEN" >/dev/null 2>&1 || true
118+
cachix use spyder >/dev/null 2>&1 || warn "Could not configure Cachix binary cache"
119+
fi
120+
121+
###############################################################################
122+
# Finally: load the flake environment
123+
###############################################################################
124+
export FLAKE_PATH=.# # override if desired
125+
export FLAKE_ARGS='--impure --accept-flake-config'
126+
127+
source_up # direnv helper – walk up to load any parent .envrc
128+
use flake "$FLAKE_PATH" $FLAKE_ARGS
129+
130+
###############################################################################
131+
# Push newly built development shell to Cachix (non‑blocking)
132+
###############################################################################
133+
if [ -n "${CACHIX_AUTH_TOKEN-}" ]; then
134+
# Push the development shell derivation to cachix
135+
( nix develop --dry-run --json $FLAKE_ARGS $FLAKE_PATH 2>/dev/null | jq -r '.devShell' | cachix push spyder 2>/dev/null || warn "Cachix push failed" ) &
136+
fi
137+
138+
# End of .envrc

.github/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
copilot-instructions.md

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @spyderorg/maintainers

.github/assets/bench.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Benchmark page renderer: builds table + sparklines from bench JSON data.
2+
;(async function () {
3+
const root = document.getElementById('bench-charts')
4+
if (!root) return
5+
function el(tag, attrs = {}, html = '') {
6+
const e = document.createElement(tag)
7+
for (const k in attrs) {
8+
e.setAttribute(k, attrs[k])
9+
}
10+
if (html) e.innerHTML = html
11+
return e
12+
}
13+
async function loadJSON(p) {
14+
try {
15+
const r = await fetch(p)
16+
if (!r.ok) return null
17+
return await r.json()
18+
} catch (_) {
19+
return null
20+
}
21+
}
22+
const summary = await loadJSON('summary.json')
23+
if (!summary) {
24+
root.textContent = 'No benchmark summary available.'
25+
return
26+
}
27+
if (!summary.benchmarks || !summary.benchmarks.length) {
28+
root.textContent = 'Benchmark summary empty.'
29+
return
30+
}
31+
root.textContent = ''
32+
function spark(values, width = 160, height = 40, pad = 3) {
33+
if (!values.length) return ''
34+
const min = Math.min(...values),
35+
max = Math.max(...values)
36+
const span = max - min || 1
37+
const pts = values
38+
.map((v, i) => {
39+
const x = pad + (i / (values.length - 1)) * (width - 2 * pad)
40+
const y = pad + (1 - (v - min) / span) * (height - 2 * pad)
41+
return x.toFixed(1) + ',' + y.toFixed(1)
42+
})
43+
.join(' ')
44+
const last = values[values.length - 1]
45+
const first = values[0]
46+
const diff = last - first
47+
const cls = diff < 0 ? 'better' : diff > 0 ? 'worse' : 'same'
48+
return `<svg viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" class="spark ${cls}"><polyline fill="none" stroke="currentColor" stroke-width="1.2" points="${pts}"/></svg>`
49+
}
50+
const table = el('table')
51+
table.innerHTML =
52+
'<thead><tr><th>Name</th><th>ns/op</th><th>bytes/op</th><th>allocs/op</th><th>trend</th></tr></thead><tbody></tbody>'
53+
const tbody = table.querySelector('tbody')
54+
for (const b of summary.benchmarks) {
55+
const series = await loadJSON('data/' + b.file)
56+
if (!series || !series.length) continue
57+
const latest = series[series.length - 1]
58+
const nsSeries = series.map((r) => r.ns_per_op)
59+
const row = el('tr')
60+
row.innerHTML = `<td><code>${
61+
b.name
62+
}</code></td><td>${latest.ns_per_op.toLocaleString()}</td><td>${
63+
latest.bytes_per_op ?? ''
64+
}</td><td>${latest.allocs_per_op ?? ''}</td><td>${spark(nsSeries)}</td>`
65+
tbody.appendChild(row)
66+
}
67+
if (!tbody.children.length) {
68+
root.textContent = 'No benchmark series data.'
69+
return
70+
}
71+
const style = el(
72+
'style',
73+
{},
74+
'.spark{background:var(--md-code-bg-color);border:1px solid var(--md-default-fg-color--light);border-radius:2px;margin:0 2px}.spark.better polyline{stroke:var(--md-typeset-color-success,#00aa55)}.spark.worse polyline{stroke:var(--md-typeset-color-error,#cc3344)} table{width:100%;border-collapse:collapse;margin-top:.75rem;font-size:.8rem}th,td{padding:4px 6px;border-bottom:1px solid var(--md-default-fg-color--light);}'
75+
)
76+
root.appendChild(style)
77+
root.appendChild(table)
78+
})()

.github/compass-metrics.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Compass Metrics Configuration
2+
# This file maps metric names to their Compass metric source UUIDs
3+
# The full ARN is constructed as: {compass.base_arn}:metric-source/{component_uuid}/{metric_uuid}
4+
5+
# Compass API Configuration
6+
compass:
7+
# Your Atlassian instance URL
8+
url: 'https://devnw.atlassian.net'
9+
10+
# Base Compass ARN (instance identifier)
11+
base_arn: 'ari:cloud:compass:89436501-45fd-498f-9c7c-b0db10b968cb'
12+
13+
# Component UUID (extracted from compass.yml component ID)
14+
# This will be auto-extracted from the component ID: only the first UUID (d819e7ce-7ec1-48ae-b718-cb3459fc6e06)
15+
# Full component ID: ari:cloud:compass:...:component/d819e7ce-7ec1-48ae-b718-cb3459fc6e06/1420c0b0-56eb-401f-8c63-63f93faeea91
16+
# You can also specify it manually here if needed:
17+
# component_uuid: 'd819e7ce-7ec1-48ae-b718-cb3459fc6e06'
18+
19+
# Metric Mappings
20+
# Each metric name maps to its specific metric source UUID
21+
# To get these UUIDs:
22+
# 1. Go to your Compass component page
23+
# 2. Navigate to the metric you want to configure
24+
# 3. Click "Copy cURL command"
25+
# 4. Extract the UUID from the "metricSourceId" (the part after the last /)
26+
metrics:
27+
# Code Quality Metrics
28+
test_coverage_percentage:
29+
uuid: '11d716cf-5667-427f-b12a-b3a769654646'
30+
description: 'Overall test coverage percentage of the codebase'
31+
32+
total_tests:
33+
uuid: '4edc8ac9-ee6e-4e7d-9ab0-cdb5f56cd54b'
34+
description: 'Total number of test functions'
35+
36+
failed_tests:
37+
uuid: '61c8881f-c858-4b88-afdd-f8e68d3cfd64'
38+
description: 'Number of failed tests'
39+
40+
passed_tests:
41+
uuid: 'cd0a5e70-8bc1-4dde-a803-cc1411bbc99f'
42+
description: 'Number of passed tests'
43+
44+
test_success_rate:
45+
uuid: '8fb59d8d-545b-4fc3-9ee7-00a45879b89b'
46+
description: 'Percentage of tests that pass'
47+
48+
# Code Complexity Metrics
49+
avg_cyclomatic_complexity:
50+
uuid: '91450e63-fc2c-4082-b216-f5c0f74c4337'
51+
description: 'Average cyclomatic complexity across all functions'
52+
53+
high_complexity_functions:
54+
uuid: 'f9413012-6459-4235-bc2b-227aa7f79256'
55+
description: 'Number of functions with complexity > 10'
56+
57+
function_count:
58+
uuid: '98f2173b-300a-4b8f-9493-03032e37bd60'
59+
description: 'Total number of functions (excluding tests)'
60+
61+
test_function_count:
62+
uuid: 'dddfb653-c4a3-40e9-bd07-f6f800f72474'
63+
description: 'Number of test functions'
64+
65+
benchmark_function_count:
66+
uuid: 'fa8e56c7-8e7a-4b59-9ad1-445972bcfa2f'
67+
description: 'Number of benchmark functions'
68+
69+
# Repository Metrics
70+
lines_of_code:
71+
uuid: '6ff6fc77-b77a-4780-8441-dcd4e075d23e'
72+
description: 'Total lines of Go code'
73+
74+
go_files_count:
75+
uuid: 'a0e73f35-5207-41d6-a955-a8e617d5ec17'
76+
description: 'Number of Go source files'
77+
78+
package_count:
79+
uuid: '41798047-20de-4011-a42f-e4a17485d6d6'
80+
description: 'Number of Go packages'
81+
82+
direct_dependencies:
83+
uuid: '28392e75-9434-45dd-9119-b8bde436688f'
84+
description: 'Number of direct Go module dependencies'
85+
86+
# Performance Metrics
87+
benchmark_count:
88+
uuid: '2ab5c86e-bf1f-434a-bea6-920907fccd1d'
89+
description: 'Number of benchmark tests'
90+
91+
avg_benchmark_ns_per_op:
92+
uuid: 'd4a2e683-69de-411b-b05c-2b5de50752c8'
93+
description: 'Average nanoseconds per operation across benchmarks'
94+
95+
avg_benchmark_bytes_per_op:
96+
uuid: 'ce949ae0-e67b-4de8-9dcf-d53eeb4b2484'
97+
description: 'Average bytes per operation across benchmarks'
98+
99+
avg_benchmark_allocs_per_op:
100+
uuid: 'aa4a0bbf-34cf-4748-96c2-62dbc5a2498e'
101+
description: 'Average allocations per operation across benchmarks'
102+
103+
slowest_benchmark_ns_per_op:
104+
uuid: 'acd737c6-3606-4eb7-9d04-6c884ed940de'
105+
description: 'Slowest benchmark (highest ns/op)'
106+
107+
fastest_benchmark_ns_per_op:
108+
uuid: '857c7ccc-030d-4ebc-a883-4cfc1406dc3d'
109+
description: 'Fastest benchmark (lowest ns/op)'
110+
111+
benchmark_performance_variance:
112+
uuid: 'a8abd71d-0d5a-4ec9-8862-587bae2ae003'
113+
description: 'Standard deviation of benchmark performance'
114+
115+
# Development Activity Metrics
116+
total_commits:
117+
uuid: 'ed4fd8ea-79ad-47eb-83ae-24581e28b3b7'
118+
description: 'Total number of commits in the repository'
119+
120+
commits_last_30_days:
121+
uuid: '6dcb75d4-e5f1-47e1-9824-cffa8f634151'
122+
description: 'Number of commits in the last 30 days'
123+
124+
# Additional Benchmark Metrics (from JSON parsing)
125+
successful_benchmarks:
126+
uuid: '47c1d92a-02a2-42c1-b584-3c1ef2dd81f0'
127+
description: 'Number of successful benchmark runs'
128+
129+
failed_benchmarks:
130+
uuid: '6cbcc1a2-5250-400b-b064-48aecb881c5a'
131+
description: 'Number of failed benchmark runs'
132+
133+
benchmark_success_rate:
134+
uuid: 'dc4c97bd-8574-458c-9a3b-090f32aedb75'
135+
description: 'Percentage of benchmarks that pass'
136+
137+
total_benchmark_time_seconds:
138+
uuid: '53d4eb4b-4cfb-4b7d-b087-833c679a50df'
139+
description: 'Total benchmark execution time in seconds'
140+
141+
# Configuration for metric pushing behavior
142+
settings:
143+
# Whether to continue pushing other metrics if one fails
144+
continue_on_error: true
145+
146+
# Whether to validate ARN format before pushing
147+
validate_arn_format: true
148+
149+
# Timeout for each metric push request (in seconds)
150+
request_timeout: 30
151+
152+
# Whether to log detailed responses for debugging
153+
verbose_logging: true
154+
# NOTE: Replace all the example ARNs above with the actual metric source ARNs from your Compass instance
155+
# The ARNs shown are examples and will not work without being updated to match your actual metrics

0 commit comments

Comments
 (0)