Skip to content

Commit b2d2781

Browse files
author
Ben Walker
committed
storage: Simplify makefile to remove docker
Signed-off-by: Ben Walker <[email protected]>
1 parent d3786b8 commit b2d2781

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

.github/workflows/storage.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,29 @@ jobs:
3232
- name: Checkout repository
3333
uses: actions/checkout@v3
3434

35-
- name: Set up QEMU
36-
uses: docker/setup-qemu-action@v2
35+
- name: Setup Go
36+
uses: actions/setup-go@v2
3737

38-
# Workaround: https://github.com/docker/build-push-action/issues/461
39-
- name: Setup Docker buildx
40-
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325
38+
- name: Install Protoc
39+
uses: arduino/setup-protoc@v1
40+
41+
- name: Install protoc-gen-go
42+
run: go install google.golang.org/protobuf/cmd/[email protected]
43+
44+
- name: Install google-api-linter
45+
run: go install github.com/googleapis/api-linter/cmd/api-linter@latest
4146

4247
- name: Build protobufs
43-
run: make
48+
run: cd storage && make python go cpp
4449
working-directory: storage
4550

4651
- name: Check uncomitted auto generated protobufs
4752
run: git diff --exit-code
4853
working-directory: storage
4954

55+
- name: Run google-api-linter
56+
run: cd storage && api-linter v1/*proto
57+
5058
- name: Upload build artifact
5159
uses: actions/upload-artifact@v3
5260
with:

storage/Makefile

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@
22
# Copyright (C) 2022 Intel Corporation
33
# Copyright (c) 2022 Dell Inc, or its subsidiaries.
44

5-
all:
6-
rm -rf ./v1/{autogen.md,gen}
7-
mkdir -p ./v1/gen/{go,cpp,python}
5+
# Make a variable named ','. Used to pass arguments with commas to protoc_compile.
6+
, := ,
87

9-
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l go -o ./v1/gen/go/ --go-source-relative
10-
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l cpp -o ./v1/gen/cpp/ --go-source-relative
11-
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l python -o ./v1/gen/python/ --go-source-relative
8+
CURRENT_VERSION := v1
129

13-
# protoc-gen-doc doesn't support proto include paths parameter so we have to copy
14-
# common included files to the proto directory
15-
cp ../common/v1/uuid.proto "${PWD}"/v1
16-
cp ../common/v1/object_key.proto "${PWD}"/v1
10+
define protoc_compile
11+
mkdir -p $(CURRENT_VERSION)/gen/$(1)
12+
protoc --proto_path=../common/$(CURRENT_VERSION) --proto_path=$(CURRENT_VERSION) \
13+
--$(1)_out=$(CURRENT_VERSION)/gen/$(1) \
14+
$(2) \
15+
$(CURRENT_VERSION)/*.proto
16+
endef
1717

18-
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -v "${PWD}"/v1:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,autogen.md
19-
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -w /out --entrypoint=sh ghcr.io/docker-multiarch/google-api-linter:1.36.0 -c "api-linter /out/*.proto --output-format summary"
18+
all: python cpp go doc lint
2019

21-
# remove common included files from the proto directory
22-
rm "${PWD}"/v1/uuid.proto
23-
rm "${PWD}"/v1/object_key.proto
20+
python:
21+
$(call protoc_compile,python,)
22+
23+
cpp:
24+
$(call protoc_compile,cpp,)
25+
26+
go:
27+
$(call protoc_compile,go,)
28+
mv $(CURRENT_VERSION)/gen/go/github.com/opiproject/opi-api/storage/v1/gen/go/* $(CURRENT_VERSION)/gen/go/
29+
30+
doc:
31+
$(call protoc_compile,doc,--doc_opt=markdown$(,)autogen.md)
32+
33+
lint:
34+
$(call protoc_compile,lint)
35+
36+
clean:
37+
rm -rf gen

0 commit comments

Comments
 (0)