From 782ede3f4c1567a5b739c501ea270bc7db79ee31 Mon Sep 17 00:00:00 2001 From: Justin Tieri <37750742+jtieri@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:03:59 -0500 Subject: [PATCH] ci: add new CI jobs and bring existing ones into compliance --- .codespellrc | 1 - .github/workflows/chores.yml | 35 ------------ .github/workflows/codeql-analysis.yml | 61 ++++++++++++++++++++ .github/workflows/lint.yml | 51 +++++++---------- .github/workflows/markdown-link-check.yml | 11 ++++ .github/workflows/spell-check.yml | 24 ++++++++ .github/workflows/title-format.yml | 20 +++++++ .golangci.yml | 70 +++++++++++++++++++++++ .goreleaser.yaml | 70 +++++++++++++++++++++++ 9 files changed, 278 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/chores.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/markdown-link-check.yml create mode 100644 .github/workflows/spell-check.yml create mode 100644 .github/workflows/title-format.yml create mode 100644 .golangci.yml create mode 100644 .goreleaser.yaml diff --git a/.codespellrc b/.codespellrc index e393c29a7..41681e1d0 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,4 @@ [codespell] skip = *.pulsar.go,*.pb.go,*.pb.gw.go,*.json,*.git,*.bin,*.sum,*.mod,query_test.go ignore-words-list = usera,pres,crate -count = quiet-level = 3 \ No newline at end of file diff --git a/.github/workflows/chores.yml b/.github/workflows/chores.yml deleted file mode 100644 index 83c577016..000000000 --- a/.github/workflows/chores.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: chores - -on: - pull_request: - -jobs: - link-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 - - typos: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run codespell - continue-on-error: true - run: | - # .codespellrc is used - sudo apt-get install codespell -y - codespell -w --config .codespellrc - exit $? - - pr-title-format: - name: Lint PR Title - permissions: - pull-requests: read - statuses: write - contents: read - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..bd9acccf4 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,61 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '59 23 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages. + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # ✏️ If the Autobuild fails above, remove it and uncomment the following lines + # and modify them (or add more) to build your code. + + #- run: | + # make install + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2a4ca6a4b..90e1aa5a1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,41 +1,34 @@ -name: golangci-lint +# Lint the entire golang project. This workflow relies on the +# '.golangci.yml' file for its configuration settings. +name: Lint on: + push: + tags: + - v* + branches: + - master + - main pull_request: +permissions: + contents: read + +env: + GO_VERSION: 1.22 + jobs: golangci: - name: lint + name: golangci-lint runs-on: ubuntu-latest steps: - uses: actions/setup-go@v5 with: - go-version: '1.21' - cache: false + go-version: ${{ env.GO_VERSION }} + - uses: actions/checkout@v4 + - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.54 - only-new-issues: true - args: --timeout=10m - - clippy-lint: - defaults: - run: - working-directory: local-interchain/rust/localic-std - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install stable with clippy and rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: rustfmt, clippy - - name: Install clippy - run: rustup component add clippy - - name: Update - run: cargo update - - name: Run clippy - run: make lint - + version: v1.57.2 + args: --timeout 15m \ No newline at end of file diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml new file mode 100644 index 000000000..3daf692b8 --- /dev/null +++ b/.github/workflows/markdown-link-check.yml @@ -0,0 +1,11 @@ +name: Markdown Link Check + +on: + pull_request: + +jobs: + link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 \ No newline at end of file diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 000000000..96ef19cc4 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,24 @@ +name: Spell Check + +on: + pull_request: + +jobs: + spellcheck: + name: Run codespell + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install codespell + run: pip install codespell + + - name: Run codespell + run: codespell \ No newline at end of file diff --git a/.github/workflows/title-format.yml b/.github/workflows/title-format.yml new file mode 100644 index 000000000..b5e7d1a95 --- /dev/null +++ b/.github/workflows/title-format.yml @@ -0,0 +1,20 @@ +name: "Lint PR Title" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..56ef8d787 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,70 @@ +run: + timeout: 10m + tests: true + +# These linter checks can be modified on a per project basis. +# Simply remove them from the enable list to disable them. +linters: + disable-all: true + enable: + - asciicheck + - bidichk + - bodyclose + - decorder + - dupl + - dupword + - errcheck + - errchkjson + - errname + - exhaustive + - exportloopref + - forbidigo + - gci + - goconst + - gocritic + - godot + - gofumpt + - gosec + - gosimple + - gosmopolitan + - govet + - grouper + - ineffassign + - loggercheck + - misspell + - nilerr + - nilnil + - noctx + - staticcheck + - stylecheck + - testifylint + - thelper + - tparallel + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + - wastedassign + - whitespace + +linters-settings: + gci: + custom-order: true + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - blank # blank imports + - dot # dot imports + - prefix(cosmossdk.io) + - prefix(github.com/cosmos) + - prefix(github.com/cosmos/cosmos-sdk) + - prefix(github.com/cometbft/cometbft) + # TODO: Replace below with '- prefix()' + - prefix(github.com/strangelove-ventures/oss-repo-template) + gosec: + excludes: + - G404 # disables checks on insecure random number source + +issues: + max-issues-per-linter: 0 \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..72a0c6c7c --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,70 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 1 + +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm + - arm64 + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + use: github + sort: asc + groups: + - title: Features + regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + order: 0 + - title: "Bug fixes" + regexp: '^.*?(bug|fix)(\([[:word:]]+\))??!?:.+$' + order: 1 + - title: Others + order: 999 + +checksum: + name_template: SHA256SUMS-{{.Version}}.txt + algorithm: sha256 + +release: + prerelease: auto + draft: true + +announce: + slack: + enabled: true + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + channel: '#release-announce' + username: 'SL Release Bot' + icon_emoji: 'strangelove' \ No newline at end of file