ci: Add workflow

This commit is contained in:
Marco Franssen
2025-12-18 16:54:59 +01:00
parent b092f590f0
commit 3c44698e46
2 changed files with 56 additions and 8 deletions

35
.github/workflows/ci.yaml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: CI
on:
push:
paths:
- '.github/workflows/ci.yaml'
- 'go.*'
- '**/*.go'
- 'Dockerfile'
- 'Makefile'
pull_request:
paths:
- '.github/workflows/ci.yaml'
- 'go.*'
- '**/*.go'
- 'Dockerfile'
- 'Makefile'
jobs:
build:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6.0.1
- name: Set up Go
uses: actions/setup-go@v6.1.0
with:
go-version-file: 'go.mod'
- name: Build binary
run: make build

View File

@@ -13,27 +13,40 @@ GOARM?=""
BUILD_ENV=CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM)
BUILD_FLAGS="-s -w -extldflags \"-static\""
.PHONY: all clean synology-csi-driver synocli test docker-build
.PHONY: all
all: build
all: synology-csi-driver
.PHONY: FORCE
FORCE: ;
synology-csi-driver:
@mkdir -p bin
$(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o ./bin/synology-csi-driver ./
.PHONY: build
build: bin/synology-csi-driver bin/synocli
bin:
@mkdir -p $@
bin/synology-csi-driver: bin FORCE
@echo "Compiling $@"
@$(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o $@ ./
.PHONY: docker-build
docker-build:
docker build -f Dockerfile -t $(IMAGE_TAG) .
.PHONY: docker-build-multiarch
docker-build-multiarch:
docker buildx build -t $(IMAGE_TAG) --platform linux/amd64,linux/arm/v7,linux/arm64 . --push
synocli:
@mkdir -p bin
$(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o ./bin/synocli ./synocli
bin/synocli: bin FORCE
@echo "Compiling $@"
@$(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o $@ ./synocli
.PHONY: test
test:
go clean -testcache
go test -v ./test/...
.PHONY: clean
clean:
-rm -rf ./bin