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
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "deps"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "deps"
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build

on:
push:
branches: [ 'main' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ 'main' ]

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
matrix:
os: [ 'macos-latest', 'ubuntu-latest' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
check-latest: true
# - name: Run linters
# run: make lint
- name: Run tests
run: make test
37 changes: 37 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CodeQL

on:
push:
branches: [ 'main' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ 'main' ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
check-latest: true
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: '/language:go'
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
*.so
*.dylib

# JetBrains
.idea/


# Test binary, built with `go test -c`
*.test

Expand All @@ -24,6 +20,14 @@
# Go workspace file
go.work

gcore-cli
# Editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~

# Project
bin/
dist/
gcore-cli
29 changes: 29 additions & 0 deletions .golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
run:
allow-parallel-runners: true
timeout: 5m

issues:
# don't skip warning about doc comments
# don't exclude the default set of lint
exclude-use-default: false

linters:
disable-all: true
enable:
- errcheck
- exportloopref
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused
51 changes: 46 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,49 @@
all: gcore-cli
all: build

.PHONY: gcore-cli
##@ General

build: gcore-cli
.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " %-15s %s\n", $$1, $$2 } /^##@/ { printf "\n%s\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

gcore-cli:
CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o gcore-cli cmd/gcore-cli/main.go
##@ Development

.PHONY: fmt
fmt: ## Run go fmt against code
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code
go vet ./...

.PHONY: lint
lint: golangci-lint ## Run golangci-lint against code
$(GOLANGCI_LINT) run -v ./...

.PHONY: test
test: fmt vet ## Run tests
go test -v -covermode=count -coverprofile=cover.out ./...

##@ Build

.PHONY: build
build: fmt vet ## Build gcore-cli binary
CGO_ENABLED=0 go build -trimpath -ldflags="-extldflags=-static" -o gcore-cli ./cmd/gcore-cli

##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint

## Tool Versions
GOLANGCI_LINT_VERSION ?= v1.56.2

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# gcore-cli

[![Build](https://github.com/G-Core/gcore-cli/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/G-Core/gcore-cli/actions/workflows/build.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/G-Core/gcore-cli)](https://goreportcard.com/report/github.com/G-Core/gcore-cli)

`gcore-cli` is the official Gcore command line tool.

## Installation
Expand Down