Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is it used?


# 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"

19 changes: 19 additions & 0 deletions formatting/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this useful?


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."
Loading