Skip to content

Commit 454e0db

Browse files
committed
Replace dobi with plsdo
1 parent 729c5b2 commit 454e0db

File tree

5 files changed

+139
-59
lines changed

5 files changed

+139
-59
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ vendor/
22
.dobi/
33
dist/
44
junit.xml
5+
.plsdo/

.plsdo.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
# plsdo.sh, version 0.1.1
3+
set -o errexit -o nounset -o pipefail
4+
5+
_plsdo_run() {
6+
case "${1-}" in
7+
""|help)
8+
_plsdo_help "${2-}" ;;
9+
*)
10+
"$@" ;;
11+
esac
12+
}
13+
14+
declare -A help
15+
16+
help[list]="Print the list of tasks"
17+
list() {
18+
declare -F | awk '{print $3}' | grep -v '^_'
19+
}
20+
21+
_plsdo_help_task_name_width="${_plsdo_help_task_name_width:-12}"
22+
23+
_plsdo_help() {
24+
local topic="${1-}"
25+
# print help for the topic
26+
if [ -n "$topic" ]; then
27+
if ! command -v "$topic" > /dev/null ; then
28+
_plsdo_error "No such task: $topic"
29+
return 1
30+
fi
31+
32+
printf "\nUsage:\n %s %s\n\n%s\n" "$0" "$topic" "${help[$topic]-}"
33+
return 0
34+
fi
35+
36+
# print list of tasks and their help line.
37+
[ -n "${banner-}" ] && echo "$banner" && echo
38+
for i in $(list); do
39+
printf "%-${_plsdo_help_task_name_width}s\t%s\n" "$i" "${help[$i]-}" | head -1
40+
done
41+
}
42+
43+
_plsdo_error() {
44+
>&2 echo "$@"
45+
}
46+
47+
# shellcheck disable=SC2016
48+
help[_plsdo_completion]='Print tab completion for $SHELL.
49+
50+
Redirect the output to a file that will be run when the shell starts,
51+
such as ~/.bashrc.
52+
53+
$ ./do _pldsdo_completion >> ~/.bash_complete/do
54+
'
55+
_plsdo_completion() {
56+
local shell; shell="$(basename "$SHELL" 2> /dev/null)"
57+
case "$shell" in
58+
bash)
59+
cat <<+++
60+
_dotslashdo_completions() {
61+
if ! command -v $0 > /dev/null; then return; fi
62+
if [ "\${#COMP_WORDS[@]}" != "2" ]; then return; fi
63+
COMPREPLY=(\$(compgen -W "\$($0 list)" "\${COMP_WORDS[1]}"))
64+
}
65+
complete -F _dotslashdo_completions $0
66+
+++
67+
;;
68+
"")
69+
_plsdo_error "Set \$SHELL to select tab completion."
70+
return 1 ;;
71+
*)
72+
_plsdo_error "No completetion for shell: $shell"
73+
return 1 ;;
74+
esac
75+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11

22
ARG GOLANG_VERSION
3-
FROM golang:${GOLANG_VERSION:-1.12-alpine} as golang
3+
FROM golang:${GOLANG_VERSION:-1.14-alpine} as golang
44
RUN apk add -U curl git bash
55
ENV CGO_ENABLED=0 \
66
PS1="# " \
77
GO111MODULE=on
8-
WORKDIR /go/src/gotest.tools/gotestsum
8+
ARG UID=1000
9+
RUN adduser --uid=${UID} --disabled-password devuser
10+
USER ${UID}:${UID}
11+
912

1013
FROM golang as tools
1114
RUN go get github.com/dnephin/filewatcher@v0.3.2
12-
RUN wget -O- -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s && \
15+
RUN wget -O- -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s && \
1316
mv bin/golangci-lint /go/bin
1417

18+
1519
FROM golang as dev
1620
COPY --from=tools /go/bin/filewatcher /usr/bin/filewatcher
1721
COPY --from=tools /go/bin/golangci-lint /usr/bin/golangci-lint
1822

23+
1924
FROM dev as dev-with-source
2025
COPY . .

do

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
source .plsdo.sh
4+
5+
binary() {
6+
mkdir -p dist
7+
go build -o dist/gotestsum .
8+
}
9+
10+
update-golden() {
11+
gotestsum -- ./testjson ./internal/junitxml -test.update-golden
12+
}
13+
14+
lint() {
15+
golangci-lint run -v
16+
}
17+
18+
go-mod-tidy() {
19+
go mod tidy
20+
git diff --stat --exit-code go.mod go.sum
21+
}
22+
23+
shell() {
24+
local tag; tag="$(_docker-build-dev)"
25+
docker run \
26+
--tty --interactive --rm \
27+
-v "$PWD:/work" \
28+
-v ~/.cache/go-build:/root/.cache/go-build \
29+
-v ~/go/pkg/mod:/go/pkg/mod \
30+
-w /work \
31+
"$tag" bash
32+
}
33+
34+
_docker-build-dev() {
35+
set -e
36+
local idfile=.plsdo/docker-build-dev-image-id
37+
local dockerfile=Dockerfile
38+
local tag=gotest.tools/gotestsum/builder
39+
if [ -f "$idfile" ] && [ "$dockerfile" -ot "$idfile" ]; then
40+
echo "$tag"
41+
return 0
42+
fi
43+
44+
mkdir -p .plsdo
45+
>&2 docker build \
46+
--iidfile "$idfile" \
47+
--file "$dockerfile" \
48+
--tag "$tag" \
49+
--build-arg "UID=$UID" \
50+
--target "dev" \
51+
.plsdo
52+
echo "$tag"
53+
}
54+
55+
_plsdo_run "$@"

dobi.yaml

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)