Skip to content

Commit c6b6143

Browse files
committed
Update
1 parent fa080c5 commit c6b6143

File tree

3 files changed

+76
-43
lines changed

3 files changed

+76
-43
lines changed

.asf.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ github:
5353
# contexts are the names of checks that must pass.
5454
contexts:
5555
- build_and_unit_test
56+
- code_quality
5657
required_pull_request_reviews:
5758
dismiss_stale_reviews: false
5859
required_approving_review_count: 1

.github/workflows/build_and_unit_test.yml

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build_and_unit_test
1+
name: Build and Unit Test
22

33
on:
44
push:
@@ -22,50 +22,8 @@ env:
2222
GOBIN: ${{ github.workspace }}/.go/bin
2323

2424
jobs:
25-
# Code quality checks
26-
code_quality:
27-
runs-on: ubuntu-latest
28-
steps:
29-
- name: Checkout code
30-
uses: actions/checkout@v4
31-
with:
32-
fetch-depth: 0
33-
34-
- name: Set up Go
35-
uses: actions/setup-go@v5
36-
with:
37-
go-version: ${{ env.GO_VERSION }}
38-
cache: true
39-
40-
- name: Setup GOPATH/PATH
41-
run: |
42-
echo "GOPATH=${GOPATH}" >> "$GITHUB_ENV"
43-
echo "${GOBIN}" >> "$GITHUB_PATH"
44-
45-
- name: Install dependencies
46-
run: make depend
47-
48-
- name: Formatting check (read-only)
49-
run: |
50-
go install golang.org/x/tools/cmd/goimports@latest
51-
CHANGED=$(goimports -l $(git ls-files '*.go'))
52-
if [ -n "$CHANGED" ]; then
53-
echo "The following files need formatting:"
54-
echo "$CHANGED"
55-
echo "Please run: make format"
56-
exit 1
57-
fi
58-
59-
- name: GolangCI-Lint
60-
uses: golangci/golangci-lint-action@v4
61-
with:
62-
version: v1.56.2
63-
args: --tests=false
64-
only-new-issues: true
6525

66-
# Build and unit tests with GPDB version matrix
6726
build_and_unit_test:
68-
needs: code_quality
6927
runs-on: ubuntu-latest
7028

7129
steps:

.github/workflows/code_quality.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Code Quality Check
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
types: [ opened, synchronize, reopened, edited, ready_for_review ]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
env:
19+
GO_VERSION: '1.21'
20+
GOPATH: ${{ github.workspace }}/.go
21+
GOBIN: ${{ github.workspace }}/.go/bin
22+
23+
jobs:
24+
code_quality:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: ${{ env.GO_VERSION }}
36+
cache: true
37+
38+
- name: Setup GOPATH/PATH
39+
run: |
40+
echo "GOPATH=${GOPATH}" >> "$GITHUB_ENV"
41+
echo "${GOBIN}" >> "$GITHUB_PATH"
42+
43+
- name: Install dependencies
44+
run: make depend
45+
46+
- name: Formatting check (read-only)
47+
run: |
48+
set -eo pipefail
49+
command -v goimports >/dev/null || go install golang.org/x/tools/cmd/goimports@latest
50+
files=$(git ls-files '*.go')
51+
if [ -z "$files" ]; then
52+
echo "No Go files found. Skipping formatting check."
53+
exit 0
54+
fi
55+
CHANGED=$(goimports -l $files)
56+
if [ -n "$CHANGED" ]; then
57+
echo "$CHANGED"
58+
echo "### Formatting issues" >> "$GITHUB_STEP_SUMMARY"
59+
echo "$CHANGED" | sed 's/^/- /' >> "$GITHUB_STEP_SUMMARY"
60+
echo "Please run \`make format\` on your local machine" >> "$GITHUB_STEP_SUMMARY"
61+
exit 1
62+
fi
63+
64+
- name: GolangCI-Lint (no PR annotations)
65+
run: |
66+
set -eo pipefail
67+
command -v golangci-lint >/dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
68+
OUTPUT=$(golangci-lint run --tests=false --out-format=colored-line-number || true)
69+
if [ -n "$OUTPUT" ]; then
70+
echo "$OUTPUT"
71+
echo "### GolangCI-Lint issues" >> "$GITHUB_STEP_SUMMARY"
72+
echo "$OUTPUT" | sed 's/^/- /' >> "$GITHUB_STEP_SUMMARY"
73+
exit 1
74+
fi

0 commit comments

Comments
 (0)