Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .cursor/check.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
#!/usr/bin/env bash
# Local mirror of the CI hygiene suite for melodic-software/.github.
#
# Runs the same lanes as .github/workflows/pr-require-checks.yml against the same vendored
# configs, using the tools .cursor/install.sh pins to the CI versions. Every
# lane runs even if an earlier one fails, and a summary is printed at the end so
# a single invocation reproduces the aggregate `ci-status` verdict locally
# (CONTRIBUTING step 3: "Ensure the project builds and its checks pass locally").
#
# Not set -e: lanes are collected, not short-circuited. Exit status is non-zero
# when any gating lane fails.
set -uo pipefail

top="$(git rev-parse --show-toplevel)" && cd -- "$top" || exit 1

# Fall back onto a per-user bin in case install.sh placed tools there.
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
*) PATH="$HOME/.local/bin:$PATH" ;;
Expand All @@ -24,7 +15,6 @@ FAILED=()

heading() { printf '\n\033[1m── %s ──\033[0m\n' "$1" >&2; }

# run_lane <name> <cmd...>: run one lane under a heading and record its verdict.
run_lane() {
local name="$1"
shift
Expand All @@ -38,8 +28,6 @@ run_lane() {
fi
}

# --- Lanes with multi-step logic --------------------------------------------

# typos skips hidden paths unless they are named. The synced _typos.toml
# cannot set ignore-hidden = false; CI's typos job has the same follow-up.
# Skip index entries that are gone from the worktree: an unstaged deletion is
Expand Down Expand Up @@ -140,8 +128,6 @@ lane_issue_form_drift() {
return "$rc"
}

# --- Run every lane ---------------------------------------------------------

run_lane markdownlint lane_markdown
run_lane typos lane_typos
run_lane editorconfig-checker ec -config .editorconfig-checker.json
Expand All @@ -158,8 +144,6 @@ lane_pr_section_drift || printf '\033[33m! check-pr-sections (advisory)\033[0m\n
heading check-issue-forms
lane_issue_form_drift || printf '\033[33m! check-issue-forms (advisory)\033[0m\n' >&2

# --- Summary ----------------------------------------------------------------

heading ci-status
printf 'passed: %d failed: %d\n' "${#PASSED[@]}" "${#FAILED[@]}" >&2
if [[ ${#FAILED[@]} -gt 0 ]]; then
Expand Down
4 changes: 0 additions & 4 deletions .cursor/install-prefix.test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env bash
# Placement contract for .cursor/install.sh.
#
# Sources the resolver only. Does not download tools or write a prefix.
set -euo pipefail

here="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
Expand Down Expand Up @@ -50,7 +47,6 @@ assert_workstation() {
}

assert_system_unwritable() {
# Stand in for a /usr/local/bin the current user cannot write.
prefix_is_writable() { return 1; }
resolve_install_prefix
if [[ "$BIN_DIR" != /usr/local/bin ]]; then
Expand Down
36 changes: 3 additions & 33 deletions .cursor/install.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
#!/usr/bin/env bash
# Install the pinned hygiene toolchain for the melodic-software/.github repository.
#
# Two call sites:
# - Cloud Agent: .cursor/environment.json runs this with MELODIC_HYGIENE_SYSTEM=1
# so tools land in /usr/local/bin, which is already on the agent shell PATH.
# - Developer machine: a direct run installs into ~/.local/bin and never uses
# sudo, even when passwordless sudo would succeed. .cursor/check.sh prepends
# ~/.local/bin to PATH.
#
# This repo ships only community-health files, so its "build" is the same
# lint/hygiene suite CI runs (see .github/workflows/pr-require-checks.yml). That suite is a set
# of standalone tools; this script installs each one pinned to the exact version
# the CI composite actions use (see Pins below), so a
# local run of .cursor/check.sh reproduces CI verdicts byte for byte.
#
# Idempotent and safe to re-run: every tool is skipped when the pinned version
# is already present, and each release asset is verified against the same
# SHA-256 the CI action pins before it is trusted (fail closed).
#
# Sourced by .cursor/install-prefix.test.sh. The installer runs only when this
# file is executed, not when it is sourced.
set -euo pipefail

# --- Pins (authority: melodic-software/ci-workflows v0.76.0 action defaults) --
Expand All @@ -42,7 +21,6 @@ CHECK_JSONSCHEMA_VERSION="0.38.2"
# The default assignment keeps ShellCheck's check-unassigned-uppercase quiet.
MELODIC_HYGIENE_SYSTEM="${MELODIC_HYGIENE_SYSTEM:-}"

# Set by resolve_install_prefix before any installer runs.
BIN_DIR=""
VENV_DIR=""
# Command prefix kept as an array so an empty (no-sudo) value expands to nothing
Expand All @@ -59,9 +37,6 @@ prefix_is_writable() {
[[ -w "$1" ]]
}

# resolve_install_prefix: set BIN_DIR, VENV_DIR, and SUDO.
# Workstation mode never consults sudo. System mode uses /usr/local/bin and
# passwordless sudo only when that prefix is not writable.
resolve_install_prefix() {
SUDO=()
if [[ "$MELODIC_HYGIENE_SYSTEM" == 1 ]]; then
Expand All @@ -85,9 +60,9 @@ resolve_install_prefix() {
log "workstation mode; using $BIN_DIR (no files outside $HOME). Set MELODIC_HYGIENE_SYSTEM=1 to install into /usr/local/bin."
}

Comment thread
kyle-sexton marked this conversation as resolved.
Resolved
# verify_sha <file> <sha256>: abort the whole install on mismatch. A hygiene
# toolchain that silently installed an unverified binary is worse than a hard
# failure the operator can see and re-run.
# Abort the whole install on mismatch: a hygiene toolchain that silently
# installed an unverified binary is worse than a hard failure the operator can
# see and re-run.
verify_sha() {
Comment thread
kyle-sexton marked this conversation as resolved.
Resolved
local file="$1" want="$2" got
got="$(sha256sum "$file" | awk '{print $1}')"
Expand All @@ -104,8 +79,6 @@ install_bin() {
log "installed $name -> $BIN_DIR/$name"
}

# ensure <label> <version> <installer> <version-cmd...>: run <installer> unless
# <version-cmd> already reports the pinned version.
ensure() {
local label="$1" want="$2" installer="$3" cur
shift 3
Expand All @@ -117,9 +90,6 @@ ensure() {
fi
}

# install_release <name> <sha256> <url> <extracted-path> <tar-member-args...>:
# download a release tarball, verify it, extract the member, and install
# $WORK/<extracted-path> as <name>.
install_release() {
local name="$1" sha="$2" url="$3" extracted="$4"
shift 4
Expand Down
8 changes: 0 additions & 8 deletions .github/scripts/issue-form-drift.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/usr/bin/env node

// Compares the org issue forms in `.github/ISSUE_TEMPLATE/` to the issue-body contract the
// standards sync delivers beside them (`.github/standards/issue-body-contract/contract.json`,
// generated from melodic-software/standards components/issue-body-contract/contract.json). A
// form that drifts from the contract (a hand edit, a stale sync, a form the contract does not
// declare) fails the PR that introduces it, with the field that differs named. `config.yml` is
// this repository's own and is not compared.
//
// The forms are the generator's YAML subset (no anchors, flow maps or multi-document streams), so
// a line reader covers them; a shape it cannot read is reported as drift, never skipped.

Expand All @@ -28,7 +21,6 @@ function scalar(raw) {
return value;
}

// Returns { name, description, type, labels, fields: [{ id, kind, heading, required }] }.
export function parseForm(text) {
const form = { type: null, labels: [], fields: [] };
let list = null;
Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/pr-section-drift.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ export function parseTemplateHeadings(markdownText) {
return [...stripHtmlComments(markdownText).matchAll(/^## (.+)$/gm)].map((match) => match[1].trim());
}

// Reads the top-level block sequence `pr_body_required_sections:` from the YAML:
// its `- <name>` items, plain or quoted, up to the next top-level line.
export function parseSourceControlSections(yamlText, location = SOURCE_CONTROL_PATH) {
const lines = yamlText.split(/\r?\n/);
const keyRe = new RegExp(`^${SOURCE_CONTROL_HEADING}:\\s*(#.*)?$`);
Expand Down
Loading