Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
21f8064
running go.mod tidy
heinrichb Feb 14, 2025
a582675
Added formatting on save for vscode as default project setting
heinrichb Feb 14, 2025
9f25502
Added makefile for build and updated README.
heinrichb Feb 14, 2025
33b30a8
Added
heinrichb Feb 14, 2025
4bca18e
READ CONFIG FILES
Dan-Avel Feb 14, 2025
a80f1ca
Updating makefile test command
heinrichb Feb 14, 2025
9d73457
Removing spacing on file comments
heinrichb Feb 14, 2025
ef23ce0
MERGE READING CONFIG WITH VALIDATING CONFIG
Dan-Avel Feb 14, 2025
79f416a
OUTPUT CONFIG SETTINGS
Dan-Avel Feb 14, 2025
59150c4
Adding tests and cleaning up readme.md
heinrichb Feb 14, 2025
fe04dfd
Merge pull request #1 from heinrichb/develop-config
heinrichb Feb 14, 2025
6b919ac
DOCUMENT FUNCTION PRINTNONEMPTYFIELDS
Dan-Avel Feb 14, 2025
c2432c0
Fixing Makefile, increading run speed and adding build dependency.
heinrichb Feb 14, 2025
258e5d7
CREATE UTILS PKG
Dan-Avel Feb 14, 2025
d758704
FORMATTING CONFIG WITH UTILS PKG
Dan-Avel Feb 14, 2025
089c684
Merge pull request #2 from heinrichb/develop-config
heinrichb Feb 14, 2025
6305f1e
Updating code coverage badge.
heinrichb Feb 14, 2025
23a6736
Merge remote-tracking branch 'origin/develop' into develop
heinrichb Feb 14, 2025
efad1e1
FIxing code coverage for develop branch
heinrichb Feb 14, 2025
0b28828
Updating CI
heinrichb Feb 14, 2025
65714f3
Updated README project structure. Removed redundant comments.
heinrichb Feb 14, 2025
0827b4b
Comment consistency, and updated to Makefile.
heinrichb Feb 14, 2025
1e65f49
- Updated Makefile:
heinrichb Feb 14, 2025
d412e48
Updating test coverage
heinrichb Feb 14, 2025
84e5e45
Make only running tests if changes are made. Separate coverage command.
heinrichb Feb 14, 2025
7c3a063
Makefile changes, formatting for coverage
heinrichb Feb 14, 2025
da61157
Better consistency on makefile output.
heinrichb Feb 14, 2025
525e2f5
Slight tweaks to makefile output
heinrichb Feb 14, 2025
907722e
Coverage being generated
heinrichb Feb 15, 2025
3addb4d
Cleaning up output
heinrichb Feb 15, 2025
318b6d4
Merge branch 'makefile-fixes' into develop
heinrichb Feb 15, 2025
a34773a
Updating readme and some comments
heinrichb Feb 15, 2025
c89a88c
Renaming utils.go to better explain what it was actually doing.
heinrichb Feb 15, 2025
33454b9
Some updates to default.json, readme explaining the updates, and giti…
heinrichb Feb 15, 2025
94c3550
FIxing unit tests, adding placeholder tests
heinrichb Feb 15, 2025
d21ef3b
feat: Add verbose flag (-v, --verbose) for enhanced system messages
heinrichb Feb 16, 2025
f2f4d44
Merge pull request #4 from heinrichb/develop-verbose
heinrichb Feb 16, 2025
826cd9f
Changing CI to run tests on all branches, aiming for 100% coverage
heinrichb Feb 16, 2025
9f28a50
ApplyDefaults - 100%
heinrichb Feb 16, 2025
b6b5596
Removing unneeded tests
heinrichb Feb 16, 2025
ea7b190
88% coverage
heinrichb Feb 16, 2025
1dfe4bd
90% coverage LESSFUCKINGGOOOO
heinrichb Feb 16, 2025
6d6e78c
Better Test Structure, less coverage
heinrichb Feb 16, 2025
1fbac92
100% printcolor coverage
heinrichb Feb 16, 2025
56e7056
100% on stubbed functions.
heinrichb Feb 16, 2025
3a2ee6d
100% coverage
heinrichb Feb 16, 2025
f966c1d
75%
heinrichb Feb 16, 2025
5611034
100% coverage
heinrichb Feb 16, 2025
53578e4
Merge branch 'develop-configtest' into develop
heinrichb Feb 16, 2025
3ab5333
feat(coverage): filter out main.go from coverage reports
heinrichb Feb 16, 2025
8048f37
Load covered
heinrichb Feb 16, 2025
c1c368f
Refactoring override config
heinrichb Feb 16, 2025
a5388da
100% coverage, bug with empty values
heinrichb Feb 16, 2025
364c20f
100% coverage, no bugs
heinrichb Feb 16, 2025
1be941b
Combining tests
heinrichb Feb 16, 2025
2abb859
Merge pull request #5 from heinrichb/develop-configtests
heinrichb Feb 16, 2025
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
78 changes: 52 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
name: CI

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: 🏗️ Checkout
uses: actions/checkout@v2

- name: 🔧 Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.23"

- name: 🏃 Build
run: go build ./...

- name: 🧪 Test
run: go test -v ./...
# File: .github/workflows/ci.yml

name: Continuous Integration (CI)

on:
push:
branches: ["*"]
pull_request:
branches: ["main", "develop"]

jobs:
build-and-test:
name: 🔨 Build and Test
runs-on: ubuntu-latest

steps:
- name: 🏗️ Checkout
uses: actions/checkout@v2

- name: 🔧 Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.23"

- name: 📦 Check go.sum consistency
run: |
go mod tidy
if ! git diff --exit-code go.sum; then
echo "go.sum is not up-to-date. Please run 'go mod tidy' and commit the changes."
exit 1
fi

- name: 🛠️ Build
run: go build ./...

- name: 🧪 Run Tests with Coverage
run: |
go test -v ./... -coverprofile=coverage.out | tee test-results.log
grep -v "cmd/scrapeycli/main.go:" coverage.out > tmp && mv tmp coverage.out

- name: 📤 Upload Coverage Reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out

- name: 📜 Upload Test Logs on Failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results.log
66 changes: 33 additions & 33 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Go binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Build artifacts and local bin directories
bin/
build/
dist/

# Test binaries (built with `go test -c`)
*.test

# Output of the go coverage tool
*.out
coverage/

# Dependency directories
vendor/

# Go workspace files
go.work
go.work.sum

# Editor/OS-specific
.DS_Store
.idea/
.vscode/

# Environment variables
.env
# File: .gitignore
# Go binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Build artifacts and local bin directories
bin
build
dist
# Test binaries (built with `go test -c`)
*.test
# Dependency directories
vendor
# Go workspace files
go.work
go.work.sum
# Editor/OS-specific
.DS_Store
.idea
# Environment variables
.env
# Ignore all configs except default.json
configs/*
!configs/default.json
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"[go]": {
"editor.defaultFormatter": "golang.go"
}
}
139 changes: 139 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# File: Makefile
# Purpose:
# - "install": ensure modules are tidy if go.mod or go.sum changed.
# - "test": run coverage if code changed.
# - "coverage": display coverage summary from coverage.out
# - "build": recompile binary if Go source or mod files changed.
# - "run": executes the compiled binary
# - "tree": display directory structure
# - All skip with "No changes detected, skipping X." if nothing changed.

.PHONY: install test coverage build run tree

# Directories for build artifacts and stamp files
BUILD_DIR := build
STAMPS_DIR := $(BUILD_DIR)/.stamps

# Stamp file paths for each step
INSTALL_STAMP := $(STAMPS_DIR)/install.stamp
BUILD_STAMP := $(STAMPS_DIR)/build.stamp
TEST_STAMP := $(STAMPS_DIR)/test.stamp

BINARY := $(BUILD_DIR)/scrapeycli

# Coverage output
COVER_DIR := ${BUILD_DIR}/coverage
COVER_PROFILE := $(COVER_DIR)/coverage.txt
COVER_HTML := $(COVER_DIR)/coverage.html

# All Go source files (including _test.go files)
GO_FILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*")

# Reusable messages
SKIP_MSG := No changes detected, skipping
CHANGE_MSG := Some files changed; re-running

# ------------------------------------------------------------------------------
# install: ensure go.mod/go.sum are tidy if changed.
# ------------------------------------------------------------------------------
install:
@mkdir -p $(STAMPS_DIR)
@TARGET=install; \
if [ ! -f "$(INSTALL_STAMP)" ] || [ go.mod -nt "$(INSTALL_STAMP)" ] || [ go.sum -nt "$(INSTALL_STAMP)" ]; then \
echo "$(CHANGE_MSG) $$TARGET..."; \
go mod tidy; \
if ! git diff --exit-code go.sum; then \
echo "go.sum updated. Please commit the changes."; \
exit 1; \
fi; \
touch "$(INSTALL_STAMP)"; \
echo "Done with installing."; \
else \
echo "$(SKIP_MSG) $$TARGET."; \
fi

# ------------------------------------------------------------------------------
# test: run tests and update coverage if any Go source (including _test.go files) have changed.
# Ensures gotestsum is installed before running tests.
# Depends on install.
# ------------------------------------------------------------------------------
test:
@if ! command -v gotestsum >/dev/null 2>&1; then \
echo "Installing gotestsum..."; \
go install gotest.tools/gotestsum@latest; \
fi
@mkdir -p $(COVER_DIR) $(STAMPS_DIR)
@TARGET=test; \
if [ ! -f "$(TEST_STAMP)" ] || [ -n "$$(find $(GO_FILES) -newer "$(TEST_STAMP)" 2>/dev/null)" ]; then \
echo "$(CHANGE_MSG) $$TARGET..."; \
> "$(COVER_PROFILE)"; \
if gotestsum --format short-verbose ./... && \
go test -cover -covermode=atomic -coverpkg=./... -coverprofile="$(COVER_PROFILE)" ./... >/dev/null; then \
if [ -f "$(COVER_PROFILE)" ]; then \
grep -v "cmd/scrapeycli/main.go:" "$(COVER_PROFILE)" > "$(COVER_PROFILE).tmp" && mv "$(COVER_PROFILE).tmp" "$(COVER_PROFILE)"; \
go tool cover -html="$(COVER_PROFILE)" -o "$(COVER_HTML)"; \
echo "Coverage file generated at: $(COVER_PROFILE)"; \
echo "HTML coverage report at: $(COVER_HTML)"; \
else \
echo "ERROR: Coverage file was not generated!"; \
fi; \
touch "$(TEST_STAMP)"; \
else \
echo "Tests failed! Skipping stamp update."; \
exit 1; \
fi; \
else \
echo "$(SKIP_MSG) $$TARGET."; \
fi

# ------------------------------------------------------------------------------
# coverage: displays a colorized coverage summary from the coverage file.
# Depends on test.
# ------------------------------------------------------------------------------
coverage: test
@echo "================== COVERAGE SUMMARY =================="
@go tool cover -func="$(COVER_PROFILE)" | go run ./scripts/coverage_formatter.go
@echo "====================================================="

# ------------------------------------------------------------------------------
# build: compile binary if Go sources changed.
# Depends on install.
# ------------------------------------------------------------------------------
build: install
@mkdir -p $(BUILD_DIR)
@mkdir -p $(STAMPS_DIR)
@TARGET=build; \
if [ ! -f "$(BUILD_STAMP)" ] || [ -n "$$(find $(GO_FILES) -newer "$(BUILD_STAMP)" 2>/dev/null)" ]; then \
echo "$(CHANGE_MSG) $$TARGET..."; \
go build -o $(BINARY) ./cmd/scrapeycli; \
touch "$(BUILD_STAMP)"; \
echo "Done with building."; \
else \
echo "$(SKIP_MSG) $$TARGET."; \
fi

# ------------------------------------------------------------------------------
# run: execute the compiled binary.
# Depends on build.
# ------------------------------------------------------------------------------
run: build
@echo "Running application..."
@$(BINARY)

# ------------------------------------------------------------------------------
# tree: displays directory structure (installs tree if missing).
# ------------------------------------------------------------------------------
tree:
@if ! command -v tree >/dev/null 2>&1; then \
echo "tree command not found. Attempting to install..."; \
OS=$$(uname); \
if [ "$$OS" = "Linux" ]; then \
sudo apt-get update && sudo apt-get install -y tree; \
elif [ "$$OS" = "Darwin" ]; then \
brew install tree; \
else \
echo "Automatic installation not supported on $$OS. Please install manually."; \
exit 1; \
fi; \
fi; \
tree -n -I "vendor|.git"
Loading