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
51 changes: 51 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh
# pre-commit hook. Shells out to Makefile targets rather than reimplementing
# the checks, so a commit is verified with the same commands as `make check`
# and CI. A check added in one place is added in all three.
#
# Installed by `make hooks` (which sets core.hooksPath). Bypass a run with
# `git commit --no-verify`.
#
# Every check is repo-wide: `go vet` and `go test` are package-scoped, and
# prettier is pointed at the whole tree by `.prettierignore`. The patterns
# below therefore decide only *whether* a check runs, not what it looks at.

set -e

staged="$(git diff --cached --name-only --diff-filter=ACMRT)"

matched() {
printf '%s\n' "$staged" | grep -Eq "$1"
}

run() {
printf '\n> %s\n' "$*"
"$@"
}

# Ordered fastest first, so an obvious failure does not wait behind the test
# suite.
if matched '\.go$|^go\.(mod|sum)$'; then
run make fmt-check
fi

# prettier reads its own config, so a change to that config is a reason to
# re-check the tree.
if matched '\.(md|json|ya?ml)$|^\.prettier(rc|ignore)$'; then
run make format-check
fi

if matched '\.go$|^go\.(mod|sum)$'; then
run make vet
fi

# Skipped with a note when golangci-lint is absent, matching the Makefile
# target. CI runs it either way.
if matched '\.go$|^go\.(mod|sum)$|^\.golangci\.ya?ml$'; then
run make lint-go
fi

# Without -race: that pass belongs to CI, which can afford the wall time.
if matched '\.go$|^go\.(mod|sum)$'; then
run make test
fi
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npx --yes prettier --check .
- name: Check formatting
run: make format-check

vulncheck:
name: Vulnerabilities
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

# Tags only. CI has already run on main by the time a release tag exists, and
# GoReleaser publishes straight from the tag, so there is nothing to gate here.
on:
push:
tags: ["v*"]

permissions:
contents: write

jobs:
release:
name: GoReleaser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
# GoReleaser reads the history to build the changelog.
fetch-depth: 0
persist-credentials: false

- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true

- uses: goreleaser/goreleaser-action@v7
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .golangci.yml → .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ formatters:
settings:
goimports:
local-prefixes:
- github.com/miguelmartens/protui
- github.com/nxplain-sh/protui
32 changes: 32 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# GoReleaser configuration. The release workflow runs this on a v* tag; run
# it locally with `goreleaser release --snapshot --clean` to see the artefacts
# without publishing anything.
version: 2

project_name: protui

builds:
- id: protui
main: ./cmd/protui
binary: protui
env:
- CGO_ENABLED=0
# protui supports macOS and Linux only; each on both architectures.
goos:
- darwin
- linux
goarch:
- amd64
- arm64
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{ .Version }}

archives:
- id: protui
formats:
- tar.gz
files:
- LICENSE
- README.md
55 changes: 0 additions & 55 deletions .pre-commit-config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ pending a first tagged version.
- [`docs/adr/`](docs/adr/README.md) records the architecture decisions, with the
alternatives considered and what each choice cost.

[unreleased]: https://github.com/miguelmartens/protui/commits/main
[unreleased]: https://github.com/nxplain-sh/protui/commits/main
132 changes: 132 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

- The use of sexualized language or imagery, and sexual attention or advances of
any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
37029379+miguelmartens@users.noreply.github.com. All complaints will be reviewed
and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
23 changes: 13 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,30 @@ You need:
- **Node** — only for `prettier`, fetched on demand via `npx`.
- **`golangci-lint`** — optional. The lint target skips it with a note when it
is absent, but CI runs it, so installing it saves a round trip.
- **[`pre-commit`](https://pre-commit.com/#install)** — optional, and only
needed if you want the hooks below.

```sh
git clone https://github.com/miguelmartens/protui
git clone https://github.com/nxplain-sh/protui
cd protui
make check # tidy, lint, test — the same checks CI runs
make hooks # optional: run those checks on every commit
```

`make help` lists every target.

### The pre-commit hooks
### The pre-commit hook

`make hooks` installs [`.pre-commit-config.yaml`](.pre-commit-config.yaml),
which runs `gofmt`, `prettier`, `go vet`, `golangci-lint` and `go test` before
each commit. Every hook shells out to a Makefile target, so the hooks and
`make check` cannot drift apart.
`make hooks` points git's `core.hooksPath` at
[`.githooks/pre-commit`](.githooks/pre-commit), which runs `gofmt`, `prettier`,
`go vet`, `golangci-lint` and `go test` before each commit. The hook shells out
to Makefile targets, so the hook and `make check` cannot drift apart. Git reads
that setting from repository config, so it is one command per clone:

Hooks are scoped by what you touched — a Markdown-only commit does not run the
Go checks — and `git commit --no-verify` skips them when you need it.
```sh
git config core.hooksPath .githooks
```

The hook is scoped by what the commit touches — a Markdown-only commit does not
run the Go checks — and `git commit --no-verify` skips it when you need it.

## Before you open a pull request

Expand Down
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,12 @@ tidy:
.PHONY: check
check: tidy lint test

## hooks: install the git pre-commit hooks
# Unlike golangci-lint this does not degrade to a note: asking for the hooks
# and silently not getting them is worse than being told to install the tool.
## hooks: install the git pre-commit hook
# Git only reads core.hooksPath from repository config, so this one line cannot
# ship itself with the checkout.
.PHONY: hooks
hooks:
@if command -v pre-commit >/dev/null 2>&1; then \
pre-commit install; \
else \
echo "pre-commit not installed (see https://pre-commit.com/#install)"; \
exit 1; \
fi
git config core.hooksPath .githooks

## clean: remove build artefacts
.PHONY: clean
Expand Down
Loading
Loading