Skip to content

Commit 3d2db24

Browse files
committed
chore(ci): github workflows
Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>
1 parent 98d006a commit 3d2db24

5 files changed

Lines changed: 96 additions & 13 deletions

File tree

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: /
5+
schedule:
6+
interval: daily
7+
rebase-strategy: disabled
8+
commit-message:
9+
prefix: "feat(deps)"
10+
- package-ecosystem: github-actions
11+
directory: /
12+
schedule:
13+
interval: daily
14+
rebase-strategy: disabled
15+
commit-message:
16+
prefix: "chore(ci)"

.github/workflows/ci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
pull_request:
7+
branches: [ "*" ]
8+
9+
jobs:
10+
diff:
11+
name: diff
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
fetch-depth: 0
17+
- uses: actions/setup-go@v6
18+
with:
19+
go-version-file: go.mod
20+
- run: make proto
21+
- name: Checking if generated protobuffer files are not aligned
22+
run: if [[ $(git diff | wc -l) -gt 0 ]]; then echo ">>> Untracked generated files have not been committed" && git --no-pager diff && exit 1; fi
23+
- name: Checking if missing untracked files for generated protobuf
24+
run: test -z "$(git ls-files --others --exclude-standard 2> /dev/null)"
25+
golangci:
26+
name: lint
27+
runs-on: ubuntu-22.04
28+
steps:
29+
- uses: actions/checkout@v5
30+
- uses: actions/setup-go@v6
31+
with:
32+
go-version-file: go.mod
33+
- name: Run golangci-lint
34+
run: make lint

.github/workflows/latest.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Container image build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
ko:
10+
permissions:
11+
contents: read
12+
packages: write
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- uses: actions/checkout@v5
16+
with:
17+
fetch-depth: 0
18+
- uses: actions/setup-go@v6
19+
with:
20+
go-version-file: go.mod
21+
- name: Login to GitHub Container Registry
22+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
23+
- name: "ko: install"
24+
run: make ko
25+
- name: "ko: build and push latest tag"
26+
run: make VERSION=latest KO_LOCAL=false KO_PUSH=true oci-build

Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ $(LOCALBIN):
3030
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
3131
KO ?= $(LOCALBIN)/ko
3232
PROTOC ?= $(LOCALBIN)/protoc
33-
PROTOC_GO ?= $(LOCALBIN)/protoc-gen-go-grpc
33+
PROTOC_GEN_GO ?= $(LOCALBIN)/protoc-gen-go
34+
PROTOC_GEN_GO_GRCP ?= $(LOCALBIN)/protoc-gen-go-grpc
3435

3536
# OCI variables
3637
OCI_REGISTRY ?= ghcr.io
@@ -47,7 +48,8 @@ PROTO_DIR = pkg/proto
4748
PROTO_FILES = $(PROTO_DIR)/security.proto
4849
PROTO_GEN = $(PROTO_DIR)/security.pb.go $(PROTO_DIR)/security_grpc.pb.go
4950
PROTOC_VERSION := 28.2
50-
PROTOC_GO_VERSION := 1.5.1
51+
PROTOC_GEN_GO_VERSION := 1.27.1
52+
PROTOC_GEN_GO_GRCP_VERSION := 1.5.1
5153

5254
# Default target - show help
5355
.DEFAULT_GOAL := help
@@ -61,10 +63,15 @@ ko: $(KO) ## Download ko locally if necessary.
6163
$(KO): $(LOCALBIN)
6264
test -s $(LOCALBIN)/ko || GOBIN=$(LOCALBIN) CGO_ENABLED=0 go install -ldflags="-s -w" github.com/google/ko@v0.18.0
6365

64-
.PHONY: protoc_go
65-
protoc_go: $(PROTOC_GO) ## Download protoc-gen-go-grpc locally if necessary.
66-
$(PROTOC_GO): $(LOCALBIN)
67-
test -s $(LOCALBIN)/protoc-gen-go-grpc || GOBIN=$(LOCALBIN) CGO_ENABLED=0 go install -ldflags="-s -w" google.golang.org/grpc/cmd/protoc-gen-go-grpc@v$(PROTOC_GO_VERSION)
66+
.PHONY: protoc_gen_go_grpc
67+
protoc_gen_go_grpc: $(PROTOC_GEN_GO_GRCP) ## Download protoc-gen-go-grpc locally if necessary.
68+
$(PROTOC_GEN_GO_GRCP): $(LOCALBIN)
69+
test -s $(LOCALBIN)/protoc-gen-go-grpc || GOBIN=$(LOCALBIN) CGO_ENABLED=0 go install -ldflags="-s -w" google.golang.org/grpc/cmd/protoc-gen-go-grpc@v$(PROTOC_GEN_GO_GRCP_VERSION)
70+
71+
.PHONY: protoc_gen_go
72+
protoc_gen_go: $(PROTOC_GEN_GO) ## Download protoc-gen-go locally if necessary.
73+
$(PROTOC_GEN_GO): $(LOCALBIN)
74+
test -s $(LOCALBIN)/protoc-gen-go || GOBIN=$(LOCALBIN) CGO_ENABLED=0 go install -ldflags="-s -w" google.golang.org/protobuf/cmd/protoc-gen-go@v$(PROTOC_GEN_GO_VERSION)
6875

6976
.PHONY: protoc
7077
protoc: $(PROTOC) ## Download protoc locally if necessary.
@@ -88,7 +95,7 @@ help: ## Display this help message
8895

8996
##@ Development
9097

91-
proto: protoc protoc_go ## Generate protobuf code
98+
proto: protoc protoc_gen_go protoc_gen_go_grpc ## Generate protobuf code
9299
PATH=$$PATH:$(LOCALBIN) $(PROTOC) --go_out=. --go_opt=paths=source_relative \
93100
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
94101
$(PROTO_FILES)
@@ -119,7 +126,7 @@ KO_PUSH ?= false
119126

120127
oci-build: $(KO) ## Build OCI artefact
121128
KOCACHE=/tmp/ko-cache KO_DOCKER_REPO=${OCI_REGISTRY}/${OCI_REPO} \
122-
$(KO) build . --bare --tags=$(VERSION) --local=$(KO_LOCAL) --push=$(KO_PUSH)
129+
$(KO) build . --bare --sbom=none --tags=$(VERSION) --local=$(KO_LOCAL) --push=$(KO_PUSH)
123130

124131
oci-run: oci-build ## Run OCI container locally (for testing)
125132
@docker run --rm -it \

pkg/proto/security.pb.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)