Skip to content

Commit

Permalink
chore: setup repo (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Oct 15, 2024
1 parent 92af49c commit eb33fd7
Show file tree
Hide file tree
Showing 33 changed files with 4,129 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
75 changes: 75 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Nefilim Continuous Integration

on:
push:

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.23
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.60.3
args: --verbose

test:
strategy:
matrix:
go-version: [1.23]
platform: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.platform }}

env:
COVER_DIR: ${{ github.workspace }}/coverage
COVER_FILE: coverage.out
COVER_OUT_PATH: ${{ github.workspace }}/coverage/coverage.out
COVER_HTML_PATH: ${{ github.workspace }}/coverage/coverage.html
GINKGO_REPORT: ginkgo.report

steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install goveralls
run: go install github.com/mattn/goveralls@latest

- name: Install ginkgo
run: go install github.com/onsi/ginkgo/v2/[email protected]

- name: Checkout code
uses: actions/checkout@v4

- name: Ensure coverage directory exists
run: |
mkdir -p ${{ github.workspace }}/coverage
- name: Run tests and generate coverage profile with Ginkgo
run: |
ginkgo run -r -json-report {{env.GINKGO_REPORT}} -coverpkg=./... -coverprofile=coverage.out
- name: Apply coverage exclusions
run: |
${{ github.workspace }}/scripts/apply-coverage-exclusions.sh
- name: Check coverage directory contents
run: |
echo "Contents of ${{ github.workspace }}/coverage:"
ls -la ${{ github.workspace }}/coverage
- name: Generate HTML coverage report
run: |
go tool cover -html=coverage.out -o ${{ github.workspace }}/coverage/coverage.html
- name: Upload coverage to Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
35 changes: 35 additions & 0 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Nefilim Release

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Git Fetch
run: git fetch --force --tags
- name: Setup
uses: actions/setup-go@v3
with:
go-version: '>=1.23'
cache: true
- name: Generate Changelog Only
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 13 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# 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~
Expand All @@ -13,13 +10,21 @@

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

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

# Go workspace file
go.work
go.work.sum
coverage
coverage.out
ginkgo.report
report.json
coverage.html

# env file
.env
.task/
test/json/marshal/
test/scratch/

.DS_Store
thumbs.db
.tmp
72 changes: 72 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
linters-settings:
errcheck:
check-type-assertions: true
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
shadow: true
disable:
- fieldalignment # too strict

nolintlint:
require-explanation: false
require-specific: true
linters:
disable-all: true
enable:
- bodyclose
# - deadcode
# depguard needs to be reviewed properly and then configured, before
# it can be re-enabled.
# https://github.com/OpenPeeDeeP/depguard#example-configs
# - depguard
- copyloopvar
- dogsled
# - dupl
- errcheck
- exhaustive
- goconst
- gocritic
- gofmt
- goimports
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- misspell
- mnd
- nolintlint
- nakedret
- prealloc
- predeclared
- revive
- staticcheck
# - structcheck
- stylecheck
- thelper
- tparallel
- unconvert
- unparam
# - varcheck
- whitespace
- wsl

issues:
max-issues-per-linter: 0
max-same-issues: 0
fix: true
exclude:
- "cuddle"

run:
issues-exit-code: 1
timeout: "5m"
51 changes: 51 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
before:
hooks:
- go mod tidy
# ? do we need a - go mod generate
# - go mod generate

builds:
- id: "traverse"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
no_main_check: true
skip: true

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
use: github
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
groups:
- title: "🚀 Features"
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: "🐛 Bug fixes"
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: "🥝 Others"
order: 999
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.56.2
hooks:
- id: golangci-lint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
args: ["--branch", "master", "--branch", "main"]
Loading

0 comments on commit eb33fd7

Please sign in to comment.