diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..64302ec8a --- /dev/null +++ b/Makefile @@ -0,0 +1,60 @@ + +# Makefile for scaleway-sdk-go + +WORKDIR := $(shell pwd) + +# Go versions to test against (matching GitHub Actions) +GO_VERSIONS := 1.23.x 1.24.x + +# List all Go packages (excluding vendor and testdata) +PKGS := $(shell go list ./... | grep -v /testdata) + +# Build architectures to test +ARCHS := 386 amd64 arm arm64 + +# Platforms to test +PLATFORMS := windows-latest macos-latest + +.PHONY: all build install-dependencies format format-check lint test test-coverage doc prebuild generate-alias generate-packages generate-global-sdk-package publish format-generated clean check-tokens build-arch-test build-platform-test unit-test + +all: build + +build: + go build -v ./... + +install-dependencies: + go mod tidy + go mod download + +format: + go fmt ./... + ./scripts/lint.sh --write + +format-check: + @echo "Checking code formatting..." + @if [ -n "$$(gofmt -l .)" ]; then \ + echo "Files not formatted:"; \ + gofmt -l .; \ + exit 1; \ + fi + @echo "Code formatting is correct" + +lint: + ./scripts/lint.sh + +test: + CGO_ENABLED=0 go test -v -race -cover $(PKGS) + +test-coverage: + CGO_ENABLED=0 go test -coverprofile=coverage.out $(PKGS) + go tool cover -func=coverage.out + go tool cover -html=coverage.out -o coverage.html + +generate: + buf generate --timeout 0 + make format + + +format-generated: + ./formatting/run.sh -i "./api" + diff --git a/formatting/run.sh b/formatting/run.sh new file mode 100755 index 000000000..0c64bdbc2 --- /dev/null +++ b/formatting/run.sh @@ -0,0 +1,19 @@ +#!/bin/bash -e + +while getopts i: flag +do + case "${flag}" in + i) INPUT_DIR=${OPTARG};; + esac +done + +while getopts i: flag +do + case "${flag}" in + i) INPUT_DIR=${OPTARG};; + esac +done + +go run golang.org/x/tools/cmd/goimports@latest -w $INPUT_DIR || { echo "Failed to clean imports in $INPUT_DIR"; exit 1; } + +echo "Import cleaning completed." \ No newline at end of file