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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ jobs:
- name: Run unit tests
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./pkg/...

- name: Check available disk space
run: df -h /

- name: Run acceptance tests (Ginkgo)
env:
PIVNET_TOKEN: ${{ secrets.PIVNET_TOKEN }}
PIVNET_MIN_FREE_SPACE_GB: "2" # Lower requirement for CI tests (default: 5GB)
# ENABLE_DOWNLOAD_TESTS: "1" # Uncomment to run all 12 tests (slower, downloads tiles)
run: |
go build -v ./cmd/tile-diff
Expand Down Expand Up @@ -63,7 +67,7 @@ jobs:
- name: Build binary
run: |
go build -v -o bin/tile-diff ./cmd/tile-diff
./bin/tile-diff --version || echo "Version command not implemented yet"
./bin/tile-diff --version

- name: Test binary runs
run: |
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.PHONY: build test acceptance-test acceptance-test-with-token acceptance-test-fast acceptance-test-fast-with-token clean install lint fmt vet

# Get version from git tags, or use "dev" if not on a tag
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")

# Build the binary
build:
go build -o tile-diff ./cmd/tile-diff
go build -ldflags "-X main.version=$(VERSION)" -o tile-diff ./cmd/tile-diff

# Run unit tests
test:
Expand Down
21 changes: 20 additions & 1 deletion cmd/tile-diff/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/malston/tile-diff/pkg/api"
Expand All @@ -18,6 +19,9 @@ import (
"github.com/malston/tile-diff/pkg/report"
)

// version is set via ldflags during build
var version = "dev"

// EnrichmentResult contains the results of release notes enrichment
type EnrichmentResult struct {
Matches map[string]releasenotes.Match
Expand Down Expand Up @@ -181,9 +185,16 @@ func main() {
productConfig := flag.String("product-config", "configs/products.yaml", "Path to product config file")
verbose := flag.Bool("verbose", false, "Enable verbose output")
debugMatching := flag.Bool("debug-matching", false, "Show detailed property-to-feature matching information")
showVersion := flag.Bool("version", false, "Show version information")

flag.Parse()

// Handle version flag
if *showVersion {
fmt.Printf("tile-diff version %s\n", version)
os.Exit(0)
}

// Track if we're in JSON mode to suppress non-JSON output
jsonMode := *reportFormat == "json"

Expand Down Expand Up @@ -231,6 +242,14 @@ func main() {
os.Exit(1)
}

// Get minimum free space requirement from env var or use default
minFreeSpaceGB := int64(10) // Default: 10GB (most tiles < 5GB, some > 10GB)
if envSpace := os.Getenv("PIVNET_MIN_FREE_SPACE_GB"); envSpace != "" {
if parsed, err := strconv.ParseInt(envSpace, 10, 64); err == nil && parsed > 0 {
minFreeSpaceGB = parsed
}
}

if *reportFormat != "json" {
fmt.Printf("tile-diff - Ops Manager Product Tile Comparison\n")
fmt.Printf("================================================\n\n")
Expand Down Expand Up @@ -265,7 +284,7 @@ func main() {
}

// Create downloader (quiet mode in JSON to suppress progress output)
downloader := pivnet.NewDownloader(client, cacheDirectory, manifestFile, eulaFile, 20, jsonMode)
downloader := pivnet.NewDownloader(client, cacheDirectory, manifestFile, eulaFile, minFreeSpaceGB, jsonMode)

// Download old tile
if !jsonMode {
Expand Down
23 changes: 23 additions & 0 deletions test/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ import (
. "github.com/onsi/gomega"
)

var _ = Describe("Basic Flags", func() {
BeforeEach(func() {
if _, err := os.Stat(tileDiffBin); os.IsNotExist(err) {
Fail(fmt.Sprintf("tile-diff binary not found at %s - run 'make build' first", tileDiffBin))
}
})

Describe("Version Flag", func() {
It("prints version information when --version is provided", func() {
output, err := runTileDiff("--version")

// Should succeed
Expect(err).NotTo(HaveOccurred(), "Should exit successfully")

// Should contain version information
Expect(output).To(ContainSubstring("version"), "Should contain 'version' in output")

// Should not contain error messages
Expect(output).NotTo(ContainSubstring("Error"), "Should not contain error messages")
})
})
})

var _ = Describe("Pivnet Integration", func() {
BeforeEach(func() {
if _, err := os.Stat(tileDiffBin); os.IsNotExist(err) {
Expand Down