From 005a24ace090a92a04575391c1dcaaa1cbd44274 Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:49:20 -0400 Subject: [PATCH] feat(ci): init checks --- .github/auto_request_review.yml | 15 +++++ .github/dependabot.yml | 16 +++++ .github/pull_request_template.md | 18 ++++++ .github/workflows/ci_release.yml | 13 ++++ .github/workflows/housekeeping.yml | 66 +++++++++++++++++++++ .github/workflows/lint.yml | 43 ++++++++++++++ .github/workflows/semantic-pull-request.yml | 20 +++++++ .gitignore | 9 +++ .golangci.yml | 46 ++++++++++++++ .markdownlint.yaml | 6 ++ .yamllint.yml | 9 +++ Makefile | 61 +++++++++++++++++++ 12 files changed, 322 insertions(+) create mode 100644 .github/auto_request_review.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/ci_release.yml create mode 100644 .github/workflows/housekeeping.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/semantic-pull-request.yml create mode 100644 .gitignore create mode 100644 .golangci.yml create mode 100644 .markdownlint.yaml create mode 100644 .yamllint.yml create mode 100644 Makefile diff --git a/.github/auto_request_review.yml b/.github/auto_request_review.yml new file mode 100644 index 0000000..bc48a57 --- /dev/null +++ b/.github/auto_request_review.yml @@ -0,0 +1,15 @@ +reviewers: + defaults: + - rollkit + groups: + rollkit: + - team:core +files: + ".github/**": + - MSevey + - rollkit +options: + ignore_draft: true + ignored_keywords: + - WIP + number_of_reviewers: 3 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d87d034 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + labels: + - T:dependencies + - package-ecosystem: gomod + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + labels: + - T:dependencies diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..0c1cad9 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,18 @@ + + +## Overview + + diff --git a/.github/workflows/ci_release.yml b/.github/workflows/ci_release.yml new file mode 100644 index 0000000..43b7e9d --- /dev/null +++ b/.github/workflows/ci_release.yml @@ -0,0 +1,13 @@ +name: CI and Release +on: + push: + branches: + - main + # Trigger on version tags + tags: + - "v*" + pull_request: + +jobs: + lint: + uses: ./.github/workflows/lint.yml diff --git a/.github/workflows/housekeeping.yml b/.github/workflows/housekeeping.yml new file mode 100644 index 0000000..16d3904 --- /dev/null +++ b/.github/workflows/housekeeping.yml @@ -0,0 +1,66 @@ +name: Housekeeping + +on: + issues: + types: [opened] + pull_request_target: + types: [opened, ready_for_review] + +jobs: + issue-management: + if: ${{ github.event.issue }} + name: Add issues to project and add triage label + uses: rollkit/.github/.github/workflows/reusable_housekeeping.yml@v0.4.1 + secrets: inherit + permissions: + issues: write + pull-requests: write + with: + run-labels: true + labels-to-add: "needs-triage" + run-projects: true + project-url: https://github.com/orgs/rollkit/projects/7 + + add-pr-to-project: + # ignore dependabot PRs + if: ${{ github.event.pull_request && github.actor != 'dependabot[bot]' }} + name: Add PRs to project + uses: rollkit/.github/.github/workflows/reusable_housekeeping.yml@v0.4.1 + secrets: inherit + permissions: + issues: write + pull-requests: write + with: + run-projects: true + project-url: https://github.com/orgs/rollkit/projects/7 + + auto-add-reviewer: + name: Auto add reviewer to PR + if: github.event.pull_request + uses: rollkit/.github/.github/workflows/reusable_housekeeping.yml@v0.4.1 + secrets: inherit + permissions: + issues: write + pull-requests: write + with: + run-auto-request-review: true + + auto-add-assignee: + # ignore dependabot PRs + if: ${{ github.event.pull_request && github.actor != 'dependabot[bot]' }} + name: Assign issue and PR to creator + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: Set pull_request url and creator login + # yamllint disable rule:line-length + run: | + echo "PR=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV + echo "CREATOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV + # yamllint enable rule:line-length + - name: Assign PR to creator + run: gh pr edit ${{ env.PR }} --add-assignee ${{ env.CREATOR }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..6258f3c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,43 @@ +# lint runs all linters in this repository +# This workflow is triggered by ci_release.yml workflow +name: lint +on: + workflow_call: + +jobs: + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: ./go.mod + # This steps sets the GIT_DIFF environment variable to true + # if files defined in PATTERS changed + - uses: technote-space/get-diff-action@v6.1.2 + with: + # This job will pass without running if go.mod, go.sum, and *.go + # wasn't modified. + PATTERNS: | + **/**.go + go.mod + go.sum + - uses: golangci/golangci-lint-action@v6.0.1 + with: + version: latest + args: --timeout 10m + github-token: ${{ secrets.github_token }} + if: env.GIT_DIFF + + yamllint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: rollkit/.github/.github/actions/yamllint@v0.4.1 + + markdown-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: rollkit/.github/.github/actions/markdown-lint@v0.4.1 diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml new file mode 100644 index 0000000..e11fe30 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yml @@ -0,0 +1,20 @@ +name: Semantic Pull Request + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: conventional-commit-pr-title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..baed0d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +coverage.txt +proto/pb +proto/tendermint +types/pb/tendermint +.vscode/launch.json +*/**.html +*.idea +*.env +.*env diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..6017061 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,46 @@ +run: + timeout: 5m + modules-download-mode: readonly + +linters: + enable: + - errorlint + - errcheck + - gofmt + - goimports + - gosec + - gosimple + - govet + - ineffassign + - misspell + - revive + - staticcheck + - typecheck + - unconvert + - unused + +issues: + exclude-use-default: false + # mempool and indexer code is borrowed from Tendermint + exclude-dirs: + - mempool + - state/indexer + - state/txindex + - third_party + include: + - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments + - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments + +linters-settings: + revive: + rules: + - name: package-comments + disabled: true + - name: duplicated-imports + severity: warning + - name: exported + arguments: + - disableStutteringCheck + + goimports: + local-prefixes: github.com/rollkit diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..6369b8d --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,6 @@ +default: true +MD010: + code_blocks: false +MD013: false +MD024: + allow_different_nesting: true diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..cd2a9e8 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,9 @@ +--- +# Built from docs https://yamllint.readthedocs.io/en/stable/configuration.html +extends: default + +rules: + # 120 chars should be enough, but don't fail if a line is longer + line-length: + max: 120 + level: warning diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9e37b99 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +PACKAGE_NAME := github.com/rollkit/astria-sequencer +GOLANG_CROSS_VERSION ?= v1.22.1 + +# Define pkgs, run, and cover variables for test so that we can override them in +# the terminal more easily. + +pkgs := $(shell go list ./...) +run := . +count := 1 + +## help: Show this help message +help: Makefile + @echo " Choose a command run in "$(PROJECTNAME)":" + @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' +.PHONY: help + +## clean: clean testcache +clean: + @echo "--> Clearing testcache" + @go clean --testcache +.PHONY: clean + +## cover: generate to code coverage report. +cover: + @echo "--> Generating Code Coverage" + @go install github.com/ory/go-acc@latest + @go-acc -o coverage.txt $(pkgs) +.PHONY: cover + +## deps: Install dependencies +deps: + @echo "--> Installing dependencies" + @go mod download + @go mod tidy +.PHONY: deps + +## lint: Run linters golangci-lint and markdownlint. +lint: vet + @echo "--> Running golangci-lint" + @golangci-lint run + @echo "--> Running markdownlint" + @markdownlint --config .markdownlint.yaml '**/*.md' + @echo "--> Running yamllint" + @yamllint --no-warnings . -c .yamllint.yml + @echo "--> Running actionlint" + @actionlint +.PHONY: lint + +## fmt: Run fixes for linters. +fmt: + @echo "--> Formatting markdownlint" + @markdownlint --config .markdownlint.yaml --ignore './cmd/rollkit/docs/*.md' '**/*.md' -f + @echo "--> Formatting go" + @golangci-lint run --fix +.PHONY: fmt + +## vet: Run go vet +vet: + @echo "--> Running go vet" + @go vet $(pkgs) +.PHONY: vet