Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): init checks #1

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/auto_request_review.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before submitting your
first PR.

NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/
-->

## Overview

<!--
Please provide an explanation of the PR, including the appropriate context,
background, goal, and rationale. If there is an issue with this information,
please provide a tl;dr and link the issue.

Ex: Closes #<issue number>
-->
13 changes: 13 additions & 0 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
@@ -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
66 changes: 66 additions & 0 deletions .github/workflows/housekeeping.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Housekeeping

on:
issues:
types: [opened]
pull_request_target:
types: [opened, ready_for_review]
Comment on lines +3 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly define triggering events.

The workflow is triggered by issue and pull request events. Consider adding more event types if needed to cover all relevant scenarios, such as labeled or synchronized, to ensure comprehensive automation.


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 }}
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider specifying triggering events explicitly.

Currently, the workflow is set to trigger on workflow_call, which means it's designed to be reusable and triggered by other workflows. However, if there are specific events (like push or pull request events) that should also trigger this workflow directly, they should be explicitly defined for clarity and robustness.


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
Comment on lines +18 to +25
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential issue with environment variable setting.

The comment on line 16 suggests setting the GIT_DIFF environment variable based on file changes, but there's no explicit step setting this variable. The get-diff-action on lines 18-25 checks for changes but doesn't set GIT_DIFF directly. Ensure that the environment variable is correctly set or adjust the workflow to use outputs from get-diff-action directly.

- 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
20 changes: 20 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -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 }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage.txt
proto/pb
proto/tendermint
types/pb/tendermint
.vscode/launch.json
*/**.html
*.idea
*.env
.*env
46 changes: 46 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
default: true
MD010:
code_blocks: false
MD013: false
MD024:
allow_different_nesting: true
9 changes: 9 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/^/ /'
Comment on lines +11 to +14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhance help command output.

The help target uses sed to extract comments and format them. Consider adding more descriptive comments to each target to make the output more informative. Additionally, ensure that the PROJECTNAME variable is correctly defined or replaced with PACKAGE_NAME to avoid confusion.

.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)
Comment on lines +26 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using version pinning for dependencies.

While installing go-acc using @latest is convenient, it might lead to unexpected issues if new versions introduce breaking changes. Consider pinning a specific version to ensure consistent builds.

.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
Comment on lines +37 to +47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimize linting commands.

The lint target runs multiple linters sequentially. To improve efficiency, consider parallelizing these commands or using a tool that can aggregate linting results from different linters.


## 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
Loading