Skip to content

Commit 837386f

Browse files
authored
Replace m and mlaunch with golang equivalents and create mongo-cluster to simplify startup/teardown in tests (#1)
* Updates * Add Go test harness with MongoDB 3.6+ support Replace pipx with uv tool for installing mtools and add comprehensive Go test harness for MongoDB cluster testing. Changes: - Switch to uv tool install with Python 3.10 for mtools compatibility - Add Go test harness with automatic dependency management - Implement port allocation with conflict detection and retries - Add health checks using MongoDB driver v1.15 (supports 3.6+) - Temporary directories with automatic cleanup - Support for parallel test execution - Comprehensive documentation in HARNESS.md Features: - Automatic installation of uv and mtools if not present - MongoDB version management via m wrapper - Non-conflicting port ranges (30000-40000) - Exponential backoff retry logic - Health checks: port binding, connection, server status - Signal handlers for cleanup on interrupt * Add golang replacements for m,mlaunch and mongo-cluster * Remove legacy requirements.txt * Try stuff * Try stuff 2 * Save people from life mistakes * Save people from life mistakes * Save people from life mistakes
1 parent 005bd61 commit 837386f

File tree

28 files changed

+8282
-19
lines changed

28 files changed

+8282
-19
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest, macos-latest]
22+
go-version: ['1.24']
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: ${{ matrix.go-version }}
32+
cache-dependency-path: go.sum
33+
34+
- name: Build binaries
35+
run: |
36+
make build
37+
38+
- name: Test
39+
run: go test ./...
40+
41+
- name: Upload artifacts
42+
uses: actions/upload-artifact@v4
43+
if: success()
44+
with:
45+
name: binaries-${{ matrix.os }}
46+
path: bin/*
47+
retention-days: 1
48+

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Tag to release (e.g., v1.0.0)'
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
packages: write
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version: '1.24'
31+
cache-dependency-path: go.sum
32+
33+
- name: Run GoReleaser
34+
uses: goreleaser/goreleaser-action@v5
35+
with:
36+
distribution: goreleaser
37+
version: 2.5.0
38+
args: release --clean
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Upload artifacts
43+
uses: actions/upload-artifact@v4
44+
if: failure()
45+
with:
46+
name: release-artifacts
47+
path: dist/*
48+

.github/workflows/snapshot.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
snapshot:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: '1.24'
30+
cache-dependency-path: go.sum
31+
32+
- name: Run GoReleaser snapshot
33+
uses: goreleaser/goreleaser-action@v5
34+
with:
35+
distribution: goreleaser
36+
version: 2.5.0
37+
args: release --snapshot --clean
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Upload snapshot artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: snapshot-artifacts
45+
path: dist/*
46+
retention-days: 1
47+

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
Brewfile.lock.json
22
data/
3+
4+
# Binaries
5+
bin/m
6+
bin/mlaunch
7+
bin/mongo-cluster
8+
bin/*.exe
9+
bin/*.dll
10+
bin/*.so
11+
bin/*.dylib
12+
13+
# Legacy binary (if exists)
314
./bin/keyhole
15+
16+
mongo-cluster
17+
mlaunch
18+
m
19+
cluster.json

.goreleaser.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Goreleaser configuration for mongo-scaffold
2+
# Builds and releases m and mlaunch binaries
3+
4+
project_name: mongo-scaffold
5+
6+
version: 2
7+
# Build configuration
8+
builds:
9+
- id: m
10+
main: ./cmd/m
11+
binary: m
12+
goos:
13+
- linux
14+
- darwin
15+
goarch:
16+
- amd64
17+
- arm64
18+
env:
19+
- CGO_ENABLED=0
20+
flags:
21+
- -trimpath
22+
ldflags:
23+
- -s -w
24+
- -X main.version={{.Version}}
25+
- -X main.commit={{.Commit}}
26+
- -X main.date={{.Date}}
27+
28+
- id: mlaunch
29+
main: ./cmd/mlaunch
30+
binary: mlaunch
31+
goos:
32+
- linux
33+
- darwin
34+
goarch:
35+
- amd64
36+
- arm64
37+
env:
38+
- CGO_ENABLED=0
39+
flags:
40+
- -trimpath
41+
ldflags:
42+
- -s -w
43+
- -X main.version={{.Version}}
44+
- -X main.commit={{.Commit}}
45+
- -X main.date={{.Date}}
46+
47+
- id: mongo-cluster
48+
main: ./cmd/mongo-cluster
49+
binary: mongo-cluster
50+
goos:
51+
- linux
52+
- darwin
53+
goarch:
54+
- amd64
55+
- arm64
56+
env:
57+
- CGO_ENABLED=0
58+
flags:
59+
- -trimpath
60+
ldflags:
61+
- -s -w
62+
- -X main.version={{.Version}}
63+
- -X main.commit={{.Commit}}
64+
- -X main.date={{.Date}}
65+
66+
# Archive configuration
67+
archives:
68+
- id: default
69+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
70+
files:
71+
- README.md
72+
- LICENSE*
73+
- CHANGELOG*
74+
builds:
75+
- m
76+
- mlaunch
77+
- mongo-cluster
78+
79+
# Checksums
80+
checksum:
81+
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
82+
algorithm: sha256
83+
84+
# Snapshots
85+
# Note: snapshot.name_template is deprecated in GoReleaser 2.5.0
86+
# Removed to avoid deprecation warnings
87+
snapshot: {}
88+
89+
# Changelog
90+
changelog:
91+
sort: asc
92+
filters:
93+
exclude:
94+
- "^docs:"
95+
- "^test:"
96+
97+
# Homebrew configuration
98+
# Note: GoReleaser 2.5.0 uses 'brews' field for Homebrew formulas
99+
brews:
100+
- name: mongo-scaffold
101+
homepage: "https://github.com/zph/mongo-scaffold"
102+
description: "MongoDB version manager and cluster launcher"
103+
license: "MIT"
104+
# Install all binaries manually since 'binaries' field is not supported in 2.5.0
105+
install: |
106+
bin.install "m"
107+
bin.install "mlaunch"
108+
bin.install "mongo-cluster"
109+
test: |
110+
system "#{bin}/m", "--version"
111+
system "#{bin}/mlaunch", "--help"
112+
system "#{bin}/mongo-cluster", "--help"
113+
114+
# GitHub release configuration
115+
release:
116+
github:
117+
owner: zph
118+
name: mongo-scaffold
119+
# Draft releases
120+
draft: false
121+
# Prerelease for tags with -alpha, -beta, -rc
122+
mode: replace
123+
header: |
124+
## {{ .Tag }}
125+
126+
{{ if .PreviousTag }}
127+
**Full Changelog**: https://github.com/zph/mongo-scaffold/compare/{{ .PreviousTag }}...{{ .Tag }}
128+
{{ end }}
129+
130+
# Docker (optional - can be removed if not needed)
131+
# dockers:
132+
# - goos: linux
133+
# goarch: amd64
134+
# image_templates:
135+
# - "ghcr.io/zph/mongo-scaffold:{{ .Tag }}"
136+
# - "ghcr.io/zph/mongo-scaffold:latest"
137+
# dockerfile: Dockerfile
138+
139+
# NFPM (for .deb and .rpm packages - optional)
140+
# nfpms:
141+
# - id: default
142+
# package_name: mongo-scaffold
143+
# file_name_template: "{{ .ConventionalFileName }}"
144+
# maintainer: "zph <zph@example.com>"
145+
# description: "MongoDB version manager and cluster launcher"
146+
# license: "MIT"
147+
# formats:
148+
# - deb
149+
# - rpm
150+
# dependencies:
151+
# - mongodb-community
152+
# contents:
153+
# - src: "{{ .ArtifactPath }}"
154+
# dst: "/usr/local/bin/{{ .Binary }}"
155+
# file_info:
156+
# mode: 0755
157+
158+
# Before hook (optional)
159+
# before:
160+
# hooks:
161+
# - go mod download
162+
# - go generate ./...
163+
164+
# After hook (optional)
165+
# after:
166+
# hooks:
167+
# - echo "Release {{ .Tag }} completed!"
168+

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

0 commit comments

Comments
 (0)