File: do

package info (click to toggle)
gotestsum 0.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,076 kB
  • sloc: sh: 86; makefile: 18
file content (75 lines) | stat: -rwxr-xr-x 1,688 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash

source .plsdo.sh

binary() {
    mkdir -p dist
    go build -o dist/gotestsum .
}

update-golden() {
    _update-golden
    GOLANG_VERSION=1.13-alpine ./do shell bash -c 'go build; PATH=$PATH:. ./do _update-golden'
}

_update-golden() {
    gotestsum -- . ./testjson ./internal/junitxml ./cmd/tool/slowest -test.update-golden
}

lint() {
    golangci-lint run -v
}

go-mod-tidy() {
    go mod tidy
    git diff --stat --exit-code go.mod go.sum
}

help[shell]='Run a shell in a golang docker container.

Env vars:

GOLANG_VERSION - the docker image tag used to build the image.
'
shell() {
    local image; image="$(_docker-build-dev)"
    docker run \
        --tty --interactive --rm \
        -v "$PWD:/work" \
        -v ~/.cache/go-build:/root/.cache/go-build \
        -v ~/go/pkg/mod:/go/pkg/mod \
        -w /work \
        "$image" \
        "${@-bash}"
}

_docker-build-dev() {
    set -e
    local idfile=".plsdo/docker-build-dev-image-id-${GOLANG_VERSION-default}"
    local dockerfile=Dockerfile
    local tag=gotest.tools/gotestsum/builder
    if [ -f "$idfile" ] && [ "$dockerfile" -ot "$idfile" ]; then
        cat "$idfile"
        return 0
    fi

    mkdir -p .plsdo
    >&2 docker build \
        --iidfile "$idfile"  \
        --file "$dockerfile" \
        --build-arg "UID=$UID" \
        --build-arg GOLANG_VERSION \
        --target "dev" \
        .plsdo
    cat "$idfile"
}

help[godoc]="Run godoc locally to preview package documentation."
godoc() {
    local url; url="http://localhost:6060/pkg/$(go list)/"
    command -v xdg-open && xdg-open "$url" &
    command -v open && open "$url" &
    command godoc -http=:6060
}

_plsdo_run "$@"