2
0

justfile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. commonenv := "CGO_ENABLED=0"
  2. version := `./tools/image-tag`
  3. commit := `git rev-parse --short HEAD`
  4. default:
  5. just --list
  6. # run core unit tests
  7. test-core:
  8. {{commonenv}} cd ./core && go test ./... -coverprofile=coverage.out
  9. {{commonenv}} cd ./core && go vet ./...
  10. # Run unit tests
  11. test: test-core
  12. {{commonenv}} go test ./... -coverprofile=coverage.out
  13. {{commonenv}} go vet ./...
  14. # Run unit tests and integration tests
  15. test-integration:
  16. {{commonenv}} INTEGRATION=true go test ./... -coverprofile=coverage.out
  17. # Compile a local binary
  18. build-local:
  19. cd ./cmd/costmodel && \
  20. {{commonenv}} go build \
  21. -ldflags \
  22. "-X github.com/opencost/opencost/core/pkg/version.Version={{version}} \
  23. -X github.com/opencost/opencost/core/pkg/version.GitCommit={{commit}}" \
  24. -o ./costmodel
  25. # Build multiarch binaries
  26. build-binary VERSION=version:
  27. cd ./cmd/costmodel && \
  28. {{commonenv}} GOOS=linux GOARCH=amd64 go build \
  29. -ldflags \
  30. "-X github.com/opencost/opencost/core/pkg/version.Version={{VERSION}} \
  31. -X github.com/opencost/opencost/core/pkg/version.GitCommit={{commit}}" \
  32. -o ./costmodel-amd64
  33. cd ./cmd/costmodel && \
  34. {{commonenv}} GOOS=linux GOARCH=arm64 go build \
  35. -ldflags \
  36. "-X github.com/opencost/opencost/core/pkg/version.Version={{VERSION}} \
  37. -X github.com/opencost/opencost/core/pkg/version.GitCommit={{commit}}" \
  38. -o ./costmodel-arm64
  39. # Build and push a multi-arch Docker image
  40. build IMAGE_TAG RELEASE_VERSION: test (build-binary RELEASE_VERSION)
  41. docker buildx build \
  42. --rm \
  43. --platform "linux/amd64" \
  44. -f 'Dockerfile.cross' \
  45. --build-arg binarypath=./cmd/costmodel/costmodel-amd64 \
  46. --build-arg version={{RELEASE_VERSION}} \
  47. --build-arg commit={{commit}} \
  48. --provenance=false \
  49. -t {{IMAGE_TAG}}-amd64 \
  50. --push \
  51. .
  52. docker buildx build \
  53. --rm \
  54. --platform "linux/arm64" \
  55. -f 'Dockerfile.cross' \
  56. --build-arg binarypath=./cmd/costmodel/costmodel-arm64 \
  57. --build-arg version={{RELEASE_VERSION}} \
  58. --build-arg commit={{commit}} \
  59. --provenance=false \
  60. -t {{IMAGE_TAG}}-arm64 \
  61. --push \
  62. .
  63. manifest-tool push from-args \
  64. --platforms "linux/amd64,linux/arm64" \
  65. --template {{IMAGE_TAG}}-ARCH \
  66. --target {{IMAGE_TAG}}
  67. validate-protobuf:
  68. ./generate.sh
  69. git diff --exit-code