Skip to content

Commit

Permalink
running protos on docker
Browse files Browse the repository at this point in the history
Signed-off-by: alanprot <[email protected]>
  • Loading branch information
alanprot committed Nov 29, 2024
1 parent 63b2eed commit 3bc4d22
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/scripts/install-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -x
VER="20.10.19"
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mkdir -vp ~/.docker/cli-plugins/
curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
mv /tmp/docker/* /usr/bin
docker run --privileged --rm tonistiigi/binfmt --install all
17 changes: 8 additions & 9 deletions .github/workflows/test-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Git safe.directory
run: |
echo "this step is needed because when running in container, actions/checkout does not set safe.directory effectively."
echo "See https://github.com/actions/runner/issues/2033. We should use --system instead of --global"
git config --system --add safe.directory $GITHUB_WORKSPACE
# Commands in the Makefile are hardcoded with an assumed file structure of the CI container
# Symlink ensures paths specified in previous commands don’t break
- name: Sym Link Expected Path to Workspace
run: |
mkdir -p /go/src/github.com/cortexproject/weaveworks-common
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/weaveworks-common
sudo mkdir -p /go/src/github.com/cortexproject/weaveworks-common
sudo ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/weaveworks-common
- name: Install Docker Client
run: sudo ./.github/workflows/scripts/install-docker.sh
- name: Go mod Vendor
run: go mod vendor
- name: Ls
run: ls /go/src/github.com/cortexproject/weaveworks-common
- name: CheckProtos
run: make check-protos

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ GO_FLAGS := -ldflags "-extldflags \"-static\" -linkmode=external -s -w" -tags ne
PROTOC_IMAGE=namely/protoc:1.23_0

protos:
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
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
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
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
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
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

protos: $(GENERATED_PROTOS)

Expand Down
2 changes: 1 addition & 1 deletion instrument/instrument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestCollectedRequest(t *testing.T) {

func TestCollectedRequest_Error(t *testing.T) {
c := &spyCollector{}
require.NoError(t, instrument.CollectedRequest(context.Background(), "test", c, nil, func(_ context.Context) error {
require.Error(t, instrument.CollectedRequest(context.Background(), "test", c, nil, func(_ context.Context) error {
return errors.New("boom")
}))
assert.True(t, c.before)
Expand Down
6 changes: 3 additions & 3 deletions mflag/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestEverything(t *testing.T) {
require.NoError(t, Set("test_uint64", "1"))
require.NoError(t, Set("test_string", "1"))
require.NoError(t, Set("test_float64", "1"))
require.NoError(t, Set("testrequire.NoError(_duration", "1s"))
require.NoError(t, Set("test_duration", "1s"))
desired = "1"
Visit(visitor)
if len(m) != 8 {
Expand Down Expand Up @@ -276,7 +276,7 @@ func testPanic(f *FlagSet, t *testing.T) {
args := []string{
"-int", "21",
}
require.NoError(t, f.Parse(args))
f.Parse(args) //nolint:errcheck
}

func TestParsePanic(t *testing.T) {
Expand Down Expand Up @@ -368,7 +368,7 @@ func TestSetOutput(t *testing.T) {
var buf bytes.Buffer
flags.SetOutput(&buf)
flags.Init("test", ContinueOnError)
require.NoError(t, flags.Parse([]string{"-unknown"}))
flags.Parse([]string{"-unknown"}) //nolint:errcheck
if out := buf.String(); !strings.Contains(out, "-unknown") {
t.Logf("expected output mentioning unknown; got %q", out)
}
Expand Down
6 changes: 2 additions & 4 deletions middleware/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func TestBadWriteLogging(t *testing.T) {
Log: logging.Logrus(logrusLogger),
}
handler := func(w http.ResponseWriter, r *http.Request) {
_, err := io.WriteString(w, "<html><body>Hello World!</body></html>")
require.NoError(t, err)
io.WriteString(w, "<html><body>Hello World!</body></html>") //nolint:errcheck
}
loggingHandler := loggingMiddleware.Wrap(http.HandlerFunc(handler))

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

Expand Down

0 comments on commit 3bc4d22

Please sign in to comment.