-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: Add commit/PR body linter for epic and issue refs
Before: Commits and PRs would inconsistently contain references to issues. Sometimes the author would forget to add it. Some authors might not think to add them. And there were no epic references provided. Why: Adding issue and epic references to PRs and commits provides traceability and context for the revenue teams, product, management and engineers. Now: A new GitHub Action workflow checks for references to issues the PR closes or informs and epics the PR is part of. It looks for references in the PR body and in commit messages and, if it doesn't find what it expects, it fails the check. Release note: None Release justification: Adding linter for epic tracking for engineering, docs, and internal teams.
- Loading branch information
Nick Vigilante
committed
Oct 4, 2022
1 parent
4780ee1
commit a7ef46a
Showing
8 changed files
with
961 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Epic + Issue Ref Linter for PR Body or Commit Messages | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize, edited] | ||
|
||
jobs: | ||
linter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Bazel cache | ||
id: bazel-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/bazel | ||
key: ${{ runner.os }}-bazel-cache | ||
|
||
- name: Install bazelisk | ||
run: | | ||
curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-linux-amd64 > /tmp/bazelisk | ||
sha256sum -c - <<EOF | ||
4cb534c52cdd47a6223d4596d530e7c9c785438ab3b0a49ff347e991c210b2cd /tmp/bazelisk | ||
EOF | ||
mkdir -p "${GITHUB_WORKSPACE}/bin/" | ||
mv /tmp/bazelisk "${GITHUB_WORKSPACE}/bin/bazel" | ||
chmod +x "${GITHUB_WORKSPACE}/bin/bazel" | ||
- name: Run lint | ||
run: build/github/pr-epic-issue-ref-lint.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
PR_NUMBER="$(echo "$GITHUB_REF" | awk -F '/' '{print $3}')" | ||
|
||
GITHUB_TOKEN="${GITHUB_TOKEN}" bin/bazel run //pkg/cmd/lint-epic-issue-refs:lint-epic-issue-refs "$PR_NUMBER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "lint-epic-issue-refs_lib", | ||
srcs = [ | ||
"lint_epic_issue_refs.go", | ||
"main.go", | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/lint-epic-issue-refs", | ||
visibility = ["//visibility:private"], | ||
deps = [ | ||
"@com_github_google_go_github//github", | ||
"@com_github_spf13_cobra//:cobra", | ||
"@org_golang_x_oauth2//:oauth2", | ||
], | ||
) | ||
|
||
go_binary( | ||
name = "lint-epic-issue-refs", | ||
embed = [":lint-epic-issue-refs_lib"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_test( | ||
name = "lint-epic-issue-refs_test", | ||
srcs = ["lint_epic_issue_refs_test.go"], | ||
args = ["-test.timeout=295s"], | ||
embed = [":lint-epic-issue-refs_lib"], | ||
deps = ["@com_github_stretchr_testify//assert"], | ||
) | ||
|
||
get_x_data(name = "get_x_data") |
Oops, something went wrong.