mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-02-03 23:17:47 +00:00
replace makefile with taskfile
add CI config + action
This commit is contained in:
parent
0736baea4b
commit
4616ac7aa5
29
.github/workflows/golang-ci.yml
vendored
Normal file
29
.github/workflows/golang-ci.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['main']
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
pull_request:
|
||||||
|
branches: ['main']
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
timeout-minutes: 3
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24'
|
||||||
|
- name: Install golangci-lint
|
||||||
|
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||||
|
- name: Run golangci-lint
|
||||||
|
run: golangci-lint run ./...
|
||||||
54
.golangci.yml
Normal file
54
.golangci.yml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
run:
|
||||||
|
# timeout for analysis, e.g. 30s, 3m, default is 1m
|
||||||
|
timeout: 3m
|
||||||
|
# exclude test files
|
||||||
|
tests: true
|
||||||
|
|
||||||
|
linters:
|
||||||
|
# Set to true runs only fast linters.
|
||||||
|
# Good option for 'lint on save', pre-commit hook or CI.
|
||||||
|
fast: true
|
||||||
|
|
||||||
|
disable-all: true
|
||||||
|
|
||||||
|
enable:
|
||||||
|
- gosimple
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
- staticcheck
|
||||||
|
- unused
|
||||||
|
- gofmt
|
||||||
|
- gofumpt
|
||||||
|
- misspell
|
||||||
|
- unparam
|
||||||
|
- gosec
|
||||||
|
- asciicheck
|
||||||
|
- errname
|
||||||
|
- gci
|
||||||
|
- godot
|
||||||
|
- goimports
|
||||||
|
- revive
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
gofmt:
|
||||||
|
rewrite-rules:
|
||||||
|
- pattern: 'interface{}'
|
||||||
|
replacement: 'any'
|
||||||
|
- pattern: 'a[b:len(a)]'
|
||||||
|
replacement: 'a[b:]'
|
||||||
|
|
||||||
|
misspell:
|
||||||
|
locale: UK
|
||||||
|
|
||||||
|
errcheck:
|
||||||
|
check-type-assertions: true
|
||||||
|
|
||||||
|
issues:
|
||||||
|
max-same-issues: 0
|
||||||
|
max-issues-per-linter: 0
|
||||||
|
exclude-use-default: false
|
||||||
|
exclude:
|
||||||
|
# gosec: Duplicated errcheck checks
|
||||||
|
- G104
|
||||||
|
# gosec: integer overflow conversion int -> uint32
|
||||||
|
- G115
|
||||||
57
Taskfile.yml
Normal file
57
Taskfile.yml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
vars:
|
||||||
|
PROGRAM: xair-cli
|
||||||
|
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
||||||
|
BIN_DIR: bin
|
||||||
|
VERSION:
|
||||||
|
sh: 'git describe --tags $(git rev-list --tags --max-count=1)'
|
||||||
|
|
||||||
|
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
|
||||||
|
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
|
desc: Build the xair-cli project
|
||||||
|
cmds:
|
||||||
|
- task: build
|
||||||
|
|
||||||
|
build:
|
||||||
|
desc: Build the xair-cli project
|
||||||
|
deps: [vet]
|
||||||
|
cmds:
|
||||||
|
- task: build-windows
|
||||||
|
- task: build-linux
|
||||||
|
|
||||||
|
vet:
|
||||||
|
desc: Vet the code
|
||||||
|
deps: [fmt]
|
||||||
|
cmds:
|
||||||
|
- go vet ./...
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
desc: Fmt the code
|
||||||
|
cmds:
|
||||||
|
- go fmt ./...
|
||||||
|
|
||||||
|
build-windows:
|
||||||
|
desc: Build the xair-cli project for Windows
|
||||||
|
cmds:
|
||||||
|
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}"
|
||||||
|
internal: true
|
||||||
|
|
||||||
|
build-linux:
|
||||||
|
desc: Build the xair-cli project for Linux
|
||||||
|
cmds:
|
||||||
|
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}"
|
||||||
|
internal: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
desc: Run tests
|
||||||
|
cmds:
|
||||||
|
- go test ./...
|
||||||
|
|
||||||
|
clean:
|
||||||
|
desc: Clean the build artifacts
|
||||||
|
cmds:
|
||||||
|
- '{{.SHELL}} rm -r {{.BIN_DIR}}'
|
||||||
40
makefile
40
makefile
@ -1,40 +0,0 @@
|
|||||||
program = xair-cli
|
|
||||||
|
|
||||||
GO = @go
|
|
||||||
BIN_DIR := bin
|
|
||||||
|
|
||||||
WINDOWS=$(BIN_DIR)/$(program)_windows_amd64.exe
|
|
||||||
LINUX=$(BIN_DIR)/$(program)_linux_amd64
|
|
||||||
VERSION=$(shell git describe --tags --always --long --dirty)
|
|
||||||
|
|
||||||
.DEFAULT_GOAL := build
|
|
||||||
|
|
||||||
.PHONY: fmt vet build windows linux test clean
|
|
||||||
fmt:
|
|
||||||
$(GO) fmt ./...
|
|
||||||
|
|
||||||
vet: fmt
|
|
||||||
$(GO) vet ./...
|
|
||||||
|
|
||||||
build: vet windows linux | $(BIN_DIR)
|
|
||||||
@echo version: $(VERSION)
|
|
||||||
|
|
||||||
windows: $(WINDOWS)
|
|
||||||
|
|
||||||
linux: $(LINUX)
|
|
||||||
|
|
||||||
|
|
||||||
$(WINDOWS):
|
|
||||||
env GOOS=windows GOARCH=amd64 go build -v -o $(WINDOWS) -ldflags="-s -w -X main.version=$(VERSION)" .
|
|
||||||
|
|
||||||
$(LINUX):
|
|
||||||
env GOOS=linux GOARCH=amd64 go build -v -o $(LINUX) -ldflags="-s -w -X main.version=$(VERSION)" .
|
|
||||||
|
|
||||||
test:
|
|
||||||
$(GO) test ./...
|
|
||||||
|
|
||||||
$(BIN_DIR):
|
|
||||||
@mkdir -p $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -rv $(BIN_DIR)
|
|
||||||
Loading…
x
Reference in New Issue
Block a user