44 lines
2.0 KiB
Go
44 lines
2.0 KiB
Go
package main
|
|
|
|
import "strings"
|
|
|
|
// MergeCheck is the first commit's merge-check.sh (ADR 0428 §4): it declares the Go toolchain (ADR 0238 §4, read
|
|
// among a script's first lines by the build seat), and runs the unit tests, then with -tags integration the
|
|
// integration tests, of every Go module in the tree; on a tree with none it says so and passes.
|
|
const MergeCheck = `#!/bin/sh
|
|
# mesh-check-toolchain: go
|
|
#
|
|
# This repository's own check, mesh/repo-check (novox/hq ADR 0238 §4), written with its first commit (ADR 0428 §4):
|
|
# every Go module in the tree is vetted, its unit tests run, and then its integration tests (-tags integration).
|
|
# A tree with no Go module has nothing to test, and the check says so and passes.
|
|
set -eu
|
|
cd "$(dirname "$0")"
|
|
|
|
modules=$(find . -name go.mod -not -path '*/vendor/*' -not -path './.git/*' | sort)
|
|
if [ -z "$modules" ]; then
|
|
echo "This tree holds no Go module, so there are no tests to run; the check passes."
|
|
exit 0
|
|
fi
|
|
for mod in $modules; do
|
|
dir=$(dirname "$mod")
|
|
echo "== $dir: go vet and the unit tests"
|
|
(cd "$dir" && go vet ./... && go test ./...)
|
|
echo "== $dir: the integration tests (-tags integration)"
|
|
(cd "$dir" && go vet -tags integration ./... && go test -tags integration ./...)
|
|
done
|
|
`
|
|
|
|
// FirstCommit is main's first commit of a listed repository: its README, naming the repository's purpose, and
|
|
// its own check.
|
|
func FirstCommit(name string, r Repo) map[string]string {
|
|
purpose := strings.TrimSpace(r.Description)
|
|
if purpose == "" {
|
|
purpose = "(its purpose is not described yet: the gitea module's config value `repositories` describes it)"
|
|
}
|
|
readme := "# " + name + "\n\n" + purpose + "\n\n" +
|
|
"Made by the mesh from the gitea module's config value `repositories` (novox/hq ADR 0428). Main takes no push: " +
|
|
"a change reaches it by a pull request whose `mesh/repo-check` (this repository's `merge-check.sh`) and " +
|
|
"`mesh/merge-gate` passed.\n"
|
|
return map[string]string{"README.md": readme, "merge-check.sh": MergeCheck}
|
|
}
|