Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Initialize repository with basic files (#8)
Browse files Browse the repository at this point in the history
This PR adds
* `go.mod` files
* a Changelog file for both inputs and developers
* PR template (copied from Beats)
* golangci-lint configuration and GH action
* `.go-version` file
  • Loading branch information
kvch authored May 25, 2022
1 parent 0645dcc commit e432800
Show file tree
Hide file tree
Showing 6 changed files with 354 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!-- Type of change
Please label this PR with one of the following labels, depending on the scope of your change:
- Bug
- Enhancement
- Breaking change
- Deprecation
- Cleanup
- Docs
-->

## What does this PR do?

<!-- Mandatory
Explain here the changes you made on the PR. Please explain the WHAT: patterns used, algorithms implemented, design architecture, message processing, etc.
-->

## Why is it important?

<!-- Mandatory
Explain here the WHY, or the rationale/motivation for the changes.
-->

## Checklist

<!-- Mandatory
Add a checklist of things that are required to be reviewed in order to have the PR approved
List here all the items you have verified BEFORE sending this PR. Please DO NOT remove any item, striking through those that do not apply. (Just in case, strikethrough uses two tildes. ~~Scratch this.~~)
-->

- [ ] My code follows the style guidelines of this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have made corresponding change to the default configuration files
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added an entry in `CHANGELOG.md` or `CHANGELOG-developer.md`.

## Author's Checklist

<!-- Recommended
Add a checklist of things that are required to be reviewed in order to have the PR approved
-->
- [ ]

## How to test this PR locally

<!-- Recommended
Explain here how this PR will be tested by the reviewer: commands, dependencies, steps, etc.
-->

## Related issues

<!-- Recommended
Link related issues below. Insert the issue link or reference after the word "Closes" if merging this should automatically close it.
- Closes #123
- Relates #123
- Requires #123
- Superseds #123
-->
-

## Use cases

<!-- Recommended
Explain here the different behaviors that this PR introduces or modifies in this project, user roles, environment configuration, etc.
If you are familiar with Gherkin test scenarios, we recommend its usage: https://cucumber.io/docs/gherkin/reference/
-->

## Screenshots

<!-- Optional
Add here screenshots about how the project will be changed after the PR is applied. They could be related to web pages, terminal, etc, or any other image you consider important to be shared with the team.
-->

## Logs

<!-- Recommended
Paste here output logs discovered while creating this PR, such as stack traces or integration logs, or any other output you consider important to be shared with the team.
-->
61 changes: 61 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: golangci-lint
on:
#push:
# branches:
# - main
# - 8.*
# - 7.17
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
jobs:
golangci:
strategy:
matrix:
include:
- GOOS: windows
- GOOS: linux
- GOOS: darwin
name: lint
runs-on: ubuntu-latest
steps:
- name: Echo details
env:
GOOS: ${{ matrix.GOOS }}
run: echo Go GOOS=$GOOS

- uses: actions/checkout@v2

# Uses Go version from the repository.
- name: Read .go-version file
id: goversion
run: echo "::set-output name=version::$(cat .go-version)"

- uses: actions/setup-go@v2
with:
go-version: "${{ steps.goversion.outputs.version }}"

- name: golangci-lint
env:
GOOS: ${{ matrix.GOOS }}
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.44.2

# Give the job more time to execute.
# Regarding `--whole-files`, the linter is supposed to support linting of changed a patch only but,
# for some reason, it's very unreliable this way - sometimes it does not report any or some
# issues without linting the whole files, so we have to use `--whole-files`
# which can lead to some frustration from developers who would like to
# fix a single line in an existing codebase and the linter would force them
# into fixing all linting issues in the whole file instead.
args: --timeout=30m --whole-files

# Optional: if set to true then the action will use pre-installed Go.
skip-go-installation: true

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true
175 changes: 175 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# DO NOT EDIT!
# This file is a rendered template, the source can be found in "./dev-tools/templates/.golangci.yml"
#
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 1m

issues:
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 0
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter: 0

output:
sort-results: true

# Uncomment and add a path if needed to exclude
# skip-dirs:
# - some/path
# skip-files:
# - ".*\\.my\\.go$"
# - lib/bad.go

# Find the whole list here https://golangci-lint.run/usage/linters/
linters:
disable-all: true
enable:
- deadcode # finds unused code
- errcheck # checking for unchecked errors in go programs
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- goconst # finds repeated strings that could be replaced by a constant
- dupl # tool for code clone detection
- forbidigo # forbids identifiers matched by reg exps
- gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
- gosimple # linter for Go source code that specializes in simplifying a code
- misspell # finds commonly misspelled English words in comments
- nakedret # finds naked returns in functions greater than a specified function length
- prealloc # finds slice declarations that could potentially be preallocated
- nolintlint # reports ill-formed or insufficient nolint directives
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- stylecheck # a replacement for golint
- unparam # reports unused function parameters
- unused # checks Go code for unused constants, variables, functions and types

- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # detects when assignments to existing variables are not used
- structcheck # finds unused struct fields
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- varcheck # Finds unused global variables and constants
- asciicheck # simple linter to check that your code does not contain non-ASCII identifiers
- bodyclose # checks whether HTTP response body is closed successfully
- durationcheck # check for two durations multiplied together
- exportloopref # checks for pointers to enclosing loop variables
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
- gosec # inspects source code for security problems
- importas # enforces consistent import aliases
- nilerr # finds the code that returns nil even if it checks that the error is not nil.
- noctx # noctx finds sending http request without context.Context
- unconvert # Remove unnecessary type conversions
- wastedassign # wastedassign finds wasted assignment statements.
- godox # tool for detection of FIXME, TODO and other comment keywords
- gomodguard # check for blocked dependencies

# all available settings of specific linters
linters-settings:
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: true

errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
errorf: true
# Check for plain type assertions and type switches
asserts: true
# Check for plain error comparisons
comparison: true

goconst:
# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 2

dupl:
# tokens count to trigger issue, 150 by default
threshold: 100

forbidigo:
# Forbid the following identifiers
forbid:
- fmt.Print.* # too much log noise
# Exclude godoc examples from forbidigo checks. Default is true.
exclude_godoc_examples: true

gomoddirectives:
# Allow local `replace` directives. Default is false.
replace-local: false

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.17.6"

misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
# locale: US
# ignore-words:
# - IdP

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 0

prealloc:
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# True by default.
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: false # Report preallocation suggestions on for loops, false by default

nolintlint:
# Enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: true
# Exclude following linters from requiring an explanation. Default is [].
allow-no-explanation: []
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
require-specific: true

gomodguard:
blocked:
# List of blocked modules.
modules:
# Blocked module.
- github.com/pkg/errors:
# Recommended modules that should be used instead. (Optional)
recommendations:
- errors
- fmt
reason: "This package is deprecated"
- github.com/elastic/beats/v7:
reason: "There must be no Beats dependency"

staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.17.6"
# https://staticcheck.io/docs/options#checks
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.17.6"
# https://staticcheck.io/docs/options#checks
checks: ["all"]

unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false

unused:
# Select the Go version to target. The default is '1.13'.
go: "1.17.6"
17 changes: 17 additions & 0 deletions CHANGELOG-developer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

### Changed

### Deprecated

### Removed

### Fixed

[Unreleased]: https://github.com/elastic/elastic-agent-system-metrics/compare/v0.0.0...HEAD
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

### Changed

### Deprecated

### Removed

### Fixed

[Unreleased]: https://github.com/elastic/elastic-agent-system-metrics/compare/v0.0.0...HEAD
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/elastic/elastic-agent-inputs

go 1.17

0 comments on commit e432800

Please sign in to comment.