Skip to content

Commit 4362363

Browse files
committed
running protos on docker
Signed-off-by: alanprot <[email protected]>
1 parent 63b2eed commit 4362363

File tree

7 files changed

+36
-30
lines changed

7 files changed

+36
-30
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -x
4+
VER="20.10.19"
5+
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
6+
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
7+
mkdir -vp ~/.docker/cli-plugins/
8+
curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
9+
chmod a+x ~/.docker/cli-plugins/docker-buildx
10+
mv /tmp/docker/* /usr/bin
11+
docker run --privileged --rm tonistiigi/binfmt --install all

.github/workflows/test-build-deploy.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,14 @@ jobs:
3434
steps:
3535
- name: Checkout Repo
3636
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37-
- name: Setup Git safe.directory
38-
run: |
39-
echo "this step is needed because when running in container, actions/checkout does not set safe.directory effectively."
40-
echo "See https://github.com/actions/runner/issues/2033. We should use --system instead of --global"
41-
git config --system --add safe.directory $GITHUB_WORKSPACE
42-
# Commands in the Makefile are hardcoded with an assumed file structure of the CI container
43-
# Symlink ensures paths specified in previous commands don’t break
4437
- name: Sym Link Expected Path to Workspace
4538
run: |
46-
mkdir -p /go/src/github.com/cortexproject/weaveworks-common
47-
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/weaveworks-common
39+
sudo mkdir -p /go/src/github.com/cortexproject/weaveworks-common
40+
sudo ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/weaveworks-common
41+
- name: Install Docker Client
42+
run: sudo ./.github/workflows/scripts/install-docker.sh
43+
- name: Go mod Vendor
44+
run: go mod vendor
4845
- name: CheckProtos
4946
run: make check-protos
5047

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ GO_FLAGS := -ldflags "-extldflags \"-static\" -linkmode=external -s -w" -tags ne
1414
PROTOC_IMAGE=namely/protoc:1.23_0
1515

1616
protos:
17-
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/weaveworks/common -w /go/src/github.com/weaveworks/common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/weaveworks/common --go_out=plugins=grpc:/go/src/ server/fake_server.proto
18-
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/weaveworks/common -w /go/src/github.com/weaveworks/common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/weaveworks/common --go_out=plugins=grpc:/go/src/ middleware/middleware_test/echo_server.proto
19-
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/weaveworks/common -w /go/src/github.com/weaveworks/common $(PROTOC_IMAGE) -I/go/src/github.com/weaveworks/common -I/go/src/github.com/weaveworks/common/vendor/github.com/gogo/protobuf/ --proto_path=/go/src/github.com/weaveworks/common --gogofast_out=plugins=grpc:/go/src/ httpgrpc/httpgrpc.proto
17+
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/cortexproject/weaveworks-common -w /go/src/github.com/cortexproject/weaveworks-common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/cortexproject/weaveworks-common --go_out=plugins=grpc:/go/src/ server/fake_server.proto
18+
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/cortexproject/weaveworks-common -w /go/src/github.com/cortexproject/weaveworks-common $(PROTOC_IMAGE) --proto_path=/go/src/github.com/cortexproject/weaveworks-common --go_out=plugins=grpc:/go/src/ middleware/middleware_test/echo_server.proto
19+
docker run $(RM) --user $(id -u):$(id -g) -v $(shell pwd):/go/src/github.com/cortexproject/weaveworks-common -w /go/src/github.com/cortexproject/weaveworks-common $(PROTOC_IMAGE) -I/go/src/github.com/cortexproject/weaveworks-common -I/go/src/github.com/cortexproject/weaveworks-common/vendor/github.com/gogo/protobuf/ --proto_path=/go/src/github.com/cortexproject/weaveworks-common --gogofast_out=plugins=grpc:/go/src/ httpgrpc/httpgrpc.proto
2020

2121
protos: $(GENERATED_PROTOS)
2222

instrument/instrument_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestCollectedRequest(t *testing.T) {
6060

6161
func TestCollectedRequest_Error(t *testing.T) {
6262
c := &spyCollector{}
63-
require.NoError(t, instrument.CollectedRequest(context.Background(), "test", c, nil, func(_ context.Context) error {
63+
require.Error(t, instrument.CollectedRequest(context.Background(), "test", c, nil, func(_ context.Context) error {
6464
return errors.New("boom")
6565
}))
6666
assert.True(t, c.before)

mflag/flag_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestEverything(t *testing.T) {
8585
require.NoError(t, Set("test_uint64", "1"))
8686
require.NoError(t, Set("test_string", "1"))
8787
require.NoError(t, Set("test_float64", "1"))
88-
require.NoError(t, Set("testrequire.NoError(_duration", "1s"))
88+
require.NoError(t, Set("test_duration", "1s"))
8989
desired = "1"
9090
Visit(visitor)
9191
if len(m) != 8 {
@@ -276,7 +276,7 @@ func testPanic(f *FlagSet, t *testing.T) {
276276
args := []string{
277277
"-int", "21",
278278
}
279-
require.NoError(t, f.Parse(args))
279+
f.Parse(args) //nolint:errcheck
280280
}
281281

282282
func TestParsePanic(t *testing.T) {
@@ -368,7 +368,7 @@ func TestSetOutput(t *testing.T) {
368368
var buf bytes.Buffer
369369
flags.SetOutput(&buf)
370370
flags.Init("test", ContinueOnError)
371-
require.NoError(t, flags.Parse([]string{"-unknown"}))
371+
flags.Parse([]string{"-unknown"}) //nolint:errcheck
372372
if out := buf.String(); !strings.Contains(out, "-unknown") {
373373
t.Logf("expected output mentioning unknown; got %q", out)
374374
}

middleware/logging_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ func TestBadWriteLogging(t *testing.T) {
3838
Log: logging.Logrus(logrusLogger),
3939
}
4040
handler := func(w http.ResponseWriter, r *http.Request) {
41-
_, err := io.WriteString(w, "<html><body>Hello World!</body></html>")
42-
require.NoError(t, err)
41+
io.WriteString(w, "<html><body>Hello World!</body></html>") //nolint:errcheck
4342
}
4443
loggingHandler := loggingMiddleware.Wrap(http.HandlerFunc(handler))
4544

@@ -129,8 +128,7 @@ func TestLoggingRequestsAtInfoLevel(t *testing.T) {
129128
LogRequestAtInfoLevel: true,
130129
}
131130
handler := func(w http.ResponseWriter, r *http.Request) {
132-
_, err := io.WriteString(w, "<html><body>Hello World!</body></html>")
133-
require.NoError(t, err)
131+
io.WriteString(w, "<html><body>Hello World!</body></html>") //nolint:errcheck
134132
}
135133
loggingHandler := loggingMiddleware.Wrap(http.HandlerFunc(handler))
136134

server/server_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ func TestDefaultAddresses(t *testing.T) {
125125
w.WriteHeader(204)
126126
})
127127

128-
go require.NoError(t, server.Run())
128+
go server.Run() //nolint:errcheck
129129
defer server.Shutdown()
130130

131131
conn, err := grpc.Dial("localhost:9095", grpc.WithTransportCredentials(insecure.NewCredentials()))
132132
require.NoError(t, err)
133-
defer require.NoError(t, conn.Close())
133+
defer conn.Close() //nolint:errcheck
134134

135135
empty := protobuf.Empty{}
136136
client := NewFakeServerClient(conn)
@@ -167,11 +167,11 @@ func TestErrorInstrumentationMiddleware(t *testing.T) {
167167
w.WriteHeader(http.StatusNotFound)
168168
})
169169

170-
go require.NoError(t, server.Run())
170+
go server.Run() //nolint:errcheck
171171

172172
conn, err := grpc.Dial("localhost:1234", grpc.WithTransportCredentials(insecure.NewCredentials()))
173173
require.NoError(t, err)
174-
defer require.NoError(t, conn.Close())
174+
defer conn.Close() //nolint:errcheck
175175

176176
empty := protobuf.Empty{}
177177
client := NewFakeServerClient(conn)
@@ -306,7 +306,7 @@ func TestHTTPInstrumentationMetrics(t *testing.T) {
306306
_ = cancelableSleep(r.Context(), time.Second*10)
307307
})
308308

309-
go require.NoError(t, server.Run())
309+
go server.Run() //nolint:errcheck
310310

311311
callThenCancel := func(f func(ctx context.Context) error) error {
312312
ctx, cancel := context.WithCancel(context.Background())
@@ -501,7 +501,7 @@ func TestMiddlewareLogging(t *testing.T) {
501501
w.WriteHeader(500)
502502
})
503503

504-
go require.NoError(t, server.Run())
504+
go server.Run() //nolint:errcheck
505505
defer server.Shutdown()
506506

507507
req, err := http.NewRequest("GET", "http://127.0.0.1:9192/error500", nil)
@@ -550,7 +550,7 @@ func TestTLSServer(t *testing.T) {
550550
fakeServer := FakeServer{}
551551
RegisterFakeServerServer(server.GRPC, fakeServer)
552552

553-
go require.NoError(t, server.Run())
553+
go server.Run() //nolint:errcheck
554554
defer server.Shutdown()
555555

556556
clientCert, err := tls.LoadX509KeyPair("certs/client.crt", "certs/client.key")
@@ -574,7 +574,7 @@ func TestTLSServer(t *testing.T) {
574574
client := &http.Client{Transport: tr}
575575
res, err := client.Get("https://localhost:9193/testhttps")
576576
require.NoError(t, err)
577-
defer require.NoError(t, res.Body.Close())
577+
defer res.Body.Close() //nolint:errcheck
578578

579579
require.Equal(t, res.StatusCode, http.StatusOK)
580580

@@ -585,7 +585,7 @@ func TestTLSServer(t *testing.T) {
585585

586586
conn, err := grpc.Dial("localhost:9194", grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
587587
require.NoError(t, err)
588-
defer require.NoError(t, conn.Close())
588+
defer conn.Close() //nolint:errcheck
589589

590590
empty := protobuf.Empty{}
591591
grpcClient := NewFakeServerClient(conn)
@@ -645,7 +645,7 @@ func TestLogSourceIPs(t *testing.T) {
645645
w.WriteHeader(500)
646646
})
647647

648-
go require.NoError(t, server.Run())
648+
go server.Run() //nolint:errcheck
649649
defer server.Shutdown()
650650

651651
require.Empty(t, fake.sourceIPs)

0 commit comments

Comments
 (0)