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: add ci checks such as commit lint, pull request title lint #429

Merged
Show file tree
Hide file tree
Changes from all 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
41 changes: 41 additions & 0 deletions .github/workflows/constraint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Reference from:
# https://github.com/c-bata/go-prompt/blob/master/.github/workflows/test.yml
name: Constraints
on:
pull_request:
types: [opened, edited, synchronize, reopened]
jobs:
# Lints Pull Request commits with commitlint.
#
# Rules can be referenced:
# https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
CommitLint:
name: Commit Lint
runs-on: ubuntu-latest
if: contains(fromJSON('["pull_request"]'), github.event_name)
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5

# Lints Pull Request title, because the title will be used as the
# commit message in branch main.
#
# Configuration detail can be referenced:
# https://github.com/marketplace/actions/pull-request-title-rules
PullRequestTitleLint:
name: Pull Request Title Lint
runs-on: ubuntu-latest
if: contains(fromJSON('["pull_request"]'), github.event_name)
steps:
- uses: deepakputhraya/action-pr-title@master
with:
allowed_prefixes: 'build,chore,ci,docs,feat,fix,perf,refactor,revert,style,test' # title should start with the given prefix
disallowed_prefixes: 'WIP,[WIP]' # title should not start with the given prefix
prefix_case_sensitive: false # title prefix are case insensitive
min_length: 5 # Min length of the title
max_length: 80 # Max length of the title
github_token: ${{ github.token }} # Default: ${{ github.token }}

8 changes: 5 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ jobs:
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
Lint:
name: Lint checks

GolangLint:
name: Golang Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go 1.19
Expand All @@ -50,3 +51,4 @@ jobs:
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.52.2

4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ linters:
linters-settings:
gofumpt:
# Select the Go version to target. The default is `1.15`.
lang-version: "1.16"
lang-version: "1.19"
# Choose whether or not to use the extra rules that are disabled
# by default
extra-rules: false
Expand All @@ -60,4 +60,4 @@ issues:
- "ifElseChain: rewrite if-else to switch statement"
- "S1000: should use for range instead of for { select {} }"
- "SA4004: the surrounding loop is unconditionally terminated"
- "copylocks: call of c\\.Post copies lock value: kcl-lang\\.io/kcl-go/pkg/spec/gpyrpc\\.Ping_Args contains google\\.golang\\.org/protobuf/internal/impl\\.MessageState contains sync\\.Mutex"
- "copylocks: call of c\\.Post copies lock value: kcl-lang\\.io/kcl-go/pkg/spec/gpyrpc\\.Ping_Args contains google\\.golang\\.org/protobuf/internal/impl\\.MessageState contains sync\\.Mutex"
21 changes: 21 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright The Karbour Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// This file is the configuration file of [commitlint](https://commitlint.js.org/#/).
//
// Rules can be referenced:
// https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
module.exports = {extends: ['@commitlint/config-conventional']}
Loading