Skip to content

Commit

Permalink
.github: add basic ci (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSevey authored Jun 26, 2023
1 parent 277ce28 commit 9d28436
Show file tree
Hide file tree
Showing 11 changed files with 467 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

set -eu -o pipefail

STAGED_GO_FILES=$(git diff --cached --name-only -- '*.go')
STAGED_MD_FILES=$(git diff --cached --name-only -- '*.md')

if [[ $STAGED_GO_FILES == "" ]] && [[ $STAGED_MD_FILES == "" ]]; then
echo "--> Found no go or markdown files, skipping linting"
elif [[ $STAGED_GO_FILES == "" ]]; then
echo "--> Found markdown files, linting"
if ! command -v markdownlint &> /dev/null ; then
echo "markdownlint is not installed of available in the PATH" >&2
echo "please check https://github.com/igorshubovych/markdownlint-cli" >&2
exit 1
fi
markdownlint --config .markdownlint.yaml '**/*.md'
else
echo "--> Found go files, running make lint"
if ! command -v golangci-lint &> /dev/null ; then
echo "golangci-lint not installed or available in the PATH" >&2
echo "please check https://github.com/golangci/golangci-lint" >&2
exit 1
fi
make lint
fi

if go mod tidy -v 2>&1 | grep -q 'updates to go.mod needed'; then
exit 1
fi

git diff --exit-code go.* &> /dev/null

if [ $? -eq 1 ]; then
echo "go.mod or go.sum differs, please re-add it to your commit"

exit 1
fi
82 changes: 82 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Bug Report
description: File a bug report to inform the community on your awesome finding!
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thank you for filling out this bug report!
- type: input
id: version
attributes:
label: Celestia Node version
description: >
use 'celestia version' or 'git rev-parse --verify HEAD' if installed
from source code
validations:
required: true
- type: markdown
attributes:
value: |
Environment
- type: input
id: os
attributes:
label: OS
description: e.g. from /etc/os-release
validations:
required: true
- type: textarea
id: tools
attributes:
label: Install tools
description: e.g. docker, makefiles, etc.
- type: textarea
id: others
attributes:
label: Others
description: >
e.g. flag options, celestia config file changes, resources
limitation(like cpu, ram limit, swap etc.)
- type: textarea
id: steps
attributes:
label: Steps to reproduce it
description: What steps have you made to reproduce it?
placeholder: Tell us what you see!
validations:
required: true
- type: textarea
id: expectation
attributes:
label: Expected result
description: What do you expect to happen as a final result?
placeholder: Let us know what is expected
validations:
required: true
- type: textarea
id: actual
attributes:
label: Actual result
description: What do you see happened instead as a final result?
placeholder: >
This is the crucial part in detecting the root cause of the issue
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: >
Please copy and paste any relevant log(max 20 lines) output. This will
be automatically formatted into code, so no need for backticks. Or paste
gists, pastebins links here
render: Shell
- type: textarea
id: misc
attributes:
label: Notes
description: Is there anything else we need to know?
placeholder: >
Maybe, you have other ways to repro or what side effects there are if
changing steps
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: true
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Feature Request
description: >
Request a new feature to inform the community on what will be beneficial for
the project!
title: "[Feature Request]: "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Thank you for taking your time and creating a new feature request!
- type: textarea
id: ideas
attributes:
label: Implementation ideas
description: What ideas do you have on how to implement this?
27 changes: 27 additions & 0 deletions .github/auto_request_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
reviewers:
defaults:
- code-owners
groups:
code-owners:
- Nashqueue
- Wondertan
- gupadhyaya
- renaynay
rollkit:
- team:rollkit
devops:
- team:DevOps
node:
- team:celestia-node
files:
"**":
- code-owners
- rollkit
- node
".github/**":
- devops
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: weekly
day: monday
time: "11:00"
open-pull-requests-limit: 10
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
day: monday
time: "11:00"
open-pull-requests-limit: 10
58 changes: 58 additions & 0 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI and Release
on:
push:
branches:
- main
# Trigger on version tags
tags:
- "v*"
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:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: celestiaorg/.github/.github/actions/[email protected]

markdown-lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: |
npm install -g [email protected]
markdownlint --config .markdownlint.yaml '**/*.md'
go-ci:
uses: ./.github/workflows/go-ci.yml

# Make a release if this is a manually trigger job, i.e. workflow_dispatch
release:
needs: [yamllint, markdown-lint, go-ci]
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/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
version-bump: ${{inputs.version}}
65 changes: 65 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Go CI

on:
workflow_call:

env:
GO_VERSION: "1.20"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.52.2

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: ${{ env.GO_VERSION }}

- run: go mod tidy

- name: check for diff
run: git diff --exit-code

test_and_coverage:
name: Tests and Coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: run tests
run: make test

- name: upload coverage
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
36 changes: 36 additions & 0 deletions .github/workflows/housekeeping.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Housekeeping

on:
pull_request_target:
types: [opened]

jobs:
auto-add-reviewer:
name: Auto add reviewer to PR
uses: celestiaorg/.github/.github/workflows/[email protected]
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 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 }}
Loading

0 comments on commit 9d28436

Please sign in to comment.