Skip to content

Commit ea79db1

Browse files
Alex BotenAneurysm9
andauthored
[chore] update makefile to include test/tidy (aws-observability#402)
* [chore] update makefile to include test/tidy This updates the build command to also run tests and tidy. Signed-off-by: Alex Boten <[email protected]> * separate test/tidy into their own gh jobs * Apply suggestions from code review Co-authored-by: Anthony Mirabella <[email protected]> Signed-off-by: Alex Boten <[email protected]> Co-authored-by: Anthony Mirabella <[email protected]>
1 parent f308144 commit ea79db1

File tree

5 files changed

+114
-1
lines changed

5 files changed

+114
-1
lines changed

.github/workflows/ci-collector.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,41 @@ on:
1515
- main
1616

1717
jobs:
18+
tidy:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-go@v3
23+
with:
24+
go-version: '^1.19.4'
25+
- uses: actions/cache@v3
26+
with:
27+
path: ~/go/pkg/mod
28+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29+
restore-keys: |
30+
${{ runner.os }}-go-
31+
- name: Tidy
32+
run: make gotidy
33+
working-directory: collector
34+
test:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: actions/setup-go@v3
39+
with:
40+
go-version: '^1.19.4'
41+
- uses: actions/cache@v3
42+
with:
43+
path: ~/go/pkg/mod
44+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
45+
restore-keys: |
46+
${{ runner.os }}-go-
47+
- name: Run tests
48+
run: make gotest
49+
working-directory: collector
1850
build:
1951
runs-on: ubuntu-latest
52+
needs: [test, tidy]
2053
strategy:
2154
matrix:
2255
architecture: [ amd64, arm64 ]

collector/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include ./Makefile.Common
2+
13
BASE_SPACE:=$(shell pwd)
24
BUILD_SPACE:=$(BASE_SPACE)/build
35
BUCKET_NAME:=lambda-artifacts-$(shell dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \t\n')
@@ -12,6 +14,20 @@ BUILD_INFO_IMPORT_PATH=main
1214
LDFLAGS=-ldflags "-s -w -X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA) -X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION) \
1315
-X github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter.collectorDistribution=opentelemetry-collector-lambda"
1416

17+
ALL_MODULES := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./' )
18+
19+
GOMODULES = $(ALL_MODULES) $(PWD)
20+
21+
# Define a delegation target for each module
22+
.PHONY: $(GOMODULES)
23+
$(GOMODULES):
24+
@echo "Running target '$(TARGET)' in module '$@'"
25+
$(MAKE) -C $@ $(TARGET)
26+
27+
# Triggers each module's delegation target
28+
.PHONY: for-all-target
29+
for-all-target: $(GOMODULES)
30+
1531
clean:
1632
rm -rf build/
1733

@@ -35,3 +51,11 @@ publish-layer: package
3551
aws s3 rm s3://$(BUCKET_NAME)/collector-extension.zip
3652
aws s3 rb s3://$(BUCKET_NAME)
3753
@echo OpenTelemetry Collector layer published.
54+
55+
.PHONY: gotidy
56+
gotidy:
57+
@$(MAKE) for-all-target TARGET="tidy"
58+
59+
.PHONY: gotest
60+
gotest:
61+
@$(MAKE) for-all-target TARGET="test"

collector/Makefile.Common

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ALL_PKGS is the list of all packages where ALL_SRC files reside.
2+
ALL_PKGS := $(sort $(shell go list ./...))
3+
4+
GOTEST_OPT?= -race -timeout 120s
5+
GOCMD?= go
6+
GOTEST=$(GOCMD) test
7+
GO_ACC=go-acc
8+
LINT=golangci-lint
9+
IMPI=impi
10+
11+
GOOS := $(shell $(GOCMD) env GOOS)
12+
GOARCH := $(shell $(GOCMD) env GOARCH)
13+
GH := $(shell which gh)
14+
15+
.PHONY: test
16+
test:
17+
$(GOTEST) $(GOTEST_OPT) ./...
18+
19+
.PHONY: test-with-cover
20+
test-with-cover:
21+
$(GO_ACC) --output=coverage.out ./...
22+
23+
.PHONY: benchmark
24+
benchmark:
25+
$(GOTEST) -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -run=notests ./
26+
27+
.PHONY: fmt
28+
fmt:
29+
gofmt -w -s ./
30+
goimports -w -local github.com/open-telemetry/opentelemetry-lambda/collector ./
31+
32+
.PHONY: tidy
33+
tidy:
34+
rm -fr go.sum
35+
$(GOCMD) mod tidy -compat=1.18
36+
37+
.PHONY: lint
38+
lint:
39+
$(LINT) run
40+
41+
.PHONY: generate
42+
generate:
43+
$(GOCMD) generate ./...
44+
45+
.PHONY: impi
46+
impi:
47+
@$(IMPI) --local github.com/open-telemetry/opentelemetry-lambda/collector --scheme stdThirdPartyLocal ./...
48+
49+
.PHONY: moddownload
50+
moddownload:
51+
$(GOCMD) mod download
52+
53+
.PHONY: align
54+
align:
55+
-fieldalignment -fix .

collector/lambdacomponents/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../Makefile.Common

collector/lambdacomponents/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor v0.68.0
1111
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.68.0
1212
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.68.0
13+
go.opentelemetry.io/collector v0.68.0
1314
go.opentelemetry.io/collector/component v0.68.0
1415
go.opentelemetry.io/collector/exporter/loggingexporter v0.68.0
1516
go.opentelemetry.io/collector/exporter/otlpexporter v0.68.0
@@ -74,7 +75,6 @@ require (
7475
github.com/tidwall/wal v1.1.7 // indirect
7576
github.com/yusufpapurcu/wmi v1.2.2 // indirect
7677
go.opencensus.io v0.24.0 // indirect
77-
go.opentelemetry.io/collector v0.68.0 // indirect
7878
go.opentelemetry.io/collector/confmap v0.68.0 // indirect
7979
go.opentelemetry.io/collector/consumer v0.68.0 // indirect
8080
go.opentelemetry.io/collector/featuregate v0.68.0 // indirect

0 commit comments

Comments
 (0)