diff --git a/.github/auto_request_review.yml b/.github/auto_request_review.yml new file mode 100644 index 0000000..a31206d --- /dev/null +++ b/.github/auto_request_review.yml @@ -0,0 +1,32 @@ +reviewers: + defaults: + - code-owners + groups: + code-owners: + - Nashqueue + - tzdybal + - gupadhyaya + rollkit: + - Manav-Aggarwal + - S1nus + - tuxcanfly + devops: + - smuu + - sysrex + - jrmanes + - Bidon15 + celestia: + - team:celestia +files: + '**': + - code-owners + - rollkit + '**/*Dockerfile': + - devops + '.github/**': + - devops +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..14c2668 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,23 @@ +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 + - package-ecosystem: docker + directory: "/docker" + schedule: + interval: weekly + open-pull-requests-limit: 10 + labels: + - T:dependencies diff --git a/.github/workflows/ci_release.yml b/.github/workflows/ci_release.yml new file mode 100644 index 0000000..3b362ae --- /dev/null +++ b/.github/workflows/ci_release.yml @@ -0,0 +1,48 @@ +name: CI and Release +on: + push: + branches: + - main + # Trigger on version tags + tags: + - 'v[0-9]+\.[0-9]+\.[0-9]+' + - 'v[0-9]+\.[0-9]+\.[0-9]+-rc(?:[0-9]+|\.[0-9]+)' + pull_request: + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + version: + # Friendly description to be shown in the UI instead of 'name' + description: "Semver type of new version (major / minor / patch)" + # Input has to be provided for the workflow to run + required: true + type: choice + options: + - patch + - minor + - major + +jobs: + lint: + uses: ./.github/workflows/lint.yml + with: + GO_VERSION: "1.20" + + test: + uses: ./.github/workflows/test.yml + with: + GO_VERSION: "1.20" + + # Make a release if this is a manually trigger job, i.e. workflow_dispatch + release: + needs: [lint, test] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' }} + permissions: "write-all" + steps: + - uses: actions/checkout@v3 + - name: Version Release + uses: celestiaorg/.github/.github/actions/version-release@v0.1.1 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + version-bump: ${{inputs.version}} diff --git a/.github/workflows/housekeeping.yml b/.github/workflows/housekeeping.yml new file mode 100644 index 0000000..fd789a6 --- /dev/null +++ b/.github/workflows/housekeeping.yml @@ -0,0 +1,75 @@ +name: Housekeeping + +on: + issues: + types: [opened] + pull_request_target: + types: [opened] + +jobs: + project: + # ignore dependabot PRs + if: ${{ github.actor != 'dependabot[bot]' }} + name: Add issues and PRs to project and add grooming label + uses: celestiaorg/.github/.github/workflows/reusable_housekeeping.yml@v0.1.1 + secrets: inherit + permissions: + issues: write + pull-requests: write + with: + run-labels: true + labels-to-add: "needs-grooming" + 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: celestiaorg/.github/.github/workflows/reusable_housekeeping.yml@v0.1.1 + secrets: inherit + permissions: + issues: write + pull-requests: write + with: + run-auto-request-review: true + + auto-add-assignee: + # ignore dependabot PRs + if: ${{ github.actor != 'dependabot[bot]' }} + name: Assign issue and PR to creator + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: Set issue url and creator login + if: ${{ github.event.issue }} + run: | + echo "ISSUE=${{ github.event.issue.html_url }}" >> $GITHUB_ENV + echo "CREATOR=${{ github.event.issue.user.login }}" >> $GITHUB_ENV + - name: Set pull_request url and creator login + if: ${{ github.event.pull_request }} + # 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 issue to creator (issue) + if: ${{ github.event.issue }} + run: gh issue edit ${{ env.ISSUE }} --add-assignee ${{ env.CREATOR }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Assign issue to creator (PR) + if: ${{ github.event.pull_request }} + run: gh pr edit ${{ env.PR }} --add-assignee ${{ env.CREATOR }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + required-labels: + runs-on: ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v4 + with: + mode: minimum + count: 1 + labels: "T:enhancement, T:documentation, T:code-hygiene, T:bug, T:adr, T:sdk, T:testing, T:question, T:dependencies, T:spec-and-docs, T:da-integration, T:dev-usability-and-ux" # yamllint disable-line rule:line-length diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..9396949 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,48 @@ +# lint runs all linters in this repository +# This workflow is triggered by ci_release.yml workflow +name: lint +on: + workflow_call: + inputs: + GO_VERSION: + description: "Go version to use" + type: string + required: true + +jobs: + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: ${{ inputs.GO_VERSION }} + # 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@v3.4.0 + with: + version: latest + args: --timeout 10m + github-token: ${{ secrets.github_token }} + if: env.GIT_DIFF + + yamllint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: celestiaorg/.github/.github/actions/yamllint@v0.1.1 + + markdown-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: celestiaorg/.github/.github/actions/markdown-lint@v0.1.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..385bacd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,74 @@ +# Tests / Code Coverage workflow +# This workflow is triggered by ci_release.yml workflow +name: Tests / Code Coverage +on: + workflow_call: + inputs: + GO_VERSION: + description: 'Go version to use' + type: string + required: true + +jobs: + go_mod_tidy_check: + name: Go Mod Tidy Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: ${{ inputs.GO_VERSION }} + - run: go mod tidy + - name: check for diff + run: git diff --exit-code + + test_coverage: + name: Unit Tests Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up go + uses: actions/setup-go@v4 + with: + go-version: ${{ inputs.GO_VERSION }} + - name: Test & Coverage + run: make cover + - uses: codecov/codecov-action@v3.1.4 + with: + file: ./coverage.txt + + unit_test: + name: Run Unit Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up go + uses: actions/setup-go@v4 + with: + go-version: ${{ inputs.GO_VERSION }} + - name: execute test run + run: make test-unit + + unit_race_test: + name: Run Unit Tests with Race Detector + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up go + uses: actions/setup-go@v4 + with: + go-version: ${{ inputs.GO_VERSION }} + - name: execute test run + run: make test-unit-race + + integration_test: + name: Run Integration Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up go + uses: actions/setup-go@v4 + with: + go-version: ${{ inputs.GO_VERSION }} + - name: Integration Tests + run: echo "No integration tests yet" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c57100a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +coverage.txt diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..2fe26b1 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,37 @@ +run: + timeout: 5m + modules-download-mode: readonly + # mempool and indexer code is borrowed from Tendermint + skip-dirs: + - mempool + - state/indexer + - state/txindex + +linters: + enable: + - deadcode + - errcheck + - gofmt + - goimports + - gosec + - gosimple + - govet + - ineffassign + - misspell + - revive + - staticcheck + - structcheck + - typecheck + - unused + - varcheck + +issues: + exclude-use-default: false + +linters-settings: + revive: + rules: + - name: package-comments + disabled: true + 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..95e3b97 --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +DOCKER := $(shell which docker) + +## 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 `go list ./...` +.PHONY: cover + +## lint: Run linters golangci-lint and markdownlint. +lint: + @echo "--> Running golangci-lint" + @golangci-lint run + @echo "--> Running markdownlint" + @markdownlint --config .markdownlint.yaml '**/*.md' + @echo "--> Running yamllint" + @yamllint --no-warnings . -c .yamllint.yml + +.PHONY: lint + +## test-unit: Running unit tests +test-unit: + @echo "--> Running unit tests" + @go test `go list ./...` +.PHONY: test-unit + +## test-unit-race: Running unit tests with data race detector +test-unit-race: + @echo "--> Running unit tests with data race detector" + @go test -race -count=1 `go list ./...` +.PHONY: test-unit-race + +### test-all: Run tests with and without data race +test-all: + @$(MAKE) test-unit + @$(MAKE) test-unit-race +.PHONY: test-all