From f6c7e387867bff72d79ed30a2f410d5aa76eb578 Mon Sep 17 00:00:00 2001 From: idoko Date: Tue, 12 Aug 2025 11:41:22 +0100 Subject: [PATCH 1/4] roll back dynamic linking --- .goreleaser.yml | 1 + Makefile | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 966c5c92..8fe5e9f9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -4,6 +4,7 @@ builds: - binary: mongodb_exporter id: mongodb_exporter env: + - CGO_ENABLED=0 goos: - linux - darwin diff --git a/Makefile b/Makefile index e19f35ec..b9b5c687 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build clean default help init test format check-license +.PHONY: all build clean default help init test format check-license release-dry-run release-dry-run-docker release-dry-run-fast default: help GO_TEST_PATH ?= ./... @@ -83,6 +83,21 @@ release: ## Build the binaries using goreleaser -w /go/src/github.com/user/repo \ goreleaser/goreleaser release --snapshot --skip=publish --clean +release-dry-run: ## Build cross-platform binaries locally without publishing + @echo "Building cross-platform binaries with GoReleaser..." + @if command -v goreleaser >/dev/null 2>&1; then \ + goreleaser build --snapshot --clean; \ + else \ + echo "GoReleaser not found. Installing via Docker..."; \ + docker run --rm --privileged \ + -v ${PWD}:/go/src/github.com/percona/mongodb_exporter \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -w /go/src/github.com/percona/mongodb_exporter \ + goreleaser/goreleaser build --snapshot --clean; \ + fi + @find build -name mongodb_exporter -type f | sort + + FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*") format: ## Format source code From 2aff6cfe44489233b98829add9bf9ca9ddef5c11 Mon Sep 17 00:00:00 2001 From: idoko Date: Tue, 12 Aug 2025 12:00:02 +0100 Subject: [PATCH 2/4] remove unused targets --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b9b5c687..585b87cc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build clean default help init test format check-license release-dry-run release-dry-run-docker release-dry-run-fast +.PHONY: all build clean default help init test format check-license release-dry-run default: help GO_TEST_PATH ?= ./... From 659a5e9390893bdd85b5dc00baae933f377ec7a4 Mon Sep 17 00:00:00 2001 From: idoko Date: Tue, 12 Aug 2025 12:45:42 +0100 Subject: [PATCH 3/4] add release dry run to CI --- .github/workflows/go.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 05241790..c4bd6f99 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -66,6 +66,10 @@ jobs: env_vars: GO_VERSION,TEST_MONGODB_IMAGE fail_ci_if_error: false + - name: Dry-run GoReleaser + run: | + make release-dry-run + - name: Run debug commands on failure if: ${{ failure() }} run: | From b6ce70d6ef94d76b5ead9f973578c18566faf2ef Mon Sep 17 00:00:00 2001 From: idoko Date: Tue, 12 Aug 2025 14:50:31 +0100 Subject: [PATCH 4/4] rework ci pipelines --- .github/workflows/build.yml | 55 ++++++++++++++++++++++++++ .github/workflows/{go.yml => test.yml} | 4 -- 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{go.yml => test.yml} (96%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7eedcf93 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: Build + +on: + push: + branches: + - main + - release-0.1x + tags: + - v[0-9]+.[0-9]+.[0-9]+* + pull_request: + +permissions: + contents: read + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: ${{ github.workspace }}/go.mod + + - name: Set up QEMU + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 + + - name: Dry-run GoReleaser + run: | + make release-dry-run + + - name: Run debug commands on failure + if: ${{ failure() }} + run: | + echo "--- Environment variables ---" + env | sort + echo "--- GO Environment ---" + go env | sort + echo "--- Git status ---" + git status + echo "--- Docker logs ---" + docker compose logs + echo "--- Docker ps ---" + docker compose ps -a diff --git a/.github/workflows/go.yml b/.github/workflows/test.yml similarity index 96% rename from .github/workflows/go.yml rename to .github/workflows/test.yml index c4bd6f99..05241790 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/test.yml @@ -66,10 +66,6 @@ jobs: env_vars: GO_VERSION,TEST_MONGODB_IMAGE fail_ci_if_error: false - - name: Dry-run GoReleaser - run: | - make release-dry-run - - name: Run debug commands on failure if: ${{ failure() }} run: |