Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Aug 5, 2024
0 parents commit 3f6bcd2
Show file tree
Hide file tree
Showing 18 changed files with 664 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/check_links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check for empty links

on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: "00 18 * * *"

jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # v1.10.0

- name: Create Issue From File
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@24452a72d85239eacf1468b0f1982a9f3fec4c94 # v5
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated issue
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Continious integration

on:
pull_request:
branches:
- main

jobs:
tests:
name: Run tests and upload results
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.21", "1.22"]

steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

# This is currently workaround for checking if gofiles have changed,
# Because paths filter doesn't work with required checks
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c # v44
with:
files: |
cmd/**
internal/**
.golangci.yml
go.mod
go.sum
- name: Setup Go
if: steps.changed-files.outputs.any_modified == 'true'
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
go-version: ${{ matrix.go-version }}

- name: golangci-lint
if: steps.changed-files.outputs.any_modified == 'true'
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6
with:
version: latest
args: --timeout=5m

- name: Install dependencies
if: steps.changed-files.outputs.any_modified == 'true'
run: go mod download

- name: Test with Go
if: steps.changed-files.outputs.any_modified == 'true'
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...

- name: Upload coverage reports to Codecov
if: steps.changed-files.outputs.any_modified == 'true'
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: cover.txt
slug: bl4ko/netbox-ssot

vulnerabilities:
name: Check for vulnerabilities
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c # v44
with:
files: |
cmd/**
internal/**
.golangci.yml
go.mod
go.sum
.dockerignore
Dockerfile
- name: Run Trivy vulnerability scanner
if: steps.changed-files.outputs.any_modified == 'true'
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
16 changes: 16 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check for git secrets with Gitleaks
on:
pull_request:
branches:
- main
jobs:
scan:
name: gitleaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@44c470ffc35caa8b1eb3e8012ca53c2f9bea4eb5 # v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Create semantic release from commit messages
on:
push:
branches: [main]
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: "lts/*"

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx [email protected]
11 changes: 11 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check spelling with spellcheck
on:
pull_request:
branches:
- main
jobs:
spellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: streetsidesoftware/cspell-action@0e63b882c2ef0e24d78b8b1fbb132b42c0a0d0cb # v6
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# End of https://www.toptal.com/developers/gitignore/api/go
80 changes: 80 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
linters-settings:
misspell:
locale: US

issues:
max-issues-per-linter: 50
max-same-issues: 20

linters:
enable:
- revive
- gocyclo
- dupl
- errorlint
- gocognit
- cyclop
- paralleltest
- lll
- nestif
- maintidx
- exhaustive
- nilnil
- gochecknoglobals
- goerr113
- ireturn
- containedctx
- gosec
- gocritic
- asasalint
- asciicheck
- bidichk
- bodyclose
- decorder
- dogsled
- dupword
- durationcheck
- errchkjson
- errname
- execinquery
- exportloopref
- forcetypeassert
- gci
- gocheckcompilerdirectives
- gochecknoinits
- goconst
- godot
- goheader
- goimports
- gomnd
- gomoddirectives
- goprintffuncname
- gosmopolitan
- grouper
- importas
- interfacebloat
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilerr
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- rowserrcheck
- sqlclosecheck
- tagalign
- tenv
- thelper
- tparallel
- unconvert
- unparam
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: check-json
- id: check-xml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: pretty-format-json
args: ["--autofix"]
- id: check-case-conflict

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: golangci-lint
- id: go-unit-tests
- id: go-mod-tidy

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

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.13.1
hooks:
- id: cspell
10 changes: 10 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 bl4ko

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.
Loading

0 comments on commit 3f6bcd2

Please sign in to comment.