Skip to content

Commit 1622134

Browse files
Project build & development toolchain
>>> Mage The main project development and build toolchain for snowsaw is Mage (1), a Make/rake-like build tool using Go. The `magefile.go` file provides all relevant project tasks - from development and production builds, testing amd linting workflows, benchmarking up to code optimizations and asset handling. Even though Go comes with a complete development/testing/deployment suite out-of-the-box, a project build tool ensures all commands always executed in the correct order and all necessary information are provided. Under the hood, the `magefile` file will make use of Go's official toolchain, but ensures consistency and a simple usage through Mage's UI features. >>> IntelliJ Development Setup Next to Mage this commit also adds file watcher configurations (2) for IntelliJ's (3) official "File Watcher" plugin (4). IntelliJ plus the official Go plugin (5) is the recommended development IDE since it is the most complete and powerful for Go (as well as the most popular IDE for Java), providing a large amount of features. The official Go plugin (5) makes IntelliJ feature-equal to Goland (6) which is a "stripped down" version of IntelliJ's core engine only bundled with Go features. >>> GolangCI To ensure a good code quality the Go ecosystem has hundreds of linters, each with a different purpose. Instead of installing and running multiple linters separately GolangCI (7) provides a uniform interface to run most popular and useful linters in parallel and with many additional configuration features. The service is like many other great platforms free for open source projects. The actual runner golangci-lint (8) is also open source and can be used locally as well in any private CI/CD pipelines. In order to use it for snowsaw, a `.golangci.yml` configuration file has been added and the runner will be executed through the `lint` Mage task. >>> Cross-Compilation Go comes with all necessary tools to cross-compile out-of-the-box, but instead of running the commands manually gox (9) is used to also simplify this task as well as running and managing the compilation in parallel. To create distributions with and without binary artifact optimizations new Mage tasks have also been implemented. >>> Formatting To adhere to the Go code styleguide and conventions the official goimports (10) tool is used and executed through the dedicated `format` Mage task. >>> Testing Go comes with all necessary testing tools out-of-the-box that are used through Mage tasks where a distinction is made between unit and integration tests as well as with and without coverage profiling. The coverage reports can be used later on to integrate services like CodeCov (11) into snowsaw's CI/CD pipeline. References: (1) https://github.com/magefile/mage (2) https://www.jetbrains.com/help/idea/using-file-watchers.html (3) https://www.jetbrains.com/idea (4) https://plugins.jetbrains.com/plugin/7177-file-watchers (5) https://plugins.jetbrains.com/plugin/9568-go (6) https://www.jetbrains.com/go (7) https://golangci.com (8) https://github.com/golangci/golangci-lint (9) https://github.com/mitchellh/gox (10) https://godoc.org/golang.org/x/tools/cmd/goimports (11) https://codecov.io Epic GH-33 Depends on GH-58 Resolves GH-62
1 parent b1ed2cc commit 1622134

File tree

8 files changed

+724
-0
lines changed

8 files changed

+724
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ npm-debug.log*
2626
# +---------+
2727
.npm/
2828
**/node_modules/
29+
30+
# +-------------------+
31+
# + Project Structure +
32+
# +-------------------+
33+
build/

.golangci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Copyright (C) 2017-present Arctic Ice Studio <[email protected]>
2+
# Copyright (C) 2017-present Sven Greb <[email protected]>
3+
#
4+
# Project: snowsaw
5+
# Repository: https://github.com/arcticicestudio/snowsaw
6+
# License: MIT
7+
8+
# Configuration for golangci-lint as well as the golangci.com service.
9+
# See the official documentations for more details:
10+
# https://github.com/golangci/golangci-lint#configuration
11+
# https://github.com/golangci/golangci/wiki/Configuration
12+
13+
issues:
14+
exclude-rules:
15+
- linters:
16+
- lll
17+
source: "^//go:generate "
18+
19+
max-issues-per-linter: 0
20+
max-same-issues: 0
21+
22+
linters:
23+
enable-all: true
24+
disable:
25+
- depguard
26+
- gochecknoglobals
27+
- gochecknoinits
28+
- maligned
29+
- prealloc
30+
31+
linters-settings:
32+
dupl:
33+
# Minimum count of tokens before triggering as duplicate code.
34+
threshold: 100
35+
36+
errcheck:
37+
# Report about not checking of errors in type assertions.
38+
# Example: `a := b.(CustomStruct)`
39+
check-type-assertions: true
40+
41+
goconst:
42+
min-len: 2
43+
min-occurrences: 3
44+
45+
gocritic:
46+
enabled-tags:
47+
- diagnostic
48+
- performance
49+
- style
50+
51+
goimports:
52+
# A comma-separated list of prefixes for local package imports to be put after 3rd-party packages.
53+
local-prefixes: github.com/arcticicestudio/snowsaw
54+
55+
golint:
56+
min-confidence: 0.0
57+
58+
govet:
59+
check-shadowing: true
60+
# See `go tool vet help [ANALYZER]` for more details about available analyzers and their settings.
61+
settings:
62+
printf:
63+
# Register custom functions to be included in the analyse.
64+
funcs:
65+
- (github.com/arcticicestudio/snowsaw/pkg/prt).Debugf
66+
- (github.com/arcticicestudio/snowsaw/pkg/prt).Infof
67+
- (github.com/arcticicestudio/snowsaw/pkg/prt).Successf
68+
- (github.com/arcticicestudio/snowsaw/pkg/prt).Warnf
69+
- (github.com/arcticicestudio/snowsaw/pkg/prt).Errorf
70+
- (github.com/arcticicestudio/snowsaw/pkg/prt).Fatalf
71+
72+
lll:
73+
line-length: 160
74+
75+
misspell:
76+
locale: US
77+
78+
run:
79+
deadline: 15m
80+
81+
service:
82+
golangci-lint-version: 1.17.x

.idea/saved-exports/fileWatchers.xml

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/watcherTasks.xml

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/fatih/color v1.7.0
77
github.com/ghodss/yaml v1.0.0
88
github.com/imdario/mergo v0.3.7
9+
github.com/magefile/mage v1.8.0
910
github.com/mattn/go-colorable v0.1.2 // indirect
1011
github.com/mitchellh/go-homedir v1.1.0
1112
github.com/spf13/cobra v0.0.5

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
1515
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
1616
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
1717
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
18+
github.com/magefile/mage v1.8.0 h1:mzL+xIopvPURVBwHG9A50JcjBO+xV3b5iZ7khFRI+5E=
19+
github.com/magefile/mage v1.8.0/go.mod h1:IUDi13rsHje59lecXokTfGX0QIzO45uVPlXnJYsXepA=
1820
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
1921
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
2022
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=

0 commit comments

Comments
 (0)