Skip to content

Commit

Permalink
Add workflows and linters (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Jan 31, 2024
1 parent fe33e67 commit d02cd58
Show file tree
Hide file tree
Showing 11 changed files with 352 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = tab

[*.{md,yml,yaml}]
indent_size = 2
indent_style = space
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily

- package-ecosystem: gomod
directory: /
schedule:
interval: daily
28 changes: 28 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
change:
- head-branch: ["^change/"]

enhancement:
- head-branch: ["^feature/", "^feat/", "^enhancement/", "^enh/"]

bug:
- head-branch: ["^fix/", "^bug/"]

chore:
- head-branch: ["^chore/"]

tech-debt:
- head-branch: ["^tech-debt/", "^techdebt/", "^debt/"]

documentation:
- head-branch: ["^docs/", "^doc/"]
- changed-files:
- any-glob-to-any-file: "**/*.md"

dependencies:
- head-branch:
["^deps/", "^dep/", "^dependabot/", "pre-commit-ci-update-config"]
- changed-files:
- any-glob-to-any-file: ["go.mod", "go.sum"]

tests:
- head-branch: ["^tests/", "^test/"]
20 changes: 20 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Dependency Review"
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
steps:
- name: "Checkout Repository"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: "Dependency Review"
uses: actions/dependency-review-action@4901385134134e04cec5fbe5ddfe3b2c5bd5d976 # v4.0.0
with:
config-file: "nginxinc/k8s-common/dependency-review-config.yml@main"
18 changes: 18 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Pull Request Labeler"
on:
- pull_request_target

permissions:
contents: read

jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-22.04
steps:
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
68 changes: 68 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Lint

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.ref_name }}-lint
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Golang Environment
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable

- name: Lint Code
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
args: --timeout 10m0s

actionlint:
name: Actionlint
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: reviewdog/action-actionlint@6a38513dd4d2e818798c5c73d0870adbb82de4a4 # v1.41.0
with:
actionlint_flags: -shellcheck ""

markdown-lint:
name: Markdown Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: DavidAnson/markdownlint-cli2-action@510b996878fc0d1a46c8a04ec86b06dbfba09de7 # v15.0.0
with:
config: ${{ github.workspace }}/.markdownlint-cli2.yaml
globs: "**/*.md"

yaml-lint:
name: Yaml Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install yamllint
run: pip install yamllint

- name: Lint YAML files
run: yamllint .
68 changes: 68 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
linters-settings:
misspell:
locale: US
revive:
ignore-generated-header: true
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming
gocyclo:
min-complexity: 15
govet:
enable:
- fieldalignment
lll:
line-length: 120
linters:
enable:
- asciicheck
- errcheck
- errorlint
- gocyclo
- gofmt
- gofumpt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- lll
- makezero
- misspell
- nilerr
- noctx
- predeclared
- revive
- staticcheck
- typecheck
- unconvert
- unparam
- unused
- wastedassign
disable-all: true
issues:
max-issues-per-linter: 0
max-same-issues: 0
run:
timeout: 3m
20 changes: 20 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Rule configuration.
# For rule descriptions and how to fix: https://github.com/DavidAnson/markdownlint/tree/main#rules--aliases
config:
ul-style:
style: dash
no-hard-tabs: false
no-multiple-blanks: false
line-length: false
blanks-around-headers: false
no-duplicate-heading:
siblings_only: true
no-inline-html: false
no-bare-urls: false
no-emphasis-as-heading: false
first-line-h1: false
code-block-style: false

# Define glob expressions to ignore
ignores:
- ".github/"
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: (^tests/results/)
- id: end-of-file-fixer
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-added-large-files
- id: check-merge-conflict
- id: check-case-conflict
- id: check-vcs-permalinks
- id: check-json
- id: pretty-format-json
args: [--autofix, --no-sort-keys, --no-ensure-ascii]
- id: mixed-line-ending
args: [--fix=lf]
- id: no-commit-to-branch
- id: detect-private-key
exclude: (^examples/|^docs/|.*_test.go$)

- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.1
hooks:
- id: gitleaks

- repo: local
hooks:
- id: golang-diff
name: create-go-diff
entry: bash -c 'git diff -p origin/main > /tmp/diff.patch'
language: system
types: [go]
pass_filenames: false

- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: golangci-lint
args: [--new-from-patch=/tmp/diff.patch]

# Rules are in .markdownlint-cli2.yaml file
# See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md for rule descriptions
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.12.1
hooks:
- id: markdownlint-cli2

# Rules are in .yamllint.yaml file
# See https://yamllint.readthedocs.io/en/stable/rules.html# for rule descriptions
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
hooks:
- id: yamllint

ci:
skip: [golang-diff, golangci-lint, markdownlint-cli2, yamllint]
45 changes: 45 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
yaml-files:
- "*.yaml"
- "*.yml"

ignore:
- .github/workflows/

rules:
braces: enable
brackets: enable
colons: enable
commas: enable
comments:
require-starting-space: true
ignore-shebangs: true
min-spaces-from-content: 1
comments-indentation: enable
document-end: disable
document-start: disable
empty-lines: enable
empty-values: enable
float-values: disable
hyphens: enable
indentation:
spaces: consistent
indent-sequences: consistent
check-multi-line-strings: true
key-duplicates: enable
key-ordering: disable
line-length:
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
ignore: |
.github/workflows/
.goreleaser.yml
new-line-at-end-of-file: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy:
ignore: |
.github/workflows/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# telemetry-exporter
# telemetry-exporter

0 comments on commit d02cd58

Please sign in to comment.