Skip to content

Commit

Permalink
Add license headers (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
yohamta authored Aug 3, 2024
1 parent f419767 commit 9666c33
Show file tree
Hide file tree
Showing 120 changed files with 1,854 additions and 93 deletions.
134 changes: 77 additions & 57 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,92 @@
# https://golangci-lint.run/usage/configuration/#config-file
# Linters: https://golangci-lint.run/usage/linters/
linters:
disable-all: true
enable:
# enabled by default
- errcheck
- goimports
- revive
- staticcheck
- govet
- forbidigo
- exhaustive
- godox
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- misspell
# additional
- bodyclose
- goheader
- goimports
- gosec
- misspell
- exhaustive
- revive

issues:
exclude-use-default: true
exclude-rules:
- path: _test\.go
linters:
- gosec
exclude-dirs:
- .github
- .vscode
- local
- config
- scripts
- ui
- docs
- gen
- filenotify

linters-settings:
godox:
keywords:
- FIXME # marks TODOs that must be fixed before merging
revive:
severity: error
confidence: 0.8
enable-all-rules: true
enable-all-rules: false
rules:
# Disabled rules
- name: add-constant
disabled: true
- name: max-public-structs
disabled: true
- name: cognitive-complexity
disabled: true
- name: unchecked-type-assertion
disabled: true
- name: cyclomatic
disabled: true
- name: empty-lines
disabled: true
- name: confusing-naming
disabled: true
- name: bare-return
disabled: true
- name: flag-parameter
disabled: true
- name: unused-receiver
disabled: true
- name: function-length
disabled: true
- name: unused-parameter
disabled: true
- name: deep-exit
disabled: true
- name: line-length-limit
disabled: true
issues:
exclude-dirs:
- ui
- assets
- .git
- cert
- bin
- internal/frontend/gen
- internal/scheduler/filenotify
exclude-rules:
- path: _test\.go|tests/.+\.go
linters:
- err113 # like err = errors.New("test error")
- gosec
- add-constant
- revive
- name: "unused-parameter"
disabled: false
- name: "import-alias-naming"
disabled: false
- name: "if-return"
disabled: false
- name: "error-return"
disabled: false
- name: "dot-imports"
disabled: false
- name: "struct-tag"
disabled: false
- name: "function-result-limit"
disabled: false
- name: "atomic"
disabled: false
- name: "use-any"
disabled: false
- name: "redundant-import-alias"
disabled: false
- name: "enforce-map-style"
disabled: false
- name: "enforce-slice-style"
disabled: false
goheader:
values:
const:
AUTHOR: The Daguflow/Dagu Authors
template: |-
Copyright (C) {{ YEAR }} {{ AUTHOR }}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
run:
allow-parallel-runners: true
go: "1.22"
2 changes: 2 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"esbenp.prettier-vscode",
// Run on save
"emeraldwalk.runonsave",
// CSpell
"streetsidesoftware.code-spell-checker"
]
}
8 changes: 0 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,4 @@
"files.associations": {
"*.gohtml": "html"
},
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.go$",
"cmd": "golines ${file} -w"
}
]
},
}
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ BUILD_VERSION=$(shell date +'%y%m%d%H%M%S')
LDFLAGS=-X 'main.version=$(BUILD_VERSION)'

# Application name

APP_NAME=dagu

# Docker image build configuration
Expand Down Expand Up @@ -56,6 +55,7 @@ PKG_swagger=github.com/go-swagger/go-swagger/cmd/swagger
PKG_golangci_lint=github.com/golangci/golangci-lint/cmd/golangci-lint
PKG_gotestsum=gotest.tools/gotestsum
PKG_gomerger=github.com/yohamta/gomerger
PKG_addlicense=github.com/google/addlicense

# Certificates for the development environment

Expand Down Expand Up @@ -159,6 +159,7 @@ build-image-latest:
@echo "${COLOR_GREEN}Building the docker image...${COLOR_RESET}"
$(DOCKER_CMD) -t ghcr.io/daguflow/${APP_NAME}:latest .

# gomerger merges all go files into a single file.
gomerger: ${LOCAL_DIR}/merged
@echo "${COLOR_GREEN}Merging Go files...${COLOR_RESET}"
@rm -f ${LOCAL_DIR}/merged/merged_project.go
Expand All @@ -169,15 +170,42 @@ gomerger: ${LOCAL_DIR}/merged
${LOCAL_DIR}/merged:
@mkdir -p ${LOCAL_DIR}/merged

# addlicnese adds license header to all files.
addlicense:
@echo "${COLOR_GREEN}Adding license headers...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install ${PKG_addlicense}
@${LOCAL_BIN_DIR}/addlicense \
-ignore "**/node_modules/**" \
-ignore "./**/gen/**" \
-ignore "Dockerfile" \
-ignore "ui/*" \
-ignore "ui/**/*" \
-ignore "bin/*" \
-ignore "local/*" \
-ignore "docs/**" \
-ignore "**/examples/*" \
-ignore ".github/*" \
-ignore ".github/**/*" \
-ignore ".*" \
-ignore "**/*.yml" \
-ignore "**/*.yaml" \
-ignore "**/filenotify/*" \
-ignore "**/testdata/**" \
-c "The Daguflow/Dagu Authors" \
-f scripts/header.txt \
.

##############################################################################
# Internal targets
##############################################################################

# build-bin builds the go application.
build-bin:
@echo "${COLOR_GREEN}Building the binary...${COLOR_RESET}"
@mkdir -p ${BIN_DIR}
@go build -ldflags="$(LDFLAGS)" -o ${BIN_DIR}/${APP_NAME} .

# build-ui builds the frontend codes.
build-ui:
@echo "${COLOR_GREEN}Building UI...${COLOR_RESET}"
@cd ui; \
Expand All @@ -186,16 +214,19 @@ build-ui:
@rm -f ${FE_ASSETS_DIR}/*
@cp ${FE_BUILD_DIR}/* ${FE_ASSETS_DIR}

# golangci-lint run linting tool.
golangci-lint:
@echo "${COLOR_GREEN}Running linter...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install $(PKG_golangci_lint)
@${LOCAL_BIN_DIR}/golangci-lint run ./...

# clean-swagger removes generated go files for swagger.
clean-swagger:
@echo "${COLOR_GREEN}Cleaning the swagger files...${COLOR_RESET}"
@rm -rf ${FE_GEN_DIR}/restapi/models
@rm -rf ${FE_GEN_DIR}/restapi/operations

# gen-swagger generates go files for the API schema.
gen-swagger:
@echo "${COLOR_GREEN}Generating the swagger server code...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install $(PKG_swagger)
Expand Down
15 changes: 15 additions & 0 deletions cmd/common_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2024 The Daguflow/Dagu Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions cmd/dry.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2024 The Daguflow/Dagu Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions cmd/dry_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2024 The Daguflow/Dagu Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions cmd/logging.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2024 The Daguflow/Dagu Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions cmd/modules.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2024 The Daguflow/Dagu Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions cmd/reqid.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2024 The Daguflow/Dagu Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd

import "github.com/google/uuid"
Expand Down
15 changes: 15 additions & 0 deletions cmd/restart.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2024 The Daguflow/Dagu Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd

import (
Expand Down
Loading

0 comments on commit 9666c33

Please sign in to comment.