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

ci: various improvements #196

Merged
merged 9 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
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
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
labels: needs-triage
---

14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--

Please add a reference to the issue that this PR addresses and indicate which
files are most critical to review. If it fully addresses a particular issue,
please include "Closes #XXX" (where "XXX" is the issue number).

-->

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog)
17 changes: 13 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "11:00"
interval: weekly
target-branch: "main"
open-pull-requests-limit: 10
labels:
- dependencies
- automerge

###################################
##
## Update All Go Dependencies

- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
time: "11:00"
interval: weekly
target-branch: "main"
open-pull-requests-limit: 10
labels:
- dependencies
- automerge
9 changes: 9 additions & 0 deletions .github/linters/yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# Default rules for YAML linting from super-linter.
# See: See https://yamllint.readthedocs.io/en/stable/rules.html
extends: default
rules:
document-end: disable
document-start: disable
line-length: disable
truthy: disable
25 changes: 25 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pull_request_rules:
- name: automatic approval for Dependabot pull requests
conditions:
- author=dependabot[bot]
actions:
review:
type: APPROVE
message: Automatically approving dependabot

- name: automatically merge PR with automerge label
conditions:
- '-label=manual-backport'
- label=automerge
actions:
merge:
method: squash

- name: Make sure PR are up to date before merging
description: >-
This automatically updates PRs when they are out-of-date with the base
branch to avoid semantic conflicts (next step is using a merge queue).
conditions:
- '-draft'
actions:
update:
37 changes: 37 additions & 0 deletions .github/workflows/ci-fast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test fast (no changes to Dockerfile)

on:
pull_request:
paths-ignore:
- "tools/**"
merge_group:
push:
branches:
- main
paths-ignore:
- "tools/**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
test-fast:
runs-on: ubuntu-latest
container: cometbft/cometbft-db-testing
steps:
- uses: actions/checkout@v4

- run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV

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

- name: test & coverage report creation
run: |
NON_INTERACTIVE=1 make test-all-with-coverage

- uses: codecov/codecov-action@v4
with:
file: ./coverage.txt
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
# make docker-test

name: Test

on:
pull_request:
paths:
- tools/Dockerfile
merge_group:
push:
branches:
- main
merge_group:
pull_request:
jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
paths:
- tools/Dockerfile

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
Test:
runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
name: "CodeQL"

on:
workflow_dispatch:
workflow_dispatch: # allow running workflow manually
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
merge_group:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
analyze:
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/conventional-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "Conventional PR Title"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: write

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
build
chore
ci
docs
refactor
perf
test
revert
spec
merge

- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.

Details:

```
${{ steps.lint_pr_title.outputs.error_message }}
```

General format: `type(scope): msg`
Breaking change: `type(scope)!: msg`
Multi-scope change: `type: msg`
Types: `feat`, `fix`, `build`, `chore`, `ci`, `docs`, `refactor`, `perf`, `test`, `revert`, `spec`, `merge`.
Example: `fix(cmd/cometbft/commands/debug): execute p.Signal only when p is not nil`

# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
28 changes: 5 additions & 23 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

name: Docker testing image
on:
workflow_dispatch:
workflow_dispatch: # allow running workflow manually
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" # e.g. v0.37.0-alpha.1, v0.38.0-alpha.10
Expand All @@ -26,24 +24,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=cometbft/cometbft-db-testing
VERSION=noop
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=latest
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT

- name: Set up Docker Build
uses: docker/[email protected]
Expand All @@ -60,5 +40,7 @@ jobs:
context: ./tools
file: ./tools/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
push: true
tags: |
cometbft/cometbft-db-testing:latest
cometbft/cometbft-db-testing:${{ github.ref_name }}
12 changes: 6 additions & 6 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ name: Check for Go vulnerabilities
# Run `make vulncheck` from the root of the repo to run this workflow locally.
on:
pull_request:
merge_group:
push:
branches:
- main
- release/**
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
govulncheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Load Go version
run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV
- run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV

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

- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Lint

on:
pull_request:
merge_group:
push:
branches:
- main
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
golangci:
Expand All @@ -15,8 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Load Go version
run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV
- run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV

- uses: actions/setup-go@v5
with:
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/markdown-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Markdown Linter
on:
push:
branches:
- main
paths:
- "**.md"
- "**.yml"
- "**.yaml"
pull_request:
branches: [main]
paths:
- "**.md"
- "**.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
build:
name: Super linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Lint Code Base
uses: docker://github/super-linter:v4
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_MD: true
VALIDATE_OPENAPI: true
VALIDATE_YAML: true
YAML_CONFIG_FILE: yaml-lint.yml
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
days-before-close: -1
days-before-pr-stale: 10
days-before-pr-close: 4
exempt-pr-labels: "pinned, security, proposal, blocked, wip"
exempt-pr-labels: "wip"
Loading