diff --git a/.github/ISSUE_TEMPLATE/issue.md b/.github/ISSUE_TEMPLATE/issue.md new file mode 100644 index 0000000..43983c5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue.md @@ -0,0 +1,77 @@ +--- +name: Issue +about: A general purpose issue +title: "[REPLACE_WITH_IDENTIFIER] Provide a descriptive title" +labels: "" +assignees: "" +--- + + + +## Objective + +[ What? Describe the issue in 1-2 sentences] + +## Origin Document + +[ Why? Justify the issue in 1-2 sentences. Consider adding a link or a screenshot.] + +## Goals + + + +- Goal #1 +- Goal #2 +- ... + +## Deliverables + + + +- [ ] Deliverable #1 +- [ ] Deliverable #2 +- ... + +## Non-goals / Non-deliverables + + + +- Non-goal #1 +- Non-deliverable #2 +- ... + +## General deliverables + + + +- [ ] **Comments**: Add/update TODOs and comments alongside the source code so it is easier to follow. +- [ ] **Testing**: Add new tests (unit and/or E2E) to the test suite. +- [ ] **Makefile**: Add new targets to the Makefile to make the new functionality easier to use. +- [ ] **Documentation**: Update architectural or development READMEs; use [mermaid](https://mermaid-js.github.io/mermaid/) diagrams where appropriate. + +--- + + + +**Creator**: [GitHub handle of issue owner] +**Co-Owners**: [OPTIONAL - GitHub handle of co-owner(s)] diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..068ccab --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,41 @@ + + +## Summary + + + +## Issue + + + +- #{ISSUE_NUMBER} + +## Type of change + +Select one or more: + +- [ ] New feature, functionality or library +- [ ] Bug fix +- [ ] Code health or cleanup +- [ ] Documentation +- [ ] Other (specify) + +## Sanity Checklist + +- [ ] I have tested my changes using the available tooling +- [ ] I have commented my code +- [ ] I have performed a self-review of my own code; both comments & source code +- [ ] I create and reference any new tickets, if applicable +- [ ] I have left TODOs throughout the codebase, if applicable diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..d186ef8 --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,69 @@ +name: reviewdog + +on: + pull_request: + branches: ["main"] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +jobs: + # Makes sure that comments like TODO_IN_THIS_PR or TODO_IN_THIS_COMMIT block + # merging to main. See https://github.com/pokt-network/action-fail-on-found + check_todo_in_this: + name: Check TODO_IN_THIS_ + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pokt-network/action-fail-on-found@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: error + fail_on_error: true + pattern: TODO_IN_THIS_ + + # Prevent the use of `sed` in helper scripts. This ensures compatibility across + # Darwin and Linux systems. + check_sed: + name: Check sed + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pokt-network/action-fail-on-found@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: error + fail_on_error: true + pattern: sed -i .* + + # There are multiple ways to validate (at compile time) that a struct + # implements a certain interface. This check enforces a common practice. + check_non_standard_interface_implementations: + name: Check for non-standard interface implementation statements + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pokt-network/action-fail-on-found@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: error + fail_on_error: true + pattern: var _ .* = &.*{} + ignore: .github,.git + + # More info: https://github.com/reviewdog/action-misspell + check_misspell: + name: Check misspelling + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-misspell@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + level: warning + locale: "US" diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..d931883 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,33 @@ +name: Run tests + +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +env: + GKE_CLUSTER: protocol-us-central1 + GKE_ZONE: us-central1 + +jobs: + go-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: "0" + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22.2" + + #- name: Run golangci-lint + # run: make go_lint + + - name: Test + run: make test_all diff --git a/Makefile b/Makefile index fe180ce..dba2e3e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,70 @@ .PHONY: proto_regen ## Regenerate protobuf artifacts proto_regen: find proto -name "*.proto" -exec protoc --go_out=. --go_opt=paths=source_relative {} \; - find proto -name "*.pb.go" | sed 's/proto\///' | xargs -I {} mv proto/{} {} \ No newline at end of file + find proto -name "*.pb.go" | sed 's/proto\///' | xargs -I {} mv proto/{} {} + +.PHONY: test_all +test_all: ## Run all go tests showing detailed output only on failures + go test -count=1 -race -tags test ./... + +############### +### Linting ### +############### + +.PHONY: go_lint +go_lint: ## Run all go linters + golangci-lint run --timeout 5m --build-tags test + +############# +### TODOS ### +############# + +# How do I use TODOs? +# 1. : ; +# e.g. TODO_HACK: This is a hack, we need to fix it later +# 2. If there's a specific issue, or specific person, add that in paranthesiss +# e.g. TODO(@Olshansk): Automatically link to the Github user https://github.com/olshansk +# e.g. TODO_INVESTIGATE(#420): Automatically link this to github issue https://github.com/pokt-network/poktroll/issues/420 +# e.g. TODO_DISCUSS(@Olshansk, #420): Specific individual should tend to the action item in the specific ticket +# e.g. TODO_CLEANUP(core): This is not tied to an issue, or a person, but should only be done by the core team. +# e.g. TODO_CLEANUP: This is not tied to an issue, or a person, and can be done by the core team or external contributors. +# 3. Feel free to add additional keywords to the list above. + +# Inspired by @goldinguy_ in this post: https://goldin.io/blog/stop-using-todo ### +# TODO - General Purpose catch-all. +# TODO_COMMUNITY - A TODO that may be a candidate for outsourcing to the community. +# TODO_DECIDE - A TODO indicating we need to make a decision and document it using an ADR in the future; https://github.com/pokt-network/pocket-network-protocol/tree/main/ADRs +# TODO_TECHDEBT - Not a great implementation, but we need to fix it later. +# TODO_BLOCKER - BEFORE MAINNET. Similar to TECHDEBT, but of higher priority, urgency & risk prior to the next release +# TODO_QOL - AFTER MAINNET. Similar to TECHDEBT, but of lower priority. Doesn't deserve a GitHub Issue but will improve everyone's life. +# TODO_IMPROVE - A nice to have, but not a priority. It's okay if we never get to this. +# TODO_OPTIMIZE - An opportunity for performance improvement if/when it's necessary +# TODO_DISCUSS - Probably requires a lengthy offline discussion to understand next steps. +# TODO_INCOMPLETE - A change which was out of scope of a specific PR but needed to be documented. +# TODO_INVESTIGATE - TBD what was going on, but needed to continue moving and not get distracted. +# TODO_CLEANUP - Like TECHDEBT, but not as bad. It's okay if we never get to this. +# TODO_HACK - Like TECHDEBT, but much worse. This needs to be prioritized +# TODO_REFACTOR - Similar to TECHDEBT, but will require a substantial rewrite and change across the codebase +# TODO_CONSIDERATION - A comment that involves extra work but was thoughts / considered as part of some implementation +# TODO_CONSOLIDATE - We likely have similar implementations/types of the same thing, and we should consolidate them. +# TODO_ADDTEST / TODO_TEST - Add more tests for a specific code section +# TODO_FLAKY - Signals that the test is flaky and we are aware of it. Provide an explanation if you know why. +# TODO_DEPRECATE - Code that should be removed in the future +# TODO_RESEARCH - A non-trivial action item that requires deep research and investigation being next steps can be taken +# TODO_DOCUMENT - A comment that involves the creation of a README or other documentation +# TODO_BUG - There is a known existing bug in this code +# TODO_NB - An important note to reference later +# TODO_DISCUSS_IN_THIS_COMMIT - SHOULD NEVER BE COMMITTED TO MASTER. It is a way for the reviewer of a PR to start / reply to a discussion. +# TODO_IN_THIS_COMMIT - SHOULD NEVER BE COMMITTED TO MASTER. It is a way to start the review process while non-critical changes are still in progress + +.PHONY: todo_list +todo_list: ## List all the TODOs in the project (excludes vendor and prototype directories) + grep --exclude-dir={.git,vendor,./docusaurus} -r TODO . + +.PHONY: todo_count +todo_count: ## Print a count of all the TODOs in the project + grep --exclude-dir={.git,vendor,./docusaurus} -r TODO . | wc -l + +.PHONY: todo_this_commit +todo_this_commit: ## List all the TODOs needed to be done in this commit + grep -n --exclude-dir={.git,vendor,.vscode,.idea} --exclude={Makefile,reviewdog.yml} -r -e "TODO_IN_THIS_" \ No newline at end of file