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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
- name: Run fixers
run: mise run fixers

- name: Install shell test dependencies
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y zsh python3

- name: Run tests
run: mise run ci-tests

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nnutter/timber

go 1.27.0
go 1.27.1

require (
charm.land/fang/v2 v2.0.1
Expand Down
73 changes: 65 additions & 8 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[tools]
go = "1.27.0"
ttyd = "1.7.7"

#####################
# Development Tasks #
Expand All @@ -15,8 +14,6 @@ description = "Require shell test dependencies and run the full suite"
run = '''
#!/usr/bin/env bash
set -euo pipefail
command -v zsh
command -v python3
python3 -c 'import os, pty; master, slave = pty.openpty(); os.close(master); os.close(slave)'
go test -race -shuffle=on -cover ./...
'''
Expand Down Expand Up @@ -67,31 +64,72 @@ run = [
"mise run fix-gofumpt ${usage_staged_files}",
"mise run fix-goimports ${usage_staged_files}",
"mise run fix-go-fix ${usage_staged_files}",
"mise run fix-testifylint",
"mise run fix-testifylint ${usage_staged_files}",
]

[tasks.fix-gofumpt]
description = "Run code formatting tools"
usage = 'arg "[staged_files]" var=#true'
run = '''
#!/usr/bin/env bash
go tool gofumpt -l -w ${usage_staged_files:-.}
set -eo pipefail
if [ -z "${usage_staged_files:-}" ]; then
go tool gofumpt -l -w .
exit 0
fi
go_files=""
for f in ${usage_staged_files}; do
case "$f" in *.go) go_files="$go_files $f" ;; esac
done
[ -z "$go_files" ] && exit 0
# shellcheck disable=SC2086
go tool gofumpt -l -w $go_files
'''

[tasks.fix-goimports]
description = "Run code formatting tools"
usage = 'arg "[staged_files]" var=#true'
run = '''
#!/usr/bin/env bash
go tool goimports -l -w -local $(go list -m) ${usage_staged_files:-.}
set -eo pipefail
if [ -z "${usage_staged_files:-}" ]; then
go tool goimports -l -w -local $(go list -m) .
exit 0
fi
go_files=""
for f in ${usage_staged_files}; do
case "$f" in *.go) go_files="$go_files $f" ;; esac
done
[ -z "$go_files" ] && exit 0
# shellcheck disable=SC2086
go tool goimports -l -w -local $(go list -m) $go_files
'''

[tasks.fix-go-fix]
description = "Apply go fix"
usage = 'arg "[staged_files]" var=#true'
run = '''
#!/usr/bin/env bash
go fix ${usage_staged_files:-./...}
set -eo pipefail
if [ -z "${usage_staged_files:-}" ]; then
go fix ./...
exit 0
fi
dirs=""
for f in ${usage_staged_files}; do
case "$f" in
*.go)
d=$(dirname "$f")
case "$d" in ./*|/*) ;; *) d="./$d" ;; esac
dirs="$dirs $d"
;;
esac
done
[ -z "$dirs" ] && exit 0
# shellcheck disable=SC2086
pkgs=$(printf '%s\n' $dirs | sort -u)
# shellcheck disable=SC2086
go fix $pkgs
'''

[tasks.fix-go-mod-tidy]
Expand All @@ -103,7 +141,26 @@ description = "Run testifylint static analysis"
usage = 'arg "[staged_files]" var=#true'
run = '''
#!/usr/bin/env bash
go tool testifylint -fix ${usage_staged_files:-.}
set -eo pipefail
if [ -z "${usage_staged_files:-}" ]; then
go tool testifylint -fix ./...
exit 0
fi
dirs=""
for f in ${usage_staged_files}; do
case "$f" in
*.go)
d=$(dirname "$f")
case "$d" in ./*|/*) ;; *) d="./$d" ;; esac
dirs="$dirs $d"
;;
esac
done
[ -z "$dirs" ] && exit 0
# shellcheck disable=SC2086
pkgs=$(printf '%s\n' $dirs | sort -u)
# shellcheck disable=SC2086
go tool testifylint -fix $pkgs
'''

##############
Expand Down
Loading