Skip to content

Commit

Permalink
initial infra (#1)
Browse files Browse the repository at this point in the history
* Initial Infrastructure for go-datatrails-merklelog

---------

Co-authored-by: jgough <[email protected]>
  • Loading branch information
honourfish and jgough committed May 14, 2024
1 parent 4683f9d commit 7de2d45
Show file tree
Hide file tree
Showing 17 changed files with 700 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Quality Control

on: [
pull_request,
workflow_dispatch
]

jobs:
build:
name: Quality Control
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false

- name: Install Go quality tools
run: |
go install golang.org/x/tools/cmd/[email protected]
go install github.com/axw/gocov/[email protected]
go install github.com/jstemmer/go-junit-report/[email protected]
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Code quality checks
run: |
# Note: it is by design that we don't use the builder
task format
task lint
- name: Unit tests
run: |
# Note: it is by design that we don't use the builder
task test:unit
- name: Integration tests
run: |
task test:integration
- name: Azurite logs
run: |
task azurite:logs
- name: Stop azurite
if: always()
run: |
task azurite:stop
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.local
**/test_results
203 changes: 203 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
linters-settings:
funlen:
lines: 350
statements: 135
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
dupl:
threshold: 100
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors.
# See the https://github.com/polyfloyd/go-errorlint for caveats.
# Default: true
errorf: false
# Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true)
# Default: true
errorf-multi: true
# Check for plain type assertions and type switches.
# Default: true
asserts: true
# Check for plain error comparisons.
# Default: true
comparison: true
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
# Check switch statements in generated files also.
# Default: false
check-generated: true
# Presence of "default" case in switch statements satisfies exhaustiveness,
# even if all enum members are not listed.
# Default: false
default-signifies-exhaustive: true
# Enum members matching the supplied regex do not have to be listed in
# switch statements to satisfy exhaustiveness.
# Default: ""
ignore-enum-members: "Example.+"
# Enum types matching the supplied regex do not have to be listed in
# switch statements to satisfy exhaustiveness.
# Default: ""
ignore-enum-types: "Example.+"
# Consider enums only in package scopes, not in inner scopes.
# Default: false
package-scope-only: true
# Only run exhaustive check on switches with "//exhaustive:enforce" comment.
# Default: false
explicit-exhaustive-switch: false
# Only run exhaustive check on map literals with "//exhaustive:enforce" comment.
# Default: false
explicit-exhaustive-map: false
gci:
local-prefixes: github.com/datatrails/go-datatrails-merklelog
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- performance
- style
- experimental
disabled-checks:
- wrapperFunc
gocognit:
min-complexity: 75
gocyclo:
min-complexity: 10
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
govet:
check-shadowing: true
settings:
printf:
funcs:
- Infof
- Warnf
- Errorf
- Fatalf
lll:
line-length: 500
maligned:
suggest-new: true
misspell:
locale: UK

# depguard (control upstream repos) not needed
# dupl - see ticket #3095
# funlen - it is to anoying for test code and this sort of subjective judgement is what PR reviews are for
# exhaustive - see ticket #3096
# gci - disabled as confusing and not really useful
# gochecknoglobals - not really useful
# goconst - see ticket #3097
# goerr113 - disabled see https://github.com/Djarvur/go-err113/issues/10
# gofumpt - not useful - confusing messages
# gomnd - see ticket #3116
# govet - see ticket #3117
# nilreturn onwardis not yet evaluated...
# maligned - this guards against performance issues due to accessing
# mis-aligned structs. We don't have direct evidence of this being a
# real problem for us. We use a lot of generated code in our hot
# paths anyway (we have no control over there layout). Until we get
# direct evidence this is hurting us, we prefer our stucts layed out
# logically and don't want to have to nolint tag everything.
#
# misspell - expected UK spelling with misspell, but customer facing text needs to be US.
# tagalign - suppress until we can get a golang code formatter that will fix this (cosmetic)
#
# WARN: typecheck cannot be disabled as golang-ci uses it internally to detect uncompilable code.
# Unfortunately the src/azb2c package triggers this erroneously so we add it to skip-dirs below.
#
linters:
enable-all: true
disable:
- containedctx
- contextcheck
- cyclop
- deadcode
- depguard
- dupl
- dupword
- durationcheck
- errchkjson
- errname
- exhaustivestruct
- exhaustruct
- forbidigo
- forcetypeassert
# DONT re-enable funlen please
- funlen
- gci
- gochecknoglobals
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofumpt
- golint
- gomoddirectives
- gomnd
- gosec
- gosimple
- ifshort
- inamedparam
- interfacer
- interfacebloat
- ireturn
- maligned
- maintidx
- misspell
- musttag
- nilerr
- nilnil
- nlreturn
- noctx
- nestif
- nolintlint
- nonamedreturns
- nosnakecase
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- protogetter
- revive
- rowserrcheck
- scopelint
- structcheck
- stylecheck
- tagalign
- tagliatelle
- tenv
- testifylint
- testpackage
- thelper
- tparallel
- unparam
- unused
- usestdlibvars
- varcheck
- varnamelen
- wastedassign
- whitespace
- wsl
- wrapcheck

run:
build-tags:
- golangcilint

issues:
exclude-rules:
- text: "weak cryptographic primitive"
linters:
- gosec
40 changes: 40 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
DataTrails observes the [CNCF Community Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md), reproduced below for emphasis.

### Contributor Code of Conduct

As contributors and maintainers of this project, and in the interest of fostering
an open and welcoming community, we pledge to respect all people who contribute
through reporting issues, posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for
everyone, regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing others' private information, such as physical or electronic addresses,
without explicit permission
* Other unethical or unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are not
aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers
commit themselves to fairly and consistently applying these principles to every aspect
of managing this project. Project maintainers who do not follow or enforce the Code of
Conduct may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a DataTrails administrator on <[email protected]>.

This Code of Conduct is adapted from the Contributor Covenant
(http://contributor-covenant.org), version 1.2.0, available at
http://contributor-covenant.org/version/1/2/0/

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# go-datatrails-merklelog
# go-datatrails-merklelog

## Overview

golang module for datatrails merklelog implementation.
68 changes: 68 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
version: '3'

# This Taskfile represents the primary control surface for developers interacting with
# this component.
#
# Primary "configure/build/deploy/test" tasks must be provided directly in this top level
# taskfile
#
# Infrequently used or pure sub-tasks should be in subservient taskfiles and included
# here.
#
# All tasks that are expected to be run directly by developers must have a meaningful
# 'desc' with all optional variables defined, in this file or in included files.
#
# All tasks that are internal sub-tasks only should have a meaningful 'summary'.
#
includes:
codequality:
taskfile: ./taskfiles/Taskfile_codequality.yml
dir: ./taskfiles
azurite:
taskfile: ./taskfiles/Taskfile_azurite.yml
dir: ./taskfiles
gobuild:
taskfile: ./taskfiles/Taskfile_gobuild.yml
dir: ./taskfiles
gotest:
taskfile: ./taskfiles/Taskfile_gotest.yml
dir: ./taskfiles

tasks:

build:fast:
desc: ensure go build works for all modules
cmds:
- task: gobuild:go:build

build:clean:
desc: ensure go build works for all modules
cmds:
- task: gobuild:go:build

format:
desc: formats the code correctly
cmds:
- task: codequality:format

lint:
desc: lints the go code
cmds:
- task: codequality:lint

go:modules:
desc: tidies the go modules
cmds:
- task: codequality:modules

test:unit:
desc: run the unit tests
cmds:
- task: gotest:go:unit

test:integration:
desc: run the azurite integration tests
cmds:
- task: azurite:preflight
- task: gotest:go:azurite
5 changes: 5 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go 1.22

use ./mmr

use ./massifs
3 changes: 3 additions & 0 deletions massifs/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/datatrails/go-datatrails-merklelog/massifs

go 1.22
Loading

0 comments on commit 7de2d45

Please sign in to comment.