From e9493ddf15384e4d0db468e31366f1606d532c3b Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Thu, 4 Jan 2024 17:34:27 +1300 Subject: [PATCH 1/5] add ci workflows (from celestia-app) --- .github/CODEOWNERS | 11 +++++ .github/ISSUE_TEMPLATE/bug-report.yml | 49 ++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.yml | 52 ++++++++++++++++++++ .github/auto_request_review.yml | 19 +++++++ .github/dependabot.yml | 16 ++++++ .github/workflows/ci-release.yml | 31 ++++++++++++ .github/workflows/goreleaser.yml | 40 +++++++++++++++ .github/workflows/issue-label-automation.yml | 50 +++++++++++++++++++ .github/workflows/lint-pull-request.yml | 20 ++++++++ .github/workflows/lint.yml | 37 ++++++++++++++ .github/workflows/markdown-linter.yml | 35 +++++++++++++ .github/workflows/pr-review-requester.yml | 23 +++++++++ .github/workflows/project-automation.yml | 14 ++++++ .github/workflows/test.yml | 20 ++++++++ 14 files changed, 417 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml create mode 100644 .github/auto_request_review.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci-release.yml create mode 100644 .github/workflows/goreleaser.yml create mode 100644 .github/workflows/issue-label-automation.yml create mode 100644 .github/workflows/lint-pull-request.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/markdown-linter.yml create mode 100644 .github/workflows/pr-review-requester.yml create mode 100644 .github/workflows/project-automation.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..5ef1bf1 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,11 @@ +# CODEOWNERS: + +# Everything goes through the following "global owners" by default. Unless a later +# match takes precedence, the "global owners" will be requested for review when +# someone opens a PR. Note that the last matching pattern takes precedence, so +# global owners are only requested if there isn't a more specific codeowner +# specified below. For this reason, the global owners are often repeated in +# directory-level definitions. + +# global owners +* @evan-forbes @rootulp @cmwaters @Wondertan @renaynay diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000..b408133 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,49 @@ +name: Bug Report +description: Create a report to help us squash bugs! +title: "" +labels: ["bug"] + +body: + - type: markdown + attributes: + value: | + IMPORTANT: Prior to opening a bug report, check if it affects one of the + core modules and if it's eligible for a bug bounty on `SECURITY.md`. + Bugs that are not submitted through the appropriate channels won't + receive any bounty. + + - type: textarea + id: summary + attributes: + label: Summary of Bug + description: Concisely describe the issue. + validations: + required: true + + - type: textarea + id: version + attributes: + label: Version + description: git commit hash or release version + validations: + required: true + + - type: textarea + id: repro + attributes: + label: Steps to Reproduce + description: > + What commands in order should someone run to reproduce your problem? + validations: + required: true + + - type: checkboxes + id: admin + attributes: + label: For Admin Use + description: (do not edit) + options: + - label: Not duplicate issue + - label: Appropriate labels applied + - label: Appropriate contributors tagged + - label: Contributor assigned/self-assigned diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 0000000..e1ab348 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,52 @@ +name: Feature Request +description: Create a proposal to request a feature +title: "<title>" +labels: ["enhancement"] + +body: + - type: markdown + attributes: + value: | + ✰ Thanks for opening an issue! ✰ + Before smashing the submit button please fill in the template. + Word of caution: poorly thought-out proposals may be rejected without + deliberation. + + - type: textarea + id: summary + attributes: + label: Summary + description: Short, concise description of the proposed feature. + validations: + required: true + + - type: textarea + id: problem + attributes: + label: Problem Definition + description: | + Why do we need this feature? + What problems may be addressed by introducing this feature? + What benefits does the SDK stand to gain by including this feature? + Are there any disadvantages of including this feature? + validations: + required: true + + - type: textarea + id: proposal + attributes: + label: Proposal + description: Detailed description of requirements of implementation. + validations: + required: true + + - type: checkboxes + id: admin + attributes: + label: For Admin Use + description: (do not edit) + options: + - label: Not duplicate issue + - label: Appropriate labels applied + - label: Appropriate contributors tagged + - label: Contributor assigned/self-assigned diff --git a/.github/auto_request_review.yml b/.github/auto_request_review.yml new file mode 100644 index 0000000..94b3e79 --- /dev/null +++ b/.github/auto_request_review.yml @@ -0,0 +1,19 @@ +# More info at https://github.com/necojackarc/auto-request-review +reviewers: + # The default reviewers + defaults: + # Example of Github Team. Github team must have write access to repo. + # NOTE: This assigned the team itself, not members of the team. The Github + # team auto PR assignment will then turn this into individuals + - team:celestia-core + - team:celestia-node + +options: + ignore_draft: true + ignored_keywords: + - DO NOT REVIEW + enable_group_assignment: false + + # Randomly pick reviewers up to this number. + # Do not set this option if you'd like to assign all matching reviewers. + number_of_reviewers: 2 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6af849d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + labels: + - dependencies + - package-ecosystem: gomod + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + labels: + - dependencies diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml new file mode 100644 index 0000000..f4bbe29 --- /dev/null +++ b/.github/workflows/ci-release.yml @@ -0,0 +1,31 @@ +name: ci-release + +# Run this workflow on push events (i.e. PR merge) to main or release branches, +# push events for new semantic version tags, and all PRs. +on: + push: + branches: + - main + - "v[0-9]+.x" + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" + - "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" + - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" + pull_request: + +jobs: + lint: + uses: ./.github/workflows/lint.yml + + markdown-linter: + uses: ./.github/workflows/markdown-linter.yml + + test: + uses: ./.github/workflows/test.yml + + goreleaser: + uses: ./.github/workflows/goreleaser.yml + permissions: write-all + secrets: + GORELEASER_ACCESS_TOKEN: ${{ secrets.GORELEASER_ACCESS_TOKEN }} diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..4986281 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,40 @@ +name: goreleaser +on: + workflow_call: + secrets: + GORELEASER_ACCESS_TOKEN: + required: true + +env: + GO_VERSION: '1.21.1' + +jobs: + goreleaser-check: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: check + + goreleaser: + needs: goreleaser-check + runs-on: ubuntu-latest + if: | + (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) + permissions: write-all + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Create .release-env file + run: |- + echo 'GITHUB_TOKEN=${{secrets.GORELEASER_ACCESS_TOKEN}}' >> .release-env + - name: Create prebuilt binaries and attach them to the GitHub release + run: make prebuilt-binary diff --git a/.github/workflows/issue-label-automation.yml b/.github/workflows/issue-label-automation.yml new file mode 100644 index 0000000..9f0a1ab --- /dev/null +++ b/.github/workflows/issue-label-automation.yml @@ -0,0 +1,50 @@ +name: issue-label-automation +on: + pull_request_target: + types: [opened] + issues: + types: [opened] +jobs: + automate-labels: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + env: + IS_BOT: ${{ (github.actor == 'dependabot[bot]' || github.actor == 'mergify[bot]') }} + IS_HUMAN: ${{ !(github.actor == 'dependabot[bot]' || github.actor == 'mergify[bot]') }} + steps: + - name: Check if issue or PR was created by external contributor + if: env.IS_HUMAN == 'true' && github.repository_owner == 'celestiaorg' + uses: tspascoal/get-user-teams-membership@v3 + id: teamCheck + with: + username: ${{ github.actor }} + team: "celestia-core" + GITHUB_TOKEN: ${{ secrets.PAT_TEAM_CHECK }} + + # If an issue was unlabeled add `needs:triage`. + - name: Maybe label issue with `needs:triage` + if: ${{ github.event_name == 'issues' }} + uses: andymckay/labeler@master + with: + add-labels: "needs:triage" + ignore-if-labeled: true + repo-token: ${{ secrets.GITHUB_TOKEN }} + + # If an issue or PR was created by someone that isn't part of + # celestia-core, add the `external` label. + - name: Maybe label issue or PR with `external` + if: env.IS_HUMAN == 'true' && steps.teamCheck.outputs.isTeamMember == 'false' + uses: andymckay/labeler@master + with: + add-labels: "external" + repo-token: ${{ secrets.GITHUB_TOKEN }} + + # If a PR was created by dependabot or mergify add the `bot` label. + - name: Maybe label PR with `bot` + if: env.IS_BOT == 'true' + uses: andymckay/labeler@master + with: + add-labels: "bot" + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint-pull-request.yml b/.github/workflows/lint-pull-request.yml new file mode 100644 index 0000000..5544d08 --- /dev/null +++ b/.github/workflows/lint-pull-request.yml @@ -0,0 +1,20 @@ +name: lint-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/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..397dddc --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,37 @@ +name: lint +on: + workflow_call: + +env: + GO_VERSION: '1.21.1' + +jobs: + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + timeout-minutes: 8 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - 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.7.0 + with: + version: v1.55.2 + args: --timeout 10m + github-token: ${{ secrets.github_token }} + if: env.GIT_DIFF + + yamllint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: celestiaorg/.github/.github/actions/yamllint@v0.2.8 diff --git a/.github/workflows/markdown-linter.yml b/.github/workflows/markdown-linter.yml new file mode 100644 index 0000000..095e558 --- /dev/null +++ b/.github/workflows/markdown-linter.yml @@ -0,0 +1,35 @@ +name: markdown-linter +on: + workflow_call: + +jobs: + markdown-lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install markdownlint-cli + run: npm install -g markdownlint-cli@0.32.1 + shell: bash + + - name: Run markdownlint + run: markdownlint --config .markdownlint.yaml **/*.md + shell: bash + + markdown-link-check: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run markdown link check + uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 + with: + config-file: '.github/markdown-link-check-config.json' + folder-path: '.' diff --git a/.github/workflows/pr-review-requester.yml b/.github/workflows/pr-review-requester.yml new file mode 100644 index 0000000..491dd95 --- /dev/null +++ b/.github/workflows/pr-review-requester.yml @@ -0,0 +1,23 @@ +name: pr-review-requester + +on: + # pull_request_target is used to allow forks write permissions when running + # this workflow. With the pull_request trigger, forks do not have any write + # access for security reasons, however write access is needed in order to + # request reviews. Since this workflow is simply requesting reviewers, it is + # safe to allow forks write access. + pull_request_target: + +jobs: + auto-request-review: + name: Auto request reviews + uses: celestiaorg/.github/.github/workflows/reusable_housekeeping.yml@v0.2.8 # yamllint disable-line rule:line-length + secrets: inherit + # write access for issues and pull requests is needed because the called + # workflow requires write access to issues and pull requests and the + # permissions must match + permissions: + issues: write + pull-requests: write + with: + run-auto-request-review: true diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml new file mode 100644 index 0000000..4f438eb --- /dev/null +++ b/.github/workflows/project-automation.yml @@ -0,0 +1,14 @@ +name: project-automation +on: + issues: + types: + - opened +jobs: + add-to-project: + name: Add new issues to the core/app project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@main + with: + project-url: https://github.com/orgs/celestiaorg/projects/24 + github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..636d50f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: test +on: + workflow_call: + +env: + GO_VERSION: '1.21.1' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Run tests + run: go test ./... -v -timeout 5m -race + From 99f2d90ff8b4c6414b09b0d36f85d39a782235f1 Mon Sep 17 00:00:00 2001 From: Callum Waters <cmwaters19@gmail.com> Date: Thu, 4 Jan 2024 17:37:45 +1300 Subject: [PATCH 2/5] use celestia-core and celestia-node as code owners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5ef1bf1..2cebf99 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -8,4 +8,4 @@ # directory-level definitions. # global owners -* @evan-forbes @rootulp @cmwaters @Wondertan @renaynay +* @celestiaorg/celestia-core @celestiaorg/celestia-node From 4e0eca0d22e59c57d215a811144c41fe24652479 Mon Sep 17 00:00:00 2001 From: Callum Waters <cmwaters19@gmail.com> Date: Thu, 4 Jan 2024 17:44:04 +1300 Subject: [PATCH 3/5] add appropriate config files --- .golangci.yml | 18 ++++++++++++++++++ .markdownlint.yaml | 5 +++++ .yamllint.yml | 9 +++++++++ 3 files changed, 32 insertions(+) create mode 100644 .golangci.yml create mode 100644 .markdownlint.yaml create mode 100644 .yamllint.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..5d53602 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,18 @@ +run: + timeout: 5m + modules-download-mode: readonly + +linters: + enable: + - exportloopref + - gofumpt + - misspell + - nakedret + - revive + - prealloc + - stylecheck + +linters-settings: + nakedret: + # Ban the use of naked returns because they reduce code readability. + max-func-lines: 0 # override the default: 30 diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..0a57674 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,5 @@ +"default": true # Default state for all rules +"MD010": + "code_blocks": false # Disable rule for hard tabs in code blocks +"MD013": false # Disable rule for line length +"MD033": false # Disable rule banning inline HTML 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 From 55a9a010da4c8301466b060cb898197d0eed5281 Mon Sep 17 00:00:00 2001 From: Callum Waters <cmwaters19@gmail.com> Date: Thu, 4 Jan 2024 17:55:37 +1300 Subject: [PATCH 4/5] fix yaml lints --- .github/auto_request_review.yml | 2 +- .github/workflows/markdown-linter.yml | 12 ------------ .github/workflows/test.yml | 1 - merkle/proto/buf.gen.yaml | 2 +- proto/buf.gen.yaml | 2 +- 5 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/auto_request_review.yml b/.github/auto_request_review.yml index 94b3e79..f2cff5c 100644 --- a/.github/auto_request_review.yml +++ b/.github/auto_request_review.yml @@ -5,7 +5,7 @@ reviewers: # Example of Github Team. Github team must have write access to repo. # NOTE: This assigned the team itself, not members of the team. The Github # team auto PR assignment will then turn this into individuals - - team:celestia-core + - team:celestia-core - team:celestia-node options: diff --git a/.github/workflows/markdown-linter.yml b/.github/workflows/markdown-linter.yml index 095e558..e9bae07 100644 --- a/.github/workflows/markdown-linter.yml +++ b/.github/workflows/markdown-linter.yml @@ -21,15 +21,3 @@ jobs: - name: Run markdownlint run: markdownlint --config .markdownlint.yaml **/*.md shell: bash - - markdown-link-check: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Run markdown link check - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 - with: - config-file: '.github/markdown-link-check-config.json' - folder-path: '.' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 636d50f..6bb10b8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,4 +17,3 @@ jobs: - name: Run tests run: go test ./... -v -timeout 5m -race - diff --git a/merkle/proto/buf.gen.yaml b/merkle/proto/buf.gen.yaml index d887b47..55de0af 100644 --- a/merkle/proto/buf.gen.yaml +++ b/merkle/proto/buf.gen.yaml @@ -3,4 +3,4 @@ plugins: - plugin: buf.build/protocolbuffers/go out: gen opt: - - paths=source_relative \ No newline at end of file + - paths=source_relative diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml index 0fec481..7e4cca4 100644 --- a/proto/buf.gen.yaml +++ b/proto/buf.gen.yaml @@ -3,4 +3,4 @@ plugins: - plugin: buf.build/protocolbuffers/go out: ../pkg/blob opt: - - paths=source_relative \ No newline at end of file + - paths=source_relative From 83a86f15331b6ba2e453d899063ba6cb17e83dd0 Mon Sep 17 00:00:00 2001 From: Callum Waters <cmwaters19@gmail.com> Date: Fri, 5 Jan 2024 11:00:52 +1300 Subject: [PATCH 5/5] remove goreleaser --- .github/workflows/ci-release.yml | 6 ----- .github/workflows/goreleaser.yml | 40 -------------------------------- 2 files changed, 46 deletions(-) delete mode 100644 .github/workflows/goreleaser.yml diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index f4bbe29..e217755 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -23,9 +23,3 @@ jobs: test: uses: ./.github/workflows/test.yml - - goreleaser: - uses: ./.github/workflows/goreleaser.yml - permissions: write-all - secrets: - GORELEASER_ACCESS_TOKEN: ${{ secrets.GORELEASER_ACCESS_TOKEN }} diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml deleted file mode 100644 index 4986281..0000000 --- a/.github/workflows/goreleaser.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: goreleaser -on: - workflow_call: - secrets: - GORELEASER_ACCESS_TOKEN: - required: true - -env: - GO_VERSION: '1.21.1' - -jobs: - goreleaser-check: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - uses: goreleaser/goreleaser-action@v5 - with: - version: latest - args: check - - goreleaser: - needs: goreleaser-check - runs-on: ubuntu-latest - if: | - (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) - permissions: write-all - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - run: git fetch --force --tags - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - name: Create .release-env file - run: |- - echo 'GITHUB_TOKEN=${{secrets.GORELEASER_ACCESS_TOKEN}}' >> .release-env - - name: Create prebuilt binaries and attach them to the GitHub release - run: make prebuilt-binary