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
115 changes: 114 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,119 @@ permissions:
contents: read

jobs:
duplication:
name: Duplication ratchet
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout candidate
uses: actions/checkout@v7
with:
path: candidate
fetch-depth: 0
persist-credentials: false
- name: Checkout trusted comparison base
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.base.sha || github.event.before }}
path: base
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
cache-dependency-path: candidate/tools/duplication/package-lock.json
- name: Test duplication tooling
run: |
npm ci --prefix candidate/tools/duplication --ignore-scripts --no-audit --no-fund
npm --prefix candidate/tools/duplication test
- name: Measure and compare production duplication
id: duplication-policy
shell: bash
run: |
policy_dir="$GITHUB_WORKSPACE/base/tools/duplication"
if [[ -f "$policy_dir/policy.json" ]]; then
echo "trusted=true" >> "$GITHUB_OUTPUT"
npm ci --prefix "$policy_dir" --ignore-scripts --no-audit --no-fund
else
# One-time bootstrap: the base branch has no duplication policy yet.
policy_dir="$GITHUB_WORKSPACE/candidate/tools/duplication"
fi
node "$policy_dir/check.mjs" --root "$GITHUB_WORKSPACE/candidate" \
--base "$GITHUB_WORKSPACE/base" --output "$RUNNER_TEMP/duplication-report"
- name: Validate proposed checker and policy against master
if: steps.duplication-policy.outputs.trusted == 'true'
run: |
node "$GITHUB_WORKSPACE/base/tools/duplication/verify.mjs" \
--root "$GITHUB_WORKSPACE/candidate" --base "$GITHUB_WORKSPACE/base" \
--output "$RUNNER_TEMP/duplication-report"
- name: Preserve actionable duplication reports
if: always()
uses: actions/upload-artifact@v7
with:
name: duplication-report
path: ${{ runner.temp }}/duplication-report
retention-days: 30
if-no-files-found: warn

duplication-baseline:
name: Update duplication baseline
needs: [duplication, test]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
concurrency:
group: duplication-baseline-master
cancel-in-progress: false
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: "24"
- name: Persist initial baseline or tighter limits
shell: bash
run: |
git fetch --no-tags origin master
if [[ "$(git rev-parse FETCH_HEAD)" != "$GITHUB_SHA" ]]; then
echo "A newer master commit exists; its successful CI run will update the baseline."
exit 0
fi
npm ci --prefix tools/duplication --ignore-scripts --no-audit --no-fund
node tools/duplication/check.mjs --update-baseline --output "$RUNNER_TEMP/duplication-ratchet"
if git diff --quiet -- tools/duplication/baseline.json; then
echo "No improved limits; baseline left unchanged."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -- tools/duplication/baseline.json
git commit -m "CHORE: ratchet duplication baseline"
# Normal non-force push: never overwrite a concurrently advanced master.
# GITHUB_TOKEN pushes do not recursively start another CI run.
if ! git push origin HEAD:master; then
git fetch --no-tags origin master
if [[ "$(git rev-parse FETCH_HEAD)" != "$GITHUB_SHA" ]]; then
echo "Master advanced during the update; leaving its newer content untouched."
exit 0
fi
echo "Baseline push failed; check repository Actions permissions and branch rules."
exit 1
fi
- name: Preserve measured baseline for manual recovery
if: always()
uses: actions/upload-artifact@v7
with:
name: duplication-baseline-candidate
path: ${{ runner.temp }}/duplication-ratchet
retention-days: 30
if-no-files-found: ignore

test:
name: Go ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -30,7 +143,7 @@ jobs:

- name: Setup Bats
if: runner.os == 'Linux'
uses: bats-core/bats-action@4.0.0
uses: bats-core/bats-action@4.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
support-install: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
cache: true
- name: Setup Bats
if: runner.os == 'Linux'
uses: bats-core/bats-action@4.0.0
uses: bats-core/bats-action@4.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
support-install: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
# Do not silently scan a newer toolchain instead of the project's Go version.
env:
GOTOOLCHAIN: local
run: go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
run: go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/theme.yml
*.test
coverage.out
/tools/duplication/node_modules/
/tools/duplication/reports/
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Go version](https://img.shields.io/github/go-mod/go-version/merefield/termcourse)](go.mod)
[![License](https://img.shields.io/github/license/merefield/termcourse)](LICENSE)

Termcourse is a Go 1.27.2 terminal UI for browsing and posting to Discourse forums. It replaces the original Ruby implementation while retaining its browsing, posting, realtime, rendering, localization, theming, and image features.
Termcourse is a Go 1.27.3 terminal UI for browsing and posting to Discourse forums. It replaces the original Ruby implementation while retaining its browsing, posting, realtime, rendering, localization, theming, and image features.

## Features

Expand Down Expand Up @@ -89,7 +89,7 @@ If no credentials are configured, Termcourse prompts for the missing username an

### Install with Go

Go 1.27.2 or newer is required when installing from source. `go install` compiles Termcourse locally:
Go 1.27.3 or newer is required when installing from source. `go install` compiles Termcourse locally:

```sh
go install github.com/merefield/termcourse/cmd/termcourse@latest
Expand Down Expand Up @@ -343,10 +343,12 @@ Each uses the same full-width block lettering at the vertical centre, then shrin

## Implementation

The Security workflow scans reachable Go standard-library and dependency vulnerabilities on PRs, pushes to master, weekly, and manual dispatch. It pins `govulncheck` to v1.8.0 and disables automatic toolchain switching to scan the Go version in `go.mod`. Advisory-service failures fail the check. The scan currently covers the Linux build; it adds no application startup work or runtime dependency. Repeat locally with:
The [Duplication ratchet](tools/duplication/README.md) checks production Go code for copy-paste regressions. Normalised matches and test duplication are reported for review.

The Security workflow scans reachable Go standard-library and dependency vulnerabilities on PRs, pushes to master, weekly, and manual dispatch. It pins `govulncheck` to v1.9.0 and disables automatic toolchain switching to scan the Go version in `go.mod`. Advisory-service failures fail the check. The scan currently covers the Linux build; it adds no application startup work or runtime dependency. Repeat locally with:

```sh
GOTOOLCHAIN=go1.27.2 go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
GOTOOLCHAIN=go1.27.3 go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 ./...
```

The interface runs on the current Charm v2 stack. Bubble Tea owns raw mode, the alternate screen, synchronized incremental rendering, resize events, cursor state, terminal queries, color downsampling, window metadata, and supported native progress metadata. Bubbles supplies the themed single-line editor and multiline composer, including bracketed paste, word navigation, soft wrapping, cursor behavior, and viewport scrolling. Lip Gloss v2 provides pure theme/layout styles, while Glamour v2/Goldmark renders GFM and `x/ansi` provides ANSI-safe grapheme measurement, truncation, Kitty graphics encoding, capability responses, and virtual image placement. `x/term` remains limited to pre-TUI password input, terminal detection, and sizing fallback.
Expand Down
36 changes: 20 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
module github.com/merefield/termcourse

go 1.27.2
go 1.27.3

require (
charm.land/bubbles/v2 v2.2.1
charm.land/bubbletea/v2 v2.0.10
charm.land/bubbletea/v2 v2.1.1
charm.land/glamour/v2 v2.0.1
charm.land/lipgloss/v2 v2.0.6
github.com/charmbracelet/colorprofile v0.4.3
github.com/charmbracelet/ultraviolet v0.0.0-20260812204455-68fa937c71be
github.com/charmbracelet/x/ansi v0.11.8
github.com/charmbracelet/ultraviolet v0.0.0-20261023060817-a45b7c86333f
github.com/charmbracelet/x/ansi v0.11.9
github.com/charmbracelet/x/term v0.2.2
github.com/joho/godotenv v1.5.1
github.com/yuin/goldmark v1.7.17
golang.org/x/image v0.45.0
golang.org/x/sys v0.48.0
golang.org/x/text v0.42.0
github.com/yuin/goldmark v1.8.7
golang.org/x/image v0.47.0
golang.org/x/sys v0.49.0
golang.org/x/text v0.43.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/alecthomas/chroma/v2 v2.20.0 // indirect
github.com/alecthomas/chroma/v2 v2.27.0 // indirect
github.com/alecthomas/repr v0.5.4 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/charmbracelet/x/exp/golden v0.0.0-20260816001655-68d539dca504 // indirect
github.com/charmbracelet/x/exp/slice v0.0.0-20260816001655-68d539dca504 // indirect
github.com/charmbracelet/x/exp/golden v0.1.0 // indirect
github.com/charmbracelet/x/exp/slice v0.1.0 // indirect
github.com/charmbracelet/x/termios v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/dlclark/regexp2/v2 v2.13.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
github.com/mattn/go-runewidth v0.0.27 // indirect
github.com/mattn/go-runewidth v0.0.31 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/rogpeppe/go-internal v1.16.0 // indirect
github.com/xo/terminfo v1.3.1 // indirect
github.com/yuin/goldmark-emoji v1.0.6 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sync v0.23.0 // indirect
golang.org/x/net v0.62.0 // indirect
golang.org/x/sync v0.24.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
Loading
Loading