Skip to content
Merged
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
14 changes: 0 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,3 @@ jobs:
# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true
working-directory: ./

fuzz:
name: fuzz tests
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}
cache: true
- uses: actions/checkout@v4
- name: Build CLI binary
run: make build
- name: Run fuzz tests
run: make e2e-fuzz
19 changes: 2 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build-and-test:
name: Build and E2E Test
name: Build and test
runs-on: ubuntu-latest
env:
DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
Expand Down Expand Up @@ -42,14 +42,6 @@ jobs:
AUDIENCE="${AUDIENCE}" \
SERVICE_URL="${SERVICE_URL}"

- name: Run E2E Tests
env:
MUMP2P_E2E_TOKEN_B64: ${{ secrets.MUMP2P_E2E_TOKEN_B64 }}
run: make e2e-test

- name: Run Fuzz Tests
run: make e2e-fuzz

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -81,12 +73,5 @@ jobs:
- name: Auth GH CLI using PAT
run: echo "${{ secrets.RELEASE_GH_TOKEN }}" | gh auth login --with-token

- name: Set Release Variables
id: vars
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "CLI_NAME=$(make -s print-cli-name)" >> $GITHUB_ENV

- name: Create Release
run: |
make release
run: make release
74 changes: 20 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,39 @@ GO_BIN ?= go
CLI_NAME := mump2p
BUILD_DIR := dist

VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
COMMIT_HASH ?= $(shell git rev-parse --short HEAD)
DOMAIN ?= ""
CLIENT_ID ?= ""
AUDIENCE ?= optimum-login
SERVICE_URL ?= http://localhost:12080
SERVICE_URL ?= http://us1-proxy.getoptimum.io:8080
Comment thread
swarna1101 marked this conversation as resolved.

LD_FLAGS := -X github.com/getoptimum/mump2p-cli/internal/config.Domain=$(DOMAIN) \
-X github.com/getoptimum/mump2p-cli/internal/config.ClientID=$(CLIENT_ID) \
-X github.com/getoptimum/mump2p-cli/internal/config.Audience=$(AUDIENCE) \
-X github.com/getoptimum/mump2p-cli/internal/config.ServiceURL=$(SERVICE_URL) \
-X github.com/getoptimum/mump2p-cli/internal/config.Version=$(VERSION) \
-X github.com/getoptimum/mump2p-cli/internal/config.CommitHash=$(COMMIT_HASH)
-X github.com/getoptimum/mump2p-cli/internal/config.ServiceURL=$(SERVICE_URL)
Comment thread
swarna1101 marked this conversation as resolved.

.DEFAULT_GOAL := help

.PHONY: all build run clean test help lint build tag release print-cli-name e2e-test e2e-fuzz coverage
.PHONY: all build run clean test lint tag release print-cli-name coverage

all: lint build

lint: ## Run linter
lint:
golangci-lint run ./...

build: ## Build the CLI binary
build:
GOOS=darwin GOARCH=amd64 $(GO_BIN) build -ldflags="$(LD_FLAGS)" -o $(BUILD_DIR)/$(CLI_NAME)-mac .
GOOS=linux GOARCH=amd64 $(GO_BIN) build -ldflags="$(LD_FLAGS)" -o $(BUILD_DIR)/$(CLI_NAME)-linux .
Comment thread
swarna1101 marked this conversation as resolved.

print-cli-name: ## Print CLI name for CI/CD usage
print-cli-name:
@echo "$(CLI_NAME)"

release: build ## Build and create GitHub release
@echo "Creating release for $(VERSION)"
mkdir -p $(BUILD_DIR)
gh release create $(VERSION) \
--title "Release $(VERSION)" \
--notes "Release notes for $(VERSION)" \
release: build
@tag=$$(git describe --tags --abbrev=0 2>/dev/null || echo v0.0.0); \
echo "Creating release for $$tag"; \
mkdir -p $(BUILD_DIR); \
gh release create "$$tag" \
--title "Release $$tag" \
--notes "Release notes for $$tag" \
$(BUILD_DIR)/$(CLI_NAME)-mac \
$(BUILD_DIR)/$(CLI_NAME)-linux \
$(BUILD_DIR)/$(CLI_NAME)-linux
Comment thread
swarna1101 marked this conversation as resolved.

tag:
@echo "Calculating next RC tag..."
Expand All @@ -56,46 +51,17 @@ tag:
git tag -a $$new_tag -m "Release $$new_tag"; \
git push origin $$new_tag

run: build ## Run the CLI with default config
run: build
./$(CLI_NAME) --config=$(CONFIG_PATH)

clean: ## Clean up build artifacts
clean:
rm -rf $(BUILD_DIR)
rm -f coverage.out coverage.html

test: ## Run unit tests
$(GO_BIN) test $(shell $(GO_BIN) list ./... | grep -v /e2e) -v -count=1
test:
$(GO_BIN) test ./... -v -count=1

coverage: ## Run tests with coverage and generate HTML report
$(GO_BIN) test $(shell $(GO_BIN) list ./... | grep -v /e2e) -coverprofile=coverage.out -v -count=1
coverage:
$(GO_BIN) test ./... -coverprofile=coverage.out -v -count=1
$(GO_BIN) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"

e2e-test: ## Run E2E tests against dist/ binary
@echo "Running E2E tests..."
@if [ ! -f "$(BUILD_DIR)/$(CLI_NAME)-linux" ] && [ ! -f "$(BUILD_DIR)/$(CLI_NAME)-mac" ]; then \
echo "Error: No binary found in $(BUILD_DIR)/"; \
echo "Run 'make build' first with release credentials"; \
exit 1; \
fi
go test ./e2e -v -timeout 10m

e2e-fuzz: ## Run fuzz tests against dist/ binary
@echo "Running fuzz tests..."
@if [ ! -f "$(BUILD_DIR)/$(CLI_NAME)-linux" ] && [ ! -f "$(BUILD_DIR)/$(CLI_NAME)-mac" ]; then \
echo "Error: No binary found in $(BUILD_DIR)/"; \
echo "Run 'make build' first with release credentials"; \
exit 1; \
fi
@echo "Fuzzing publish topic names..."
@go test ./e2e -run='^$$' -fuzz=FuzzPublishTopicName -fuzztime=1m -timeout=3m
@echo "Fuzzing publish messages..."
@go test ./e2e -run='^$$' -fuzz=FuzzPublishMessage -fuzztime=1m -timeout=3m
@echo "Fuzzing service URLs..."
@go test ./e2e -run='^$$' -fuzz=FuzzServiceURL -fuzztime=1m -timeout=3m
@echo "Fuzzing file paths..."
@go test ./e2e -run='^$$' -fuzz=FuzzFilePath -fuzztime=1m -timeout=3m
@echo "All fuzz tests passed!"

help: ## Show help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
Loading
Loading