blob: 5992dd6124f2591f693622075f041a0582a90ad6 (
plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
BIN = dive
BUILD_DIR = ./dist/dive_linux_amd64
BUILD_PATH = $(BUILD_DIR)/$(BIN)
PWD := ${CURDIR}
PRODUCTION_REGISTRY = docker.io
SHELL = /bin/bash -o pipefail
TEST_IMAGE = busybox:latest
all: gofmt clean build
## For CI
ci-unit-test:
go test -cover -v -race ./...
ci-static-analysis:
grep -R 'const allowTestDataCapture = false' runtime/ui/viewmodel
go vet ./...
gofmt -s -l . 2>&1 | grep -vE '^\.git/' | grep -vE '^\.cache/'
golangci-lint run
ci-install-go-tools:
mkdir -p ${HOME}/.local/bin
curl -sfL https://goreleaser.com/static/run > ${HOME}/.local/bin/goreleaser
chmod +x ${HOME}/.local/bin/goreleaser
ci-install-ci-tools:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${HOME}/.local/bin/
ci-docker-login:
echo '${DOCKER_PASSWORD}' | docker login -u '${DOCKER_USERNAME}' --password-stdin '${PRODUCTION_REGISTRY}'
ci-docker-logout:
docker logout '${PRODUCTION_REGISTRY}'
ci-publish-release:
goreleaser --rm-dist
ci-build-snapshot-packages:
goreleaser \
--snapshot \
--skip-publish \
--rm-dist
ci-release:
goreleaser release --rm-dist
# todo: add --pull=never when supported by host box
ci-test-production-image:
docker run \
--rm \
-t \
-v //var/run/docker.sock://var/run/docker.sock \
'${PRODUCTION_REGISTRY}/wagoodman/dive:latest' \
'${TEST_IMAGE}' \
--ci
ci-test-deb-package-install:
docker run \
-v //var/run/docker.sock://var/run/docker.sock \
-v /${PWD}://src \
-w //src \
ubuntu:latest \
/bin/bash -x -c "\
apt update && \
apt install -y curl && \
curl -L 'https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz' | \
tar -vxzf - docker/docker --strip-component=1 && \
mv docker /usr/local/bin/ &&\
docker version && \
apt install ./dist/dive_*_linux_amd64.deb -y && \
dive --version && \
dive '${TEST_IMAGE}' --ci \
"
ci-test-rpm-package-install:
docker run \
-v //var/run/docker.sock://var/run/docker.sock \
-v /${PWD}://src \
-w //src \
fedora:latest \
/bin/bash -x -c "\
curl -L 'https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz' | \
tar -vxzf - docker/docker --strip-component=1 && \
mv docker /usr/local/bin/ &&\
docker version && \
dnf install ./dist/dive_*_linux_amd64.rpm -y && \
dive --version && \
dive '${TEST_IMAGE}' --ci \
"
ci-test-linux-run:
ls -la ./dist
ls -la ./dist/dive_linux_amd64_v1
chmod 755 ./dist/dive_linux_amd64_v1/dive && \
./dist/dive_linux_amd64_v1/dive '${TEST_IMAGE}' --ci && \
./dist/dive_linux_amd64_v1/dive --source docker-archive .data/test-kaniko-image.tar --ci --ci-config .data/.dive-ci
# we're not attempting to test docker, just our ability to run on these systems. This avoids setting up docker in CI.
ci-test-mac-run:
chmod 755 ./dist/dive_darwin_amd64_v1/dive && \
./dist/dive_darwin_amd64_v1/dive --source docker-archive .data/test-docker-image.tar --ci --ci-config .data/.dive-ci
# we're not attempting to test docker, just our ability to run on these systems. This avoids setting up docker in CI.
ci-test-windows-run:
./dist/dive_windows_amd64_v1/dive --source docker-archive .data/test-docker-image.tar --ci --ci-config .data/.dive-ci
## For development
run: build
$(BUILD_PATH) build -t dive-example:latest -f .data/Dockerfile.example .
run-large: build
$(BUILD_PATH) amir20/clashleaders:latest
run-podman: build
podman build -t dive-example:latest -f .data/Dockerfile.example .
$(BUILD_PATH) localhost/dive-example:latest --engine podman
run-podman-large: build
$(BUILD_PATH) docker.io/amir20/clashleaders:latest --engine podman
run-ci: build
CI=true $(BUILD_PATH) dive-example:latest --ci-config .data/.dive-ci
build: gofmt
go build -o $(BUILD_PATH)
generate-test-data:
docker build -t dive-test:latest -f .data/Dockerfile.test-image . && docker image save -o .data/test-docker-image.tar dive-test:latest && echo 'Exported test data!'
test: gofmt
./.scripts/test-coverage.sh
dev:
docker run -ti --rm -v $(PWD):/app -w /app -v dive-pkg:/go/pkg/ golang:1.13 bash
clean:
rm -rf dist
go clean
gofmt:
go fmt -x ./...
|