diff --git a/.circleci/config.yml b/.circleci/config.yml index 62fd8f0..85b55fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,53 +1,14 @@ version: 2.1 -executors: - golang: - working_directory: /go/src/moul.io/moulsay - docker: - - image: circleci/golang:1.12 - environment: - GO111MODULE: "on" - DOCKER_IMAGE: moul/moulsay - - docker: - docker: - - image: docker:18.06.3-ce-git - orbs: - codecov: codecov/codecov@1.0.5 - moul: moul/build@1.5.0 - retry: moul/retry@0.6.0 - docker: circleci/docker@0.5.13 - #dl: moul/dl@1.7.0 - tools: gotest/tools@0.0.10 - -jobs: - go-build: - executor: golang - steps: - - checkout - - retry/install - - tools/mod-download - - tools/mod-tidy-check - - run: retry -m 3 make install - - run: retry -m 3 make test - - moul/install_golangci-lint - - run: PATH=$PATH:$(pwd)/bin retry -m 3 make lint - - codecov/upload: - file: coverage.txt - - docker-build: - executor: docker - steps: - - checkout - - setup_remote_docker: - docker_layer_caching: true - - docker/build: - image: moul/moulsay - #- docker/dockerlint + moul: moul/build@1.10.0 # https://github.com/moul/build workflows: main: jobs: - - go-build - - docker-build + - moul/golang-build: + gopkg: moul.io/moulsay + - moul/golang-build: + gopkg: moul.io/moulsay + tag: '1.11' + - moul/docker-build diff --git a/.goreleaser.yml b/.github/.goreleaser.yml similarity index 100% rename from .goreleaser.yml rename to .github/.goreleaser.yml diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..3627bc2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,31 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG] " +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Type '....' +3. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots / Logs** +If applicable, add screenshots or logs to help explain your problem. + +**Versions (please complete the following information, if relevant):** + - Software version: [e.g. v1.2.3, latest, building from sources] + - OS: [e.g. Ubuntu, Mac, iOS, ...] + - Golang version [e.g. 1.12] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..9ef8997 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom +about: 'Anything else: questions, discussions, thanks, ascii-arts, ...' +title: '' +labels: discussion +assignees: moul + +--- + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..3f27c3f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[IDEA] " +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ebc63af --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,9 @@ + diff --git a/renovate.json b/.github/renovate.json similarity index 100% rename from renovate.json rename to .github/renovate.json diff --git a/.gitignore b/.gitignore index 60f6c2f..53b035e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ coverage.txt # Vendors +package-lock.json node_modules/ vendor/ diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..73dba8d --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,22 @@ +Copyright 2019 Manfred Touron and other moulsay Developers. + +Intellectual Property Notice +---------------------------- + +moulsay is licensed under the Apache License, Version 2.0 +(see LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) of +the MIT license (see LICENSE-MIT or http://opensource.org/licenses/MIT), +at your option. + +Copyrights and patents in the moulsays project are retained +by contributors. +No copyright assignment is required to contribute to moulsay. + + SPDX-License-Identifier: (Apache-2.0 OR MIT) + +SPDX usage +---------- + +Individual files may contain SPDX tags instead of the full license text. +This enables machine processing of license information based on the SPDX +License Identifiers that are available here: https://spdx.org/licenses/ diff --git a/LICENSE b/LICENSE-APACHE similarity index 99% rename from LICENSE rename to LICENSE-APACHE index 889a22d..fa43fcf 100644 --- a/LICENSE +++ b/LICENSE-APACHE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2019 Manfred Touron + Copyright 2019 Manfred Touron (manfred.life) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..849c5c0 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2019 Manfred Touron (manfred.life) + +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 index e828742..804ecc8 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,7 @@ -GO ?= go -DOCKER_IMAGE ?= moul/moulsay +GOPKG ?= moul.io/moulsay +DOCKER_IMAGE ?= moul/moulsay +GOBINS ?= . -.PHONY: install -install: - $(GO) install . +all: test install -.PHONY: test -test: - echo "" > /tmp/coverage.txt - set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ - cd $$dir; \ - $(GO) test -mod=readonly -v -cover -coverprofile=/tmp/profile.out -covermode=atomic -race ./...; \ - if [ -f /tmp/profile.out ]; then \ - cat /tmp/profile.out >> /tmp/coverage.txt; \ - rm -f /tmp/profile.out; \ - fi); done - mv /tmp/coverage.txt . - -.PHONY: lint -lint: - golangci-lint run --verbose ./... - -.PHONY: release -release: - goreleaser --snapshot --skip-publish --rm-dist - @echo -n "Do you want to release? [y/N] " && read ans && [ $${ans:-N} = y ] - goreleaser --rm-dist - -.PHONY: docker -docker: - docker build \ - --build-arg VCS_REF=`git rev-parse --short HEAD` \ - --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ - --build-arg VERSION=`git describe --tags --always` \ - -t $(DOCKER_IMAGE) . +-include rules.mk diff --git a/SECURITY.md b/SECURITY.md index 8c3e37a..6705984 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,6 +4,6 @@ I take security seriously. If you discover a security issue, please bring it to ### Reporting a Vulnerability -Please **DO NOT** file a public issue, instead send your report privately to m+security-report@42.am. +Please **DO NOT** file a public issue, instead send your report privately to security@moul.io. Security reports are greatly appreciated and I will publicly thank you for it, although I keep your name confidential if you request it. diff --git a/package.json b/package.json new file mode 100644 index 0000000..ba8ca68 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "_comment": "this project is not a node.js one, package.json is just used to define some metadata", + "name": "@moul.io/moulsay", + "version": "0.0.1", + "author": "Manfred Touron (https://manfred.life)", + "contributors": [ + "Manfred Touron (https://manfred.life)" + ], + "license": "(Apache-2.0 OR MIT)", + "scripts": { + "start": "moulsay", + "install": "make install", + "test": "make test" + }, + "repository": { + "type": "git", + "url": "https://github.com/moul/moulsay.git" + }, + "bugs": "https://github.com/moul/moulsay/issues", + "homepage": "https://moul.io/moulsay" +} diff --git a/rules.mk b/rules.mk new file mode 100644 index 0000000..298013d --- /dev/null +++ b/rules.mk @@ -0,0 +1,168 @@ +# +--------------------------------------------------------------+ +# | * * * moul.io/rules.mk | +# +--------------------------------------------------------------+ +# | | +# | ++ ______________________________________ | +# | ++++ / \ | +# | ++++ | | | +# | ++++++++++ | https://moul.io/rules.mk is a set | | +# | +++ | | of common Makefile rules that can | | +# | ++ | | be configured from the Makefile | | +# | + -== ==| | or with environment variables. | | +# | ( <*> <*> | | | +# | | | /| Manfred Touron | | +# | | _) / | manfred.life | | +# | | +++ / \______________________________________/ | +# | \ =+ / | +# | \ + | +# | |\++++++ | +# | | ++++ ||// | +# | ___| |___ _||/__ __| +# | / --- \ \| ||| __ _ ___ __ __/ /| +# |/ | | \ \ / / ' \/ _ \/ // / / | +# || | | | | | /_/_/_/\___/\_,_/_/ | +# +--------------------------------------------------------------+ + +## +## rules.mk +## +ifeq ($(RULESMK),1) +.PHONY: rulesmk.bumpdeps +rulesmk.bumpdeps: + wget -O rules.mk https://raw.githubusercontent.com/moul/rules.mk/master/rules.mk + +BUMPDEPS_STEPS += rulesmk.bumpdeps +endif + +## +## Golang +## + +ifdef GOPKG +GO ?= go + +ifdef GOBINS +.PHONY: go.install +go.install: + set -e; for dir in $(GOBINS); do ( set -xe; \ + cd $$dir; \ + $(GO) install .; \ + ); done +INSTALL_STEPS += go.install +endif + +.PHONY: go.unittest +go.unittest: + echo "" > /tmp/coverage.txt + set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + $(GO) test -v -cover -coverprofile=/tmp/profile.out -covermode=atomic -race ./...; \ + if [ -f /tmp/profile.out ]; then \ + cat /tmp/profile.out >> /tmp/coverage.txt; \ + rm -f /tmp/profile.out; \ + fi); done + mv /tmp/coverage.txt . + +.PHONY: go.lint +go.lint: + set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + golangci-lint run --verbose ./...; \ + ); done + +.PHONY: go.tidy +go.tidy: + set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + $(GO) mod tidy; \ + ); done + +.PHONY: go.build +go.build: + set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + $(GO) build ./...; \ + ); done + +.PHONY: go.bump-deps +go.bumpdeps: + set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + $(GO) get -u ./...; \ + ); done + +.PHONY: go.release +go.release: + goreleaser --snapshot --skip-publish --rm-dist + @echo -n "Do you want to release? [y/N] " && read ans && [ $${ans:-N} = y ] + goreleaser --rm-dist + +BUILD_STEPS += go.build +RELEASE_STEPS += go.release +BUMPDEPS_STEPS += go.bumpdeps +TIDY_STEPS += go.tidy +LINT_STEPS += go.lint +UNITTEST_STEPS += go.unittest +endif + +## +## Docker +## + +ifdef DOCKER_IMAGE +.PHONY: docker.build +docker.build: + docker build \ + --build-arg VCS_REF=`git rev-parse --short HEAD` \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VERSION=`git describe --tags --always` \ + -t $(DOCKER_IMAGE) . + +BUILD_STEPS += docker.build +endif + +## +## Common +## + +TEST_STEPS += $(UNITTEST_STEPS) +TEST_STEPS += $(LINT_STEPS) +TEST_STEPS += $(TIDY_STEPS) +ALL_STEPS += $(TEST_STEPS) + +all: $(ALL_STEPS) + +ifneq ($(strip $(TEST_STEPS)),) +.PHONY: test +test: $(TEST_STEPS) +endif + +ifdef INSTALL_STEPS +.PHONY: install +install: $(INSTALL_STEPS) +endif + +ifdef UNITTEST_STEPS +.PHONY: unittest +unittest: $(UNITTEST_STEPS) +endif + +ifdef LINT_STEPS +.PHONY: lint +lint: $(LINT_STEPS) +endif + +ifdef TIDY_STEPS +.PHONY: tidy +tidy: $(TIDY_STEPS) +endif + +ifdef BUILD_STEPS +.PHONY: build +build: $(BUILD_STEPS) +endif + +ifdef BUMPDEPS_STEPS +.PHONY: bumpdeps +bumpdeps: $(BUMPDEPS_STEPS) +endif