Skip to content
Open
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
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,26 @@ jobs:
exit 1
fi

run-tests:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build
run: |
go install github.com/goreleaser/goreleaser/v2@latest
make build
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist/

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.22.3
1.22.4
59 changes: 59 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
- go mod tidy
- go generate ./...

builds:
- id: apmsoak
main: ./cmd/apmsoak
binary: apmsoak-{{.Os}}-{{.Arch}}
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -X github.com/elastic/apm-perf/internal/version.commitSha={{.FullCommit}}
- -X github.com/elastic/apm-perf/internal/version.buildTime={{.Date}}
no_unique_dist_dir: true
- id: apmbench
main: ./cmd/apmbench
binary: apmbench-{{.Os}}-{{.Arch}}
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -X github.com/elastic/apm-perf/internal/version.commitSha={{.FullCommit}}
- -X github.com/elastic/apm-perf/internal/version.buildTime={{.Date}}
no_unique_dist_dir: true
- id: apmtelemetrygen
main: ./cmd/apmtelemetrygen
binary: apmtelemetrygen-{{.Os}}-{{.Arch}}
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -X github.com/elastic/apm-perf/internal/version.commitSha={{.FullCommit}}
- -X github.com/elastic/apm-perf/internal/version.buildTime={{.Date}}
no_unique_dist_dir: true
16 changes: 7 additions & 9 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ WORKDIR /opt/apm-perf
# Use dedicated layer for Go dependency, cached until they changes
COPY go.mod go.sum ./
RUN go mod download
RUN go install github.com/goreleaser/goreleaser/v2@latest

# Copy files
COPY . .

# Build
ARG TARGETOS TARGETARCH
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
ENV CGO_ENABLED=0

# Leverage mounts to cache relevant Go paths
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
Expand Down Expand Up @@ -49,16 +44,19 @@ LABEL \
# Switch workdir
WORKDIR /opt/apm-perf

# OS Details
ARG TARGETOS TARGETARCH

# Copy files for apmsoak
COPY --from=builder /opt/apm-perf/dist/apmsoak /usr/bin/apmsoak
COPY --from=builder /opt/apm-perf/dist/apmsoak-${TARGETOS}-${TARGETARCH} /usr/bin/apmsoak
COPY ./internal/loadgen/events ./events
COPY ./cmd/apmsoak/scenarios.yml /opt/apm-perf/scenarios.yml

# Copy files for apmbench
COPY --from=builder /opt/apm-perf/dist/apmbench /usr/bin/apmbench
COPY --from=builder /opt/apm-perf/dist/apmbench-${TARGETOS}-${TARGETARCH} /usr/bin/apmbench

# Copy files for apmtelemetrygen
COPY --from=builder /opt/apm-perf/dist/apmtelemetrygen /usr/bin/apmtelemetrygen
COPY --from=builder /opt/apm-perf/dist/apmtelemetrygen-${TARGETOS}-${TARGETARCH} /usr/bin/apmtelemetrygen

# Default to apmsoak, override to use apmbench
CMD [ "/usr/bin/apmsoak" ]
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@ clean:
rm -fr bin

.PHONY: build
build: COMMIT_SHA=$$(git rev-parse HEAD)
build: CURRENT_TIME_ISO=$$(date -u +"%Y-%m-%dT%H:%M:%SZ")
build: LDFLAGS=-X 'github.com/elastic/apm-perf/internal/version.commitSha=$(COMMIT_SHA)'
build: LDFLAGS+=-X 'github.com/elastic/apm-perf/internal/version.buildTime=$(CURRENT_TIME_ISO)'
build:
mkdir -p $(DIST_DIR)
go build -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/apmsoak cmd/apmsoak/*.go
go build -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/apmbench cmd/apmbench/*.go
go build -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/apmtelemetrygen cmd/apmtelemetrygen/*.go
goreleaser build --snapshot --clean

.PHONY: test
test: go.mod
Expand Down