Skip to content

Commit c579413

Browse files
committed
*: add vendor, Makefile, tests with docker
Signed-off-by: Gyu-Ho Lee <[email protected]>
1 parent 779820b commit c579413

File tree

1,810 files changed

+430962
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,810 files changed

+430962
-143
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/bin
2+
.Dockerfile
3+
/*.log

.travis.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
language: go
1+
language: shell
22

3-
sudo: false
3+
sudo: required
44

5-
go:
6-
- go1.8.2
5+
services:
6+
- docker
7+
8+
before_install:
9+
- make build-docker-test
10+
- make compile-with-docker-test
711

812
script:
9-
- ./test
13+
- make docker-test

Dockerfile

+40-101
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,43 @@
1-
FROM ubuntu:17.04
2-
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
1+
FROM ubuntu:17.10
2+
3+
ENV ROOT_DIR /
4+
WORKDIR ${ROOT_DIR}
5+
ENV HOME /root
6+
7+
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
8+
&& apt-get -y update \
9+
&& apt-get -y install \
10+
build-essential \
11+
gcc \
12+
apt-utils \
13+
software-properties-common \
14+
curl \
15+
python \
16+
git \
17+
tar \
18+
bash \
19+
apt-transport-https \
20+
libssl-dev \
21+
&& rm /bin/sh \
22+
&& ln -s /bin/bash /bin/sh \
23+
&& ls -l $(which bash) \
24+
&& echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
25+
&& apt-get -y clean \
26+
&& rm -rf /var/lib/apt/lists/* \
27+
&& apt-get -y update \
28+
&& apt-get -y upgrade \
29+
&& apt-get -y dist-upgrade \
30+
&& apt-get -y update \
31+
&& apt-get -y upgrade \
32+
&& apt-get -y autoremove \
33+
&& apt-get -y autoclean
334

4-
##########################
5-
# invalidates cache for every commit
6-
RUN apt-get -y update
7-
RUN apt-get -y install curl
8-
RUN curl -o /version-git.json https://api.github.com/repos/gyuho/linux-inspect/git/refs/heads/master
9-
##########################
10-
11-
##########################
12-
# initialize Ubuntu
13-
RUN apt-get -y install \
14-
build-essential apt-utils gcc bash tar \
15-
apt-transport-https libssl-dev git
16-
17-
RUN apt-get -y update
18-
RUN apt-get -y upgrade
19-
RUN apt-get -y dist-upgrade
20-
RUN apt-get -y update
21-
RUN apt-get -y upgrade
22-
RUN apt-get -y autoremove
23-
RUN apt-get -y autoclean
24-
25-
RUN cat /etc/lsb-release > /version-container.txt
26-
RUN printf "\n" >> /version-container.txt
27-
RUN uname -a >> /version-container.txt
28-
RUN printf "\n" >> /version-container.txt
29-
##########################
30-
31-
##########################
32-
ENV HOME_DIR /
33-
WORKDIR ${HOME_DIR}
34-
ENV GIT_PATH github.com/gyuho/linux-inspect
35-
36-
# install Go
37-
RUN rm -rf /root/go1.4
38-
RUN mkdir -p /root/go1.4
39-
RUN curl -s https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | tar -v -C /root/go1.4 -xz --strip-components=1
40-
ENV GOROOT /goroot-tip
41-
RUN rm -rf ${GOROOT}
42-
ENV PATH ${GOROOT}/bin:/usr/local/go/bin:$PATH
43-
RUN git clone https://go.googlesource.com/go ${GOROOT}
44-
WORKDIR ${GOROOT}/src
45-
RUN git reset --hard HEAD
46-
RUN ./make.bash
47-
RUN ${GOROOT}/bin/go version
48-
RUN cp ${GOROOT}/bin/go /bin/go
49-
RUN go version
50-
WORKDIR ${HOME_DIR}
51-
52-
# install linux-inspect
53-
ENV GOPATH /gopath-tip
54-
ENV PATH ${GOPATH}/bin:/usr/local/go/bin:$PATH
55-
RUN mkdir -p ${GOPATH}/src/github.com/gyuho
56-
RUN git clone https://github.com/gyuho/linux-inspect --branch master ${GOPATH}/src/${GIT_PATH}
57-
WORKDIR ${GOPATH}/src/${GIT_PATH}
58-
RUN git reset --hard HEAD
59-
RUN go get -d -v ./cmd/linux-inspect
60-
RUN go get -d -v github.com/coreos/etcd/pkg/netutil
61-
RUN go install -v ./cmd/linux-inspect
62-
RUN linux-inspect -h
63-
64-
RUN ./test
65-
##########################
66-
67-
##########################
68-
ENV HOME_DIR /
69-
WORKDIR ${HOME_DIR}
70-
ENV GIT_PATH github.com/gyuho/linux-inspect
71-
72-
# install Go
7335
ENV GOROOT /usr/local/go
74-
ENV GOPATH /gopath-1.8.1
75-
ENV PATH ${GOPATH}/bin:/usr/local/go/bin:$PATH
76-
ENV GO_VERSION 1.8.1
36+
ENV GOPATH /go
37+
ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH}
38+
ENV GO_VERSION REPLACE_ME_GO_VERSION
7739
ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang
78-
RUN rm -rf ${GOROOT}
79-
RUN curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz
80-
RUN go version
81-
WORKDIR ${HOME_DIR}
82-
83-
# install linux-inspect
84-
ENV GOPATH /gopath-1.8.1
85-
ENV PATH ${GOPATH}/bin:/usr/local/go/bin:$PATH
86-
RUN mkdir -p ${GOPATH}/src/github.com/gyuho
87-
RUN git clone https://github.com/gyuho/linux-inspect --branch master ${GOPATH}/src/${GIT_PATH}
88-
WORKDIR ${GOPATH}/src/${GIT_PATH}
89-
RUN git reset --hard HEAD
90-
RUN go get -d -v ./cmd/linux-inspect
91-
RUN go get -d -v github.com/coreos/etcd/pkg/netutil
92-
RUN go install -v ./cmd/linux-inspect
93-
RUN linux-inspect -h
94-
95-
RUN ./test
96-
##########################
97-
98-
##########################
99-
WORKDIR ${GOPATH}/src/${GIT_PATH}
100-
RUN pwd
101-
102-
RUN cat /version-git.json
103-
RUN cat /version-container.txt
104-
##########################
40+
RUN rm -rf ${GOROOT} \
41+
&& curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \
42+
&& mkdir -p ${GOPATH}/src ${GOPATH}/bin \
43+
&& go version

Gopkg.lock

+97
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# https://github.com/coreos/etcd
2+
[[constraint]]
3+
name = "github.com/coreos/etcd"
4+
revision = "15bfc1b36162805e8a90ae747d955667870c2f95"
5+
6+
# https://github.com/dustin/go-humanize
7+
[[constraint]]
8+
name = "github.com/dustin/go-humanize"
9+
revision = "bb3d318650d48840a39aa21a027c6630e198e626"
10+
11+
# https://github.com/fatih/color
12+
[[constraint]]
13+
name = "github.com/fatih/color"
14+
revision = "5df930a27be2502f99b292b7cc09ebad4d0891f4"
15+
16+
# https://github.com/gyuho/dataframe
17+
[[constraint]]
18+
name = "github.com/gyuho/dataframe"
19+
revision = "008fc241adc41d4bd5c54b9f6564ef16407c030e"
20+
21+
# https://github.com/kr/pty
22+
[[constraint]]
23+
name = "github.com/kr/pty"
24+
revision = "95d05c1eef33a45bd58676b6ce28d105839b8d0b"
25+
26+
# https://github.com/olekukonko/tablewriter
27+
[[constraint]]
28+
name = "github.com/olekukonko/tablewriter"
29+
revision = "a7a4c189eb47ed33ce7b35f2880070a0c82a67d4"
30+
31+
# https://github.com/spf13/cobra
32+
[[constraint]]
33+
name = "github.com/spf13/cobra"
34+
revision = "1be1d2841c773c01bee8289f55f7463b6e2c2539"
35+
36+
# https://gopkg.in/yaml.v2
37+
[[constraint]]
38+
name = "gopkg.in/yaml.v2"
39+
revision = "287cf08546ab5e7e37d55a84f7ed3fd1db036de5"

Makefile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Example:
2+
# make gen
3+
# make build
4+
# GO_VERSION=1.8.5 make build-docker-test
5+
# make build-docker-test
6+
# make compile-with-docker-test
7+
# make test
8+
# make docker-test
9+
10+
.PHONY: gen
11+
gen:
12+
go install -v ./cmd/generate-df && generate-df
13+
go install -v ./cmd/generate-etc && generate-etc
14+
go install -v ./cmd/generate-proc && generate-proc
15+
go install -v ./cmd/generate-top && generate-top
16+
17+
.PHONY: build
18+
build:
19+
go build -o ./bin/linux-inspect -v ./cmd/linux-inspect
20+
./bin/linux-inspect -h
21+
22+
clean:
23+
rm -f ./*.log
24+
rm -f ./.Dockerfile
25+
26+
_GO_VERSION = 1.9.2
27+
ifdef GO_VERSION
28+
_GO_VERSION = $(GO_VERSION)
29+
endif
30+
31+
build-docker-test:
32+
$(info GO_VERSION: $(_GO_VERSION))
33+
@cat ./Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
34+
> ./.Dockerfile
35+
docker build \
36+
--tag gyuho/linux-inspect:go$(_GO_VERSION) \
37+
--file ./.Dockerfile .
38+
39+
compile-with-docker-test:
40+
$(info GO_VERSION: $(_GO_VERSION))
41+
docker run \
42+
--rm \
43+
--volume=`pwd`/:/go/src/github.com/gyuho/linux-inspect \
44+
gyuho/linux-inspect:go$(_GO_VERSION) \
45+
/bin/bash -c "cd /go/src/github.com/gyuho/linux-inspect && \
46+
go build -o ./bin/linux-inspect -v ./cmd/linux-inspect && \
47+
./bin/linux-inspect -h"
48+
49+
TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
50+
51+
.PHONY: test
52+
test:
53+
$(info GO_VERSION: $(_GO_VERSION))
54+
$(info log-file: test-$(TEST_SUFFIX).log)
55+
$(_TEST_OPTS) ./tests.sh 2>&1 | tee test-$(TEST_SUFFIX).log
56+
! egrep "(--- FAIL:|panic: test timed out|appears to have leaked|Too many goroutines)" -B50 -A10 test-$(TEST_SUFFIX).log
57+
58+
docker-test:
59+
$(info GO_VERSION: $(_GO_VERSION))
60+
$(info log-file: test-$(TEST_SUFFIX).log)
61+
docker run \
62+
--rm \
63+
--volume=`pwd`/:/go/src/github.com/gyuho/linux-inspect \
64+
gyuho/linux-inspect:go$(_GO_VERSION) \
65+
/bin/bash -c "cd /go/src/github.com/gyuho/linux-inspect && \
66+
go build -o ./bin/linux-inspect -v ./cmd/linux-inspect && \
67+
./tests.sh 2>&1 | tee test-$(TEST_SUFFIX).log"
68+
! egrep "(--- FAIL:|panic: test timed out|appears to have leaked|Too many goroutines)" -B50 -A10 test-$(TEST_SUFFIX).log

df/generated.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package df
22

3-
// updated at 2017-05-09 15:51:39.458012515 -0700 PDT
3+
// updated at 2017-11-23 20:37:48.722062 -0800 PST
44

55
// Row is 'df' command output row in Linux.
66
type Row struct {

ebpf/doc.go

-3
This file was deleted.

ebpf/epbf.go

-3
This file was deleted.

etc/generated.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package etc
22

3-
// updated at 2017-05-09 15:51:39.840738515 -0700 PDT
3+
// updated at 2017-11-23 20:37:49.328968 -0800 PST
44

55
// Mtab is '/etc/mtab' in Linux.
66
type Mtab struct {

0 commit comments

Comments
 (0)