Skip to content

Commit 21d20ed

Browse files
feat(raycilint): add GitHub Action workflow for PR size checks
Adds a GitHub Actions workflow that runs rayci-lint prsize on pull requests and posts a sticky comment when thresholds are exceeded. The job fails unless the PR has a configurable skip label (default: skip-prcheck). Topic: prcheck-action Relative: prcheck-binary Signed-off-by: andrew <andrew@anyscale.com>
1 parent 3583125 commit 21d20ed

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

.buildkite/raycilint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ go_filelength:
22
max_lines: 500
33
go_coverage:
44
min_coverage_pct: 80
5+
prsize:
6+
max_additions: 500
7+
max_deletions: 2000

.github/workflows/prcheck.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: PR Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled, unlabeled]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
env:
11+
CONFIG_PATH: ".buildkite/raycilint.yaml"
12+
SKIP_LABEL: "skip-prcheck" # If updating this label, also update harcoded ref below.
13+
14+
jobs:
15+
check:
16+
name: PR size check
17+
# Skip all label-related events unless the skip-prcheck label was toggled.
18+
# env context is unavailable in job-level if, so the label name must be hardcoded.
19+
if: >-
20+
(github.event.action != 'labeled' && github.event.action != 'unlabeled')
21+
|| github.event.label.name == 'skip-prcheck'
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 5
24+
steps:
25+
- name: Check for skip label
26+
id: check
27+
if: ${{ !contains(github.event.pull_request.labels.*.name, env.SKIP_LABEL) }}
28+
run: echo "run=true" >> "$GITHUB_OUTPUT"
29+
30+
- uses: actions/checkout@v4
31+
if: steps.check.outputs.run
32+
with:
33+
fetch-depth: 1
34+
persist-credentials: false
35+
36+
- uses: actions/setup-go@v5
37+
if: steps.check.outputs.run
38+
with:
39+
go-version-file: go.mod
40+
41+
- name: Run prcheck
42+
id: prcheck
43+
if: steps.check.outputs.run
44+
env:
45+
BASE_REF: ${{ github.event.pull_request.base.ref }}
46+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
47+
run: >-
48+
go run ./raycilint/raycilint -config-file "$CONFIG_PATH" prsize
49+
-base-ref "$BASE_REF"
50+
-head-ref "$HEAD_REF"
51+
52+
- name: Update size warning comment
53+
if: failure()
54+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
55+
with:
56+
header: prcheck
57+
message: |
58+
## ⚠️ PR Size Warning
59+
This PR exceeds the size limits defined in `${{ env.CONFIG_PATH }}`.
60+
${{ steps.prcheck.outputs.additions && format('- additions: `{0}`', steps.prcheck.outputs.additions) || '' }}
61+
${{ steps.prcheck.outputs.deletions && format('- deletions: `{0}`', steps.prcheck.outputs.deletions) || '' }}
62+
63+
Break this into smaller PRs, or apply the `${{ env.SKIP_LABEL }}` label to bypass.
64+
65+
- name: Delete size warning comment
66+
if: success() || !steps.check.outputs.run
67+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
68+
with:
69+
header: prcheck
70+
delete: true

run_prcheck.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
TMP_DIR="$(mktemp -d)"
6+
7+
if [[ -f .rayciversion ]]; then
8+
RAYCI_VERSION="$(cat .rayciversion)"
9+
echo "--- Install rayci-lint binary ${RAYCI_VERSION}"
10+
curl -sfL "https://github.com/ray-project/rayci/releases/download/v${RAYCI_VERSION}/rayci-lint-linux-amd64" -o "$TMP_DIR/rayci-lint"
11+
chmod +x "$TMP_DIR/rayci-lint"
12+
exec "$TMP_DIR/rayci-lint" prsize "$@"
13+
14+
exit 1 # Unreachable; just for safe-guarding.
15+
fi
16+
17+
# Legacy path; build from source.
18+
19+
RAYCI_BRANCH="${RAYCI_BRANCH:-stable}"
20+
21+
echo "--- Install rayci-lint"
22+
23+
readonly GO_VERSION=1.24.5
24+
curl -sfL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar -xzf - -C "$TMP_DIR"
25+
export GOROOT="$TMP_DIR/go"
26+
export GOPATH="$TMP_DIR/gopath"
27+
export GOPRIVATE="github.com/ray-project/rayci"
28+
"$TMP_DIR/go/bin/go" install 'github.com/ray-project/rayci/raycilint/raycilint@'"${RAYCI_BRANCH}"
29+
30+
echo "--- Run rayci-lint prsize"
31+
32+
exec "$GOPATH/bin/raycilint" prsize "$@"

0 commit comments

Comments
 (0)