Skip to content

Commit

Permalink
Merge pull request #5 from jjuarez/feature/update-the-modules
Browse files Browse the repository at this point in the history
Feature: Regular updates
  • Loading branch information
jjuarez authored Jul 25, 2024
2 parents 7405ec5 + 6e9fc55 commit 1aaf6e7
Show file tree
Hide file tree
Showing 6 changed files with 2,176 additions and 87 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml → .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Pipeline
name: Build & Tests

on:
push:
Expand All @@ -8,7 +8,9 @@ on:
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
build:
Expand All @@ -17,11 +19,17 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.16'
go-version: '^1.21'
- run: go version

- name: Build
run: make build

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.21'
- name: Test
run: make test
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
54 changes: 45 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,65 @@ GOCOMMAND := go
GOBUILD := $(GOCOMMAND) build
GOCLEAN := $(GOCOMMAND) clean
GOTEST := $(GOCOMMAND) test
GOLINT := $(shell command -v golangci-lint 2>/dev/null)

EXECUTABLE := ikscc
INSTALL_PATH := /usr/local/bin
INSTALL := $(INSTALL_PATH)/$(EXECUTABLE)

PROJECT_CHANGESET := $(shell git rev-parse --verify HEAD 2>/dev/null)


define assert-command
@$(if $(shell command -v $1 2>/dev/null),,$(error $(1) command not found))
endef

BINARY := ./bin/ikscc

.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nTargets:\n"} /^[a-z0-9//_-]+:.*?##/ { printf " %-15s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nTargets:\n"} /^[a-z0-9\/_-]+:.*?##/ { printf " %-15s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)


.PHONY: lint
lint: ## Lint
$(call assert-command,$(GOLINT))
@$(GOLINT) --verbose run ./...


./bin/$(EXECUTABLE):
ifdef PROJECT_VERSION
@$(GOBUILD) -v -ldflags="-X github.com/jjuarez/iks-ctx-cleaner/cmd.Version='v$(PROJECT_VERSION)'" -o ./bin/$(EXECUTABLE) main.go
else
@$(GOBUILD) -v -ldflags="-X github.com/jjuarez/iks-ctx-cleaner/cmd.Version='nightly:$(PROJECT_CHANGESET)'" -o ./bin/$(EXECUTABLE) main.go
endif


.PHONY: build
build: ## Builds the binary
@$(GOBUILD) -o $(BINARY) -v main.go
build: ./bin/$(EXECUTABLE) ## Builds the binary

.PHONY: run
run: build ## Runs the latest binary
@$(BINARY)

.PHONY: test
test: ## Testing all the things
@$(GOTEST) -v ./...


.PHONY: clean
clean: ## Clean the generated products
@$(GOCLEAN)
@rm -fr $(BINARY) ./dist/*
@rm -fr ./bin/$(EXECUTABLE) ./dist/*


$(INSTALL):
@install -m 0755 ./bin/$(EXECUTABLE) $(INSTALL_PATH)

.PHONY: build install
install: $(INSTALL) ## Installs the program in the system


.PHONY: uninstall
uninstall: ## Uninstalls the program from the system
@rm -f $(INSTALL)


.PHONY: all
all: clean build test
all: lint build test install
11 changes: 7 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ module github.com/jjuarez/iks-ctx-cleaner
go 1.16

require (
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.7.1
gopkg.in/yaml.v3 v3.0.0
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
gopkg.in/yaml.v3 v3.0.1
)
Loading

0 comments on commit 1aaf6e7

Please sign in to comment.