Skip to content

Commit

Permalink
Automation things: codecov, linting, github, circleci, etc. (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
winder committed Mar 9, 2023
1 parent 2061b2c commit f5c2701
Show file tree
Hide file tree
Showing 27 changed files with 498 additions and 121 deletions.
51 changes: 51 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: 2.1

orbs:
go: circleci/go@1.7.0
codecov: codecov/codecov@3.1.1

parameters:
ubuntu_image:
type: string
default: "ubuntu-2004:202107-02"

workflows:
version: 2
build_and_test:
jobs:
- test

jobs:
test:
machine:
image: << pipeline.parameters.ubuntu_image >>
steps:
- go/install:
version: "1.17.9"
- build_conduit
- install_linter
- run_tests
- codecov/upload

commands:
build_conduit:
description: build project
steps:
- checkout
- run: make

install_linter:
description: Install golangci-lint
steps:
- run:
name: Install golangci-lint
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.3

run_tests:
steps:
- run: test -z `go fmt ./...`
- run: make lint
- run: make check
- run:
command: make test
no_output_timeout: 15m
16 changes: 16 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
codecov:
require_ci_to_pass: no
branch: develop

ignore:

coverage:
precision: 2
round: down
range: "70...100"
status:
patch:
default:
target: auto
threshold: 0%
project: off
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: "\U0001F41C Bug report"
about: Report a reproducible bug.
title: ''
labels: ''
assignees: ''

---

### Subject of the issue

<!-- Describe your issue here. -->

### Your environment

<!--
* Software version.
* Pipeline configuration.
* Operating System details.
-->

### Steps to reproduce

1.
2.

### Expected behaviour

### Actual behaviour
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: "\U0001F514 Feature Request"
about: Suggestions for how we can improve the algorand platform.
title: ''
labels: ''
assignees: ''
---

## Problem

<!-- What is the problem that we’re trying to solve? -->

## Solution

<!-- Do you have a potential/suggested solution? Document more than one if possible. -->

## Dependencies

<!-- Does the solution have any team or design dependencies? -->

## Urgency

<!-- What is the urgency here and why? -->
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
Thanks for submitting a pull request! We appreciate the time and effort you spent to get this far.
If you haven't already, please make sure that you've reviewed the CONTRIBUTING guide:
https://github.com/algorand/go-algorand/blob/master/CONTRIBUTING.md#code-guidelines
-->

## Summary

Explain the goal of this change and what problem it is solving. Format this cleanly so that it may be used for a commit message, as your changes will be squash-merged.

## Test Plan

How did you test these changes? Please provide the exact scenarios you tested in as much detail as possible including commands, output and rationale.
20 changes: 20 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
changelog:
exclude:
labels:
- Skip-Release-Notes
categories:
- title: Bugfixes
labels:
- Bug-Fix
- title: New Features
labels:
- New Feature
- title: Enhancements
labels:
- Enhancement
- title: Not Yet Enabled
labels:
- Not-Yet-Enabled
- title: Other
labels:
- "*"
24 changes: 24 additions & 0 deletions .github/workflows/pr-type-category.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check PR category and type
on:
pull_request:
branches:
- develop
types: [opened, synchronize, reopened, labeled, unlabeled, edited]
jobs:
check_label:
runs-on: ubuntu-latest
name: Check PR Category and Type
steps:
- name: Checking for correct number of required github pr labels
uses: mheap/github-action-required-labels@v2
with:
mode: exactly
count: 1
labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes"

- name: "Checking for PR Category in PR title. Should be like '<category>: <pr title>'."
run: |
if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then
echo "## PR Category is missing from PR title. Please add it like '<category>: <pr title>'." >> GITHUB_STEP_SUMMARY
exit 1
fi
25 changes: 25 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "ReviewDog workflow"
on:
pull_request:
jobs:
# Blocking Errors Section
reviewdog-errors:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0 # required for new-from-rev option in .golangci.yml
- name: Install specific golang
uses: actions/setup-go@v2
with:
go-version: '1.17.13'
- name: reviewdog-golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
golangci_lint_version: "v1.47.3"
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
reporter: "github-pr-review"
tool_name: "Lint Errors"
level: "error"
fail_on_error: true
55 changes: 55 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Build artifacts
cmd/conduit/conduit
tmp/
conduit-docs/

# 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

# Output of fixtures_test.go
_*.json

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

# emacs
*~

# Python
__pycache__
e2e_tests/dist
e2e_tests/build
e2e_tests/*egg-info*
.venv

# jetbrains IDE
.idea

# VS Code
.vscode

.deb_tmp
.tar_tmp
*.deb
*.tar.bz2

coverage.txt

# mac OS
.DS_store

# asdf
.tool-versions

# conduit example
cmd/conduit/data
53 changes: 53 additions & 0 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
run:
timeout: 5m
tests: true

linters:
disable-all: true
enable:
- staticcheck
- structcheck
- typecheck
- varcheck
- deadcode
- gosimple
- unused

severity:
default-severity: warning

issues:
# Disable default exclude rules listed in `golangci-lint run --help` (selectively re-enable some below)
exclude-use-default: false

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

exclude:
# ignore govet false positive fixed in https://github.com/golang/go/issues/45043
- "sigchanyzer: misuse of unbuffered os.Signal channel as argument to signal.Notify"
# ignore golint false positive fixed in https://github.com/golang/lint/pull/487
- "exported method (.*).Unwrap` should have comment or be unexported"
# ignore issues about the way we use _struct fields to define encoding settings
- "`_struct` is unused"

# Enable some golangci-lint default exception rules:
# "EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok"
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# "EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore"
- ineffective break statement. Did you mean to break out of the outer loop

exclude-rules:
# be more lenient with test code
- path: _test\.go
linters:
- staticcheck
- structcheck
- typecheck
- varcheck
- deadcode
- gosimple
- unused
59 changes: 59 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
run:
timeout: 5m
tests: false

linters:
disable-all: true
enable:
- deadcode
- errcheck
- gci
- gofmt
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- structcheck
- typecheck
- unused
- varcheck

linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/algorand)
- prefix(github.com/algorand/conduit)

section-separators:
- newLine

severity:
default-severity: error

issues:
# Disable default exclude rules listed in `golangci-lint run --help` (selectively re-enable some below)
exclude-use-default: false

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

exclude:
# ignore govet false positive fixed in https://github.com/golang/go/issues/45043
- "sigchanyzer: misuse of unbuffered os.Signal channel as argument to signal.Notify"
# ignore golint false positive fixed in https://github.com/golang/lint/pull/487
- "exported method (.*).Unwrap` should have comment or be unexported"
# ignore issues about the way we use _struct fields to define encoding settings
- "`_struct` is unused"

# Enable some golangci-lint default exception rules:
# "EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok"
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# "EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore"
- ineffective break statement. Did you mean to break out of the outer loop
Loading

0 comments on commit f5c2701

Please sign in to comment.