Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch precompiled xk6 extension from grafana/xk6-sm #966

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
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
12 changes: 8 additions & 4 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
],
"customManagers": [
{
// Update k6 version in Dockerfiles.
// Update xk6-sm
"customType": "regex",
"depNameTemplate": "grafana/xk6-sm",
"datasourceTemplate": "github-releases",
"depNameTemplate": "grafana/k6",
"fileMatch": [".*\\.mk"],
"versioningTemplate": "semver",
"fileMatch": [
"Dockerfile",
"scripts/make/sm-k6.mk"
],
"matchStrings": [
"(?:^|\\n)[ \\t]*K6_VERSION\\s*:=\\s*(?<currentValue>\\S+)[ \\t]*(?:$|\\n)"
"https://github.com/grafana/xk6-sm/releases/download/(?<currentValue>[^/]+)/"
]
}
]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ jobs:
- name: build
run: make build-native

- name: Download sm-k6
run: make sm-k6-native

- name: lint
run: make lint

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/validate_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
- name: build
run: make build-native

- name: Download sm-k6
run: make sm-k6-native

- name: lint
run: make lint

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ARG TARGETOS
ARG TARGETARCH
ARG HOST_DIST=$TARGETOS-$TARGETARCH

ADD --chmod=0555 https://github.com/grafana/xk6-sm/releases/download/v0.0.3-pre/sm-k6-${TARGETOS}-${TARGETARCH} /usr/local/bin/sm-k6
COPY dist/${HOST_DIST}/synthetic-monitoring-agent /usr/local/bin/synthetic-monitoring-agent
COPY dist/${HOST_DIST}/k6 /usr/local/bin/sm-k6
COPY scripts/pre-stop.sh /usr/local/lib/synthetic-monitoring-agent/pre-stop.sh
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ARG TARGETOS
ARG TARGETARCH
ARG HOST_DIST=$TARGETOS-$TARGETARCH

ADD --chmod=0555 https://github.com/grafana/xk6-sm/releases/download/v0.0.3-pre/sm-k6-${TARGETOS}-${TARGETARCH} /usr/local/bin/sm-k6
COPY dist/${HOST_DIST}/synthetic-monitoring-agent /usr/local/bin/synthetic-monitoring-agent
COPY dist/${HOST_DIST}/k6 /usr/local/bin/sm-k6
COPY scripts/pre-stop.sh /usr/local/lib/synthetic-monitoring-agent/pre-stop.sh
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ include $(ROOTDIR)/scripts/make/build.mk
include $(ROOTDIR)/scripts/make/testing.mk
include $(ROOTDIR)/scripts/make/linters.mk
include $(ROOTDIR)/scripts/make/release.mk
include $(ROOTDIR)/scripts/make/sm-k6.mk
include $(ROOTDIR)/scripts/make/helpers.mk
include $(ROOTDIR)/scripts/make/xk6.mk
4 changes: 3 additions & 1 deletion internal/prober/multihttp/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httptest"
"path/filepath"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -852,7 +853,8 @@ func TestSettingsToScript(t *testing.T) {
t.Cleanup(cancel)
// logger := zerolog.New(zerolog.NewTestWriter(t))
logger := zerolog.Nop()
k6path := filepath.Join(testhelper.ModuleDir(t), "dist", "k6")
k6path := filepath.Join(testhelper.ModuleDir(t), "dist", runtime.GOOS+"-"+runtime.GOARCH, "sm-k6")
t.Log(k6path)
runner := k6runner.New(k6runner.RunnerOpts{Uri: k6path})

prober, err := NewProber(ctx, check, logger, runner, http.Header{})
Expand Down
21 changes: 21 additions & 0 deletions scripts/make/sm-k6.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
XK6_PLATFORMS := $(filter-out linux/arm,$(PLATFORMS)) darwin/arm64 darwin/amd64

.PHONY: sm-k6
sm-k6:
@true

define sm-k6
$(DISTDIR)/$(1)-$(2)/sm-k6:
mkdir -p "$(DISTDIR)/$(1)-$(2)"
# Renovate updates the following line. Keep its syntax as it is.
curl -sSL https://github.com/grafana/xk6-sm/releases/download/v0.0.4/sm-k6-$(1)-$(2) -o "$$@"
chmod +x "$$@"

sm-k6: $(DISTDIR)/$(1)-$(2)/sm-k6
endef

$(foreach BUILD_PLATFORM,$(XK6_PLATFORMS), \
$(eval $(call sm-k6,$(word 1,$(subst /, ,$(BUILD_PLATFORM))),$(word 2,$(subst /, ,$(BUILD_PLATFORM))))))

.PHONY: sm-k6-native
sm-k6-native: $(DISTDIR)/$(HOST_OS)-$(HOST_ARCH)/sm-k6
1 change: 0 additions & 1 deletion scripts/make/vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ ifeq ($(USE_LOCAL_TOOLS),true)
GOLANGCI_LINT := golangci-lint
GOTESTSUM := gotestsum
SHELLCHECK := shellcheck
XK6 := xk6
endif
88 changes: 0 additions & 88 deletions scripts/make/xk6.mk

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/package/nfpm.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contents:
dst: /etc/systemd/system/synthetic-monitoring-agent.service

# Copy k6 as sm-k6 to prevent clashing with k6 if it's installed.
- src: {{.DISTDIR}}/{{.Os}}-{{.Arch}}/k6
- src: {{.DISTDIR}}/{{.Os}}-{{.Arch}}/sm-k6
dst: /usr/bin/sm-k6
rpm:
deb:
Loading
Loading