Skip to content

Commit

Permalink
Refactor the files (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
habedi authored Feb 28, 2025
1 parent 70f257e commit e29a24d
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linux Build
name: Build for Linux

on:
workflow_dispatch: # Allow manual execution
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: MacOS Build
name: Build for MacOS

on:
workflow_dispatch: # Allow manual execution
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Windows Build
name: Build for Windows

on:
workflow_dispatch: # Allow manual execution
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Release
name: Make a Release

on:
workflow_dispatch: # Allow manual execution
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Run Tests

on:
workflow_dispatch: # Allow manual execution
Expand All @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
# Go versions to test against
go-version: [ "1.21", "1.22", "1.23" ]
go-version: [ "1.21", "1.22", "1.23", "1.24" ]

steps:
- name: Checkout Repository
Expand Down
64 changes: 34 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ COVER_FLAGS = --cover --coverprofile=$(COVER_PROFILE)
CUSTOM_SNAPCRAFT_BUILD_ENVIRONMENT = $(or $(SNAP_BACKEND), multipass)
PATH := /snap/bin:$(PATH)

################################################################################
## Go Targets
################################################################################

# Default target
.DEFAULT_GOAL := help

Expand All @@ -18,67 +22,67 @@ help: ## Show this help message
.PHONY: build
build: format ## Build the binary for the current platform
@echo "Tidying dependencies..."
go mod tidy
@go mod tidy
@echo "Building the project..."
go build -o $(BINARY)
@go build -o $(BINARY)

.PHONY: format
format: ## Format Go files
@echo "Formatting Go files..."
go fmt ./...
@go fmt ./...

.PHONY: test
test: format ## Run tests
test: format ## Run the tests
@echo "Running tests..."
go test -v ./... $(COVER_FLAGS) --race
@go test -v ./... $(COVER_FLAGS) --race

.PHONY: showcov
showcov: test ## Display test coverage report
@echo "Displaying test coverage report..."
go tool cover -func=$(COVER_PROFILE)
@go tool cover -func=$(COVER_PROFILE)

.PHONY: clean
clean: ## Remove generated and temporary files
clean: ## Remove artifacts and temporary files
@echo "Cleaning up..."
find . -type f -name '*.got.*' -delete
find . -type f -name '*.out' -delete
find . -type f -name '*.snap' -delete
rm -f $(COVER_PROFILE)
rm -rf bin/
@find . -type f -name '*.got.*' -delete
@find . -type f -name '*.out' -delete
@find . -type f -name '*.snap' -delete
@rm -f $(COVER_PROFILE)
@rm -rf bin/

.PHONY: run
run: build ## Build and run the binary
@echo "Running the $(BINARY) binary..."
./$(BINARY)
@./$(BINARY)

.PHONY: build-macos
build-macos: format ## Build a universal binary for macOS (x86_64 and arm64)
@echo "Building universal binary for macOS..."
mkdir -p bin
GOARCH=amd64 go build -o bin/$(BINARY_NAME)-x86_64 ./main.go
GOARCH=arm64 go build -o bin/$(BINARY_NAME)-arm64 ./main.go
lipo -create -output $(BINARY) bin/$(BINARY_NAME)-x86_64 bin/$(BINARY_NAME)-arm64
@mkdir -p bin
@GOARCH=amd64 go build -o bin/$(BINARY_NAME)-x86_64 ./main.go
@GOARCH=arm64 go build -o bin/$(BINARY_NAME)-arm64 ./main.go
@lipo -create -output $(BINARY) bin/$(BINARY_NAME)-x86_64 bin/$(BINARY_NAME)-arm64

.PHONY: snap-deps
snap-deps: ## Install Snapcraft dependencies
@echo "Installing Snapcraft dependencies..."
sudo apt-get update
sudo apt-get install -y snapd
sudo snap refresh
sudo snap install snapcraft --classic
sudo snap install multipass --classic
@sudo apt-get update
@sudo apt-get install -y snapd
@sudo snap refresh
@sudo snap install snapcraft --classic
@sudo snap install multipass --classic

.PHONY: install-deps
install-deps: ## Install development dependencies on Debian-based systems
@echo "Installing dependencies..."
make snap-deps
sudo apt-get install -y chromium-browser build-essential chromium || true # ignore errors
sudo snap install chromium
sudo snap install go --classic
sudo snap install golangci-lint --classic
go mod download
@make snap-deps
@sudo apt-get install -y chromium-browser build-essential chromium || true # ignore errors
@sudo snap install chromium
@sudo snap install go --classic
@sudo snap install golangci-lint --classic
@go mod download

.PHONY: lint
lint: format ## Run linters on Go files
lint: format ## Run the linters
@echo "Linting Go files..."
golangci-lint run ./...
@golangci-lint run ./...
45 changes: 12 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,18 @@
</div>
<br>

<p align="center">
<a href="https://github.com/habedi/gogg/actions/workflows/tests.yml">
<img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/habedi/gogg/tests.yml?label=Tests&style=flat&labelColor=555555&logo=github">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_linux.yml">
<img alt="Linux Build" src="https://img.shields.io/github/actions/workflow/status/habedi/gogg/build_linux.yml?label=Linux%20Build&style=flat&labelColor=555555&logo=linux">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_windows.yml">
<img alt="Windows Build" src="https://img.shields.io/github/actions/workflow/status/habedi/gogg/build_windows.yml?label=Windows%20Build&style=flat&labelColor=555555&logo=github">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_macos.yml">
<img alt="MacOS Build" src="https://img.shields.io/github/actions/workflow/status/habedi/gogg/build_macos.yml?label=MacOS%20Build&style=flat&labelColor=555555&logo=apple">
</a>
<br>
<a href="docs">
<img alt="Docs" src="https://img.shields.io/badge/docs-latest-3776ab?style=flat&labelColor=555555&logo=readthedocs">
</a>
<a href="https://github.com/habedi/gogg">
<img alt="License" src="https://img.shields.io/badge/license-MIT-007ec6?style=flat&labelColor=555555&logo=open-source-initiative">
</a>
<a href="https://codecov.io/gh/habedi/gogg">
<img alt="Code Coverage" src="https://img.shields.io/codecov/c/github/habedi/gogg?style=flat&labelColor=555555&logo=codecov">
</a>
<a href="https://www.codefactor.io/repository/github/habedi/gogg">
<img alt="CodeFactor" src="https://img.shields.io/codefactor/grade/github/habedi/gogg?style=flat&labelColor=555555&logo=codefactor">
</a>
<a href="https://github.com/habedi/gogg/releases/latest">
<img alt="Release" src="https://img.shields.io/github/release/habedi/gogg.svg?style=flat&labelColor=555555&logo=github">
</a>
<a href="https://github.com/habedi/gogg/releases">
<img alt="Total Downloads" src="https://img.shields.io/github/downloads/habedi/gogg/total.svg?style=flat&labelColor=555555&logo=github">
</a>
</p>
[![Tests](https://img.shields.io/github/actions/workflow/status/habedi/gogg/tests.yml?label=tests&style=flat&labelColor=555555&logo=github)](https://github.com/habedi/gogg/actions/workflows/tests.yml)
[![Linters](https://img.shields.io/github/actions/workflow/status/habedi/gogg/linters.yml?label=lintss&style=flat&labelColor=555555&logo=github)](https://github.com/habedi/gogg/actions/workflows/lints.yml)
[![Linux Build](https://img.shields.io/github/actions/workflow/status/habedi/gogg/build_linux.yml?label=linux%20build&style=flat&labelColor=555555&logo=linux)](https://github.com/habedi/gogg/actions/workflows/build_linux.yml)
[![Windows Build](https://img.shields.io/github/actions/workflow/status/habedi/gogg/build_windows.yml?label=windows%20build&style=flat&labelColor=555555&logo=github)](https://github.com/habedi/gogg/actions/workflows/build_windows.yml)
[![MacOS Build](https://img.shields.io/github/actions/workflow/status/habedi/gogg/build_macos.yml?label=macos%20build&style=flat&labelColor=555555&logo=apple)](https://github.com/habedi/gogg/actions/workflows/build_macos.yml)
<br>
[![Docs](https://img.shields.io/badge/docs-latest-3776ab?style=flat&labelColor=555555&logo=readthedocs)](docs)
[![License](https://img.shields.io/badge/license-MIT-007ec6?style=flat&labelColor=555555&logo=open-source-initiative)](https://github.com/habedi/gogg)
[![Code Coverage](https://img.shields.io/codecov/c/github/habedi/gogg?style=flat&labelColor=555555&logo=codecov)](https://codecov.io/gh/habedi/gogg)
[![CodeFactor](https://img.shields.io/codefactor/grade/github/habedi/gogg?style=flat&labelColor=555555&logo=codefactor)](https://www.codefactor.io/repository/github/habedi/gogg)
[![Release](https://img.shields.io/github/release/habedi/gogg.svg?style=flat&labelColor=555555&logo=github)](https://github.com/habedi/gogg/releases/latest)
[![Total Downloads](https://img.shields.io/github/downloads/habedi/gogg/total.svg?style=flat&labelColor=555555&logo=github)](https://github.com/habedi/gogg/releases)

# Gogg

Expand Down
4 changes: 2 additions & 2 deletions logo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e29a24d

Please sign in to comment.