Skip to content

Commit 0c648cd

Browse files
committed
Feature: modernize CI/CD with GitHub Actions
Replace legacy Concourse CI with modern GitHub Actions to improve developer experience and CI reliability. Split the pipeline into two separate workflows: core CI (pipeline.yml) handles testing, coverage reporting, and builds, while code quality checks (code-check.yml) handle linting and formatting independently. Key improvements include real-time output visibility using tee commands, comprehensive GitHub Step Summaries showing test results and coverage reports directly in PRs, and proper workflow failure states when code quality issues are detected. Updated golangci-lint to use fixed Docker version (v1.64.8) and modernized configuration to resolve compatibility issues with latest tooling. This separation allows functional tests to run independently of code style checks, providing faster feedback and clearer PR status indicators for developers. Files changed: - Add .github/workflows/pipeline.yml (test/build workflow) - Refactor .github/workflows/code-check.yml (code quality workflow) - Update .golangci.yml (modern linter configuration) - Update Makefile (remove Concourse targets, fix tool versions)
1 parent fc376e8 commit 0c648cd

File tree

7 files changed

+278
-76
lines changed

7 files changed

+278
-76
lines changed

.asf.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ github:
5252
required_status_checks:
5353
# strict means "Require branches to be up to date before merging".
5454
strict: true
55+
56+
contexts:
57+
- test
58+
- build
5559
required_pull_request_reviews:
5660
dismiss_stale_reviews: false
5761
required_approving_review_count: 1

.github/workflows/code-check.yml

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,77 @@
1-
---
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
220
name: code-style-check
321

422
on:
523
pull_request:
6-
branches: [master]
24+
branches: [main]
25+
types: [opened, synchronize, reopened, edited]
26+
workflow_dispatch:
727

828
jobs:
929
lint:
1030
runs-on: ubuntu-latest
1131
steps:
12-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v4
1333
- name: run check
1434
run: |
15-
make lint
35+
set +e # Don't exit on error
36+
make lint 2>&1 | tee lint_output.txt
37+
echo "LINT_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
38+
continue-on-error: true
39+
40+
- name: Code Check Summary
41+
if: always()
42+
run: |
43+
echo "## 📋 Code Quality Check Results" >> $GITHUB_STEP_SUMMARY
44+
if [ "${LINT_EXIT_CODE}" == "0" ]; then
45+
echo "✅ All code quality checks passed!" >> $GITHUB_STEP_SUMMARY
46+
echo "- ✅ Code formatting (gofmt)" >> $GITHUB_STEP_SUMMARY
47+
echo "- ✅ Import organization (goimports)" >> $GITHUB_STEP_SUMMARY
48+
echo "- ✅ Static analysis (golangci-lint)" >> $GITHUB_STEP_SUMMARY
49+
echo "" >> $GITHUB_STEP_SUMMARY
50+
51+
if [ -f lint_output.txt ]; then
52+
echo "### 🔍 Lint Details" >> $GITHUB_STEP_SUMMARY
53+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
54+
# Show successful completion messages
55+
grep -E "(SUCCESS|PASS|✓|completed)" lint_output.txt | tail -n 10 >> $GITHUB_STEP_SUMMARY || echo "All checks completed successfully" >> $GITHUB_STEP_SUMMARY
56+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
57+
fi
58+
else
59+
echo "❌ Code quality checks failed. Please fix the issues above." >> $GITHUB_STEP_SUMMARY
60+
echo "" >> $GITHUB_STEP_SUMMARY
61+
echo "Run \`make lint\` locally to check and fix issues." >> $GITHUB_STEP_SUMMARY
62+
echo "" >> $GITHUB_STEP_SUMMARY
63+
64+
if [ -f lint_output.txt ]; then
65+
echo "### 🚨 Issues Found" >> $GITHUB_STEP_SUMMARY
66+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
67+
# Show the last part of output which usually contains the errors
68+
tail -n 30 lint_output.txt >> $GITHUB_STEP_SUMMARY
69+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
70+
fi
71+
fi
72+
73+
- name: Fail workflow if lint failed
74+
if: env.LINT_EXIT_CODE != '0'
75+
run: |
76+
echo "Code quality checks failed. Please fix the issues and try again."
77+
exit 1

.github/workflows/pipeline.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
20+
name: CI Pipeline
21+
22+
on:
23+
push:
24+
branches: [ main ]
25+
pull_request:
26+
branches: [ main ]
27+
types: [ opened, synchronize, reopened, edited ]
28+
workflow_dispatch:
29+
30+
env:
31+
GO_VERSION: '1.21'
32+
33+
jobs:
34+
test:
35+
name: Test
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v4
44+
with:
45+
go-version: ${{ env.GO_VERSION }}
46+
cache: true
47+
48+
- name: Download dependencies
49+
run: make depend
50+
51+
- name: Run tests
52+
run: |
53+
set +e # Don't exit on error
54+
make unit 2>&1 | tee test_output.txt
55+
echo "TEST_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
56+
continue-on-error: true
57+
58+
- name: Generate coverage report
59+
if: env.TEST_EXIT_CODE == '0'
60+
run: |
61+
echo "Generating code coverage report..."
62+
make coverage 2>&1 | tee coverage_output.txt || true
63+
64+
- name: Test Summary
65+
if: always()
66+
run: |
67+
echo "## 🧪 Test Results" >> $GITHUB_STEP_SUMMARY
68+
if [ "${TEST_EXIT_CODE}" == "0" ]; then
69+
echo "✅ All tests passed successfully!" >> $GITHUB_STEP_SUMMARY
70+
echo "" >> $GITHUB_STEP_SUMMARY
71+
72+
# Extract and display test summary
73+
if [ -f test_output.txt ]; then
74+
echo "### 🎯 Test Execution Summary" >> $GITHUB_STEP_SUMMARY
75+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
76+
# Extract the final summary lines
77+
tail -n 10 test_output.txt | grep -E "(Ginkgo ran|Test Suite)" >> $GITHUB_STEP_SUMMARY || echo "Test summary not found" >> $GITHUB_STEP_SUMMARY
78+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
79+
echo "" >> $GITHUB_STEP_SUMMARY
80+
fi
81+
82+
echo "### 📊 Code Coverage Report" >> $GITHUB_STEP_SUMMARY
83+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
84+
if [ -f coverage_output.txt ]; then
85+
cat coverage_output.txt >> $GITHUB_STEP_SUMMARY
86+
else
87+
echo "Coverage report not available" >> $GITHUB_STEP_SUMMARY
88+
fi
89+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
90+
else
91+
echo "❌ Some tests failed. Check the logs above for details." >> $GITHUB_STEP_SUMMARY
92+
echo "" >> $GITHUB_STEP_SUMMARY
93+
if [ -f test_output.txt ]; then
94+
echo "### 📋 Test Output" >> $GITHUB_STEP_SUMMARY
95+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
96+
tail -n 20 test_output.txt >> $GITHUB_STEP_SUMMARY
97+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
98+
fi
99+
fi
100+
101+
build:
102+
name: Build
103+
runs-on: ubuntu-latest
104+
needs: [test]
105+
106+
steps:
107+
- name: Checkout code
108+
uses: actions/checkout@v4
109+
110+
- name: Set up Go
111+
uses: actions/setup-go@v4
112+
with:
113+
go-version: ${{ env.GO_VERSION }}
114+
cache: true
115+
116+
- name: Build
117+
run: go build -v ./...
118+
119+
- name: Build Summary
120+
if: always()
121+
run: |
122+
echo "## 🔨 Build Results" >> $GITHUB_STEP_SUMMARY
123+
if [ ${{ job.status }} == 'success' ]; then
124+
echo "✅ Build completed successfully!" >> $GITHUB_STEP_SUMMARY
125+
else
126+
echo "❌ Build failed. Check the logs above for details." >> $GITHUB_STEP_SUMMARY
127+
fi

.golangci.yml

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,86 @@
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
20+
# golangci-lint configuration file
21+
# See https://golangci-lint.run/docs/product/migration-guide for migration instructions
22+
23+
run:
24+
timeout: 5m
25+
go: "1.21"
26+
27+
output:
28+
format: colored-line-number
29+
print-issued-lines: true
30+
print-linter-name: true
31+
32+
linters-settings:
33+
govet:
34+
check-shadowing: true
35+
revive:
36+
min-confidence: 0
37+
gocyclo:
38+
min-complexity: 15
39+
dupl:
40+
threshold: 100
41+
goconst:
42+
min-len: 2
43+
min-occurrences: 2
44+
145
linters:
2-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
3-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
4-
disable-all: true
546
enable:
6-
- golint
7-
- vet
8-
- varcheck
9-
- unparam
47+
- govet
1048
- errcheck
49+
- staticcheck
50+
- unused
51+
- gosimple
52+
- ineffassign
53+
- typecheck
54+
- revive
55+
- gocyclo
56+
- gofmt
57+
- goimports
58+
- misspell
59+
- lll
60+
- unparam
61+
- nakedret
62+
- prealloc
63+
- gocritic
64+
disable:
65+
- golint # deprecated, replaced by revive
66+
- structcheck # deprecated since v1.49.0
67+
- varcheck # deprecated since v1.49.0
68+
- deadcode # deprecated since v1.49.0
69+
- scopelint # deprecated since v1.39.0
1170

1271
issues:
13-
# List of regexps of issue texts to exclude, empty list by default.
14-
# But independently from this option we use default exclude patterns,
15-
# it can be disabled by `exclude-use-default: false`. To list all
16-
# excluded by default patterns execute `golangci-lint run --help`
17-
exclude:
18-
- "don't use ALL_CAPS in Go names; use CamelCase"
19-
- "should not use dot imports"
20-
72+
exclude-use-default: false
2173
exclude-rules:
22-
- path: _test\.go
23-
text: "don't use underscores in Go names"
24-
linters:
25-
- golint
26-
74+
# Exclude some linters from running on tests files.
2775
- path: _test\.go
2876
linters:
77+
- gocyclo
2978
- errcheck
79+
- dupl
80+
- gosec
81+
# Exclude known linters from partially hard-to-fix issues
82+
- linters:
83+
- lll
84+
source: "^//go:generate "
85+
max-issues-per-linter: 0
86+
max-same-issues: 0

Makefile

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ goimports:
2222
docker run --rm -i -v "${PWD}":/data -w /data unibeautify/goimports -w -l /data
2323

2424
golangci-lint:
25-
docker run --rm -v ${PWD}:/data -w /data golangci/golangci-lint golangci-lint run -v
25+
docker run --rm -v ${PWD}:/data -w /data golangci/golangci-lint:v1.64.8 golangci-lint run -v
2626

2727
gofmt:
2828
docker run --rm -v ${PWD}:/data cytopia/gofmt --ci .
2929

3030
$(GINKGO):
31-
go install github.com/onsi/ginkgo/v2/ginkgo@latest
31+
go install github.com/onsi/ginkgo/v2/ginkgo@v2.13.0
3232

3333
unit: $(GINKGO)
3434
ginkgo -r --keep-going --randomize-suites --randomize-all \
@@ -56,18 +56,4 @@ clean :
5656
rm -rf /tmp/cover*
5757
rm -rf /tmp/unit*
5858

59-
##### Pipeline targets #####
6059

61-
set-dev:
62-
fly --target dev set-pipeline --check-creds \
63-
--pipeline=dev-gp-common-go-libs-${BRANCH}-${USER} \
64-
-c ci/pipeline.yml \
65-
--var=branch=${BRANCH} \
66-
--var=golang-version=${GOLANG_VERSION}
67-
68-
set-prod:
69-
fly --target prod set-pipeline --check-creds \
70-
--pipeline=gp-common-go-libs \
71-
-c ci/pipeline.yml \
72-
--var=branch=main\
73-
--var=golang-version=${GOLANG_VERSION}

0 commit comments

Comments
 (0)