commit 60414874d957e7e1f0f4feca30163223cac562e4 Author: IamTheFij Date: Wed Feb 9 17:25:37 2022 +0000 Initial commit diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..f5ac111 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,86 @@ +--- +kind: pipeline +name: test + +steps: + - name: test + image: golang:1.17 + environment: + VERSION: ${DRONE_TAG:-${DRONE_COMMIT}} + commands: + - make test + + - name: check + image: iamthefij/drone-pre-commit:personal + +--- +kind: pipeline +name: publish + +depends_on: + - test + +trigger: + event: + - push + - tag + refs: + - refs/heads/master + - refs/tags/v* + +steps: + - name: build all binaries + image: golang:1.17 + environment: + VERSION: ${DRONE_TAG:-${DRONE_COMMIT}} + commands: + - make all + + - name: compress binaries for release + image: ubuntu + commands: + - find ./dist -type f -executable -execdir tar -czvf {}.tar.gz {} \; + when: + event: tag + + - name: upload gitea release + image: plugins/gitea-release + settings: + title: ${DRONE_TAG} + files: dist/*.tar.gz + checksum: + - md5 + - sha1 + - sha256 + - sha512 + base_url: + from_secret: gitea_base_url + api_key: + from_secret: gitea_token + when: + event: tag + +--- +kind: pipeline +name: notify + +depends_on: + - test + - publish + +trigger: + status: + - failure + +steps: + + - name: notify + image: drillster/drone-email + settings: + host: + from_secret: SMTP_HOST # pragma: whitelist secret + username: + from_secret: SMTP_USER # pragma: whitelist secret + password: + from_secret: SMTP_PASS # pragma: whitelist secret + from: drone@iamthefij.com diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b4fe5a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# ---> Go +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Output dist directory +dist/ + +# Built executable +imap-notes diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..9dafa72 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,48 @@ +--- +linters: + enable: + - asciicheck + - bodyclose + - dogsled + - dupl + - exhaustive + - gochecknoinits + - gocognit + - gocritic + - gocyclo + - goerr113 + - gofumpt + - goimports + - gomnd + - goprintffuncname + # - gosec + # - ifshort + - interfacer + - maligned + - misspell + - nakedret + - nestif + - nlreturn + - noctx + - unparam + - wsl + # - errorlint + disable: + - gochecknoglobals + +linters-settings: + gosec: + excludes: + - G204 +# gomnd: +# settings: +# mnd: +# ignored-functions: math.* + +issues: + exclude-rules: + - path: _test\.go + linters: + - errcheck + - gosec + - maligned diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5ebaf84 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-added-large-files + - id: check-yaml + args: + - --allow-multiple-documents + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-merge-conflict + - repo: git://github.com/dnephin/pre-commit-golang + rev: v0.4.0 + hooks: + - id: go-fmt + - id: go-imports + - id: golangci-lint diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4767680 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2021 $REPO_OWNER + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f034873 --- /dev/null +++ b/Makefile @@ -0,0 +1,60 @@ +APP_NAME = imap-notes +VERSION ?= $(shell git describe --tags --dirty) +GOFILES = *.go +# Multi-arch targets are generated from this +TARGET_ALIAS = $(APP_NAME)-linux-amd64 $(APP_NAME)-linux-arm $(APP_NAME)-linux-arm64 $(APP_NAME)-darwin-amd64 $(APP_NAME)-darwin-arm64 +TARGETS = $(addprefix dist/,$(TARGET_ALIAS)) +# +# Default make target will run tests +.DEFAULT_GOAL = test + +# Build all static Minitor binaries +.PHONY: all +all: $(TARGETS) + +# Build all static Linux Minitor binaries +.PHONY: all-linux +all-linux: $(filter dist/$(APP_NAME)-linux-%,$(TARGETS)) + +# Build imap-notes for the current machine +$(APP_NAME): $(GOFILES) + @echo Version: $(VERSION) + go build -ldflags '-X "main.version=$(VERSION)"' -o $(APP_NAME) + +.PHONY: build +build: $(APP_NAME) + +# Run all tests +.PHONY: test +test: + go test -coverprofile=coverage.out + go tool cover -func=coverage.out + @go tool cover -func=coverage.out | awk -v target=80.0% \ + '/^total:/ { print "Total coverage: " $3 " Minimum coverage: " target; if ($3+0.0 >= target+0.0) print "ok"; else { print "fail"; exit 1; } }' + +# Installs pre-commit hooks +.PHONY: install-hooks +install-hooks: + pre-commit install --install-hooks + +# Runs pre-commit checks on files +.PHONY: check +check: + pre-commit run --all-files + +.PHONY: clean +clean: + rm -f ./$(APP_NAME) + rm -f ./coverage.out + rm -fr ./dist + +## Multi-arch targets +$(TARGETS): $(GOFILES) + mkdir -p ./dist + GOOS=$(word 2, $(subst -, ,$(@))) GOARCH=$(word 3, $(subst -, ,$(@))) CGO_ENABLED=0 \ + go build -ldflags '-X "main.version=$(VERSION)"' -a -installsuffix nocgo \ + -o $@ + +.PHONY: $(TARGET_ALIAS) +$(TARGET_ALIAS): + $(MAKE) $(addprefix dist/,$@) diff --git a/README.md b/README.md new file mode 100644 index 0000000..2fe8bc3 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# [imap-notes](/iamthefij/imap-notes) + +A terminal IMAP Notes editor compatible with Apple Notes diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c6cfccb --- /dev/null +++ b/go.mod @@ -0,0 +1,6 @@ +module git.iamthefij.com//iamthefij/imap-notes + +go 1.17 + +require ( +) diff --git a/main.go b/main.go new file mode 100644 index 0000000..631c3b5 --- /dev/null +++ b/main.go @@ -0,0 +1,18 @@ +package main + +var ( + // version of imap-notes being run + version = "dev" +) + +func main() { + showVersion := flag.Bool("version", false, "Display the version of minitor and exit") + flag.Parse() + + // Print version if flag is provided + if *showVersion { + fmt.Println("imap-notes version:", version) + + return + } +}