Skip to content

Commit 8d60670

Browse files
committed
chore(tooling): Improve CI pipeline and expand pre-commit hooks
Expands the pre-commit configuration with a wider range of hooks to enforce file quality, validation, security, and Git safety checks. The CI pipeline is updated to: - Correct the `golangci-lint` format command to `fmt`. - Enable CGO for test execution to support the race detector. - Improve the robustness of test report parsing scripts. Additionally, this commit includes minor stylistic and formatting cleanups across various project files.
1 parent e7de5d0 commit 8d60670

File tree

16 files changed

+245
-225
lines changed

16 files changed

+245
-225
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# These owners will be the default owners for everything in
2-
# the repo. Unless a later match takes precedence, they will
2+
# the repo. Unless a later match takes precedence, they will
33
# be requested for review when someone opens a pull request.
44
* @kjanat
55

.github/workflows/autofix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: golangci-lint run --fix
3535

3636
- name: Run golangci-lint format
37-
run: golangci-lint format
37+
run: golangci-lint fmt
3838

3939
- name: Run go mod tidy
4040
run: go mod tidy

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464

6565
- name: Run tests with enhanced reporting
6666
id: test
67+
env:
68+
CGO_ENABLED: 1
6769
run: |
6870
cat >> $GITHUB_STEP_SUMMARY << EOF
6971
## 🔧 Test Environment
@@ -79,9 +81,9 @@ jobs:
7981
# Extract test results for summary
8082
TEST_STATUS=$?
8183
TOTAL_TESTS=$(grep -c "=== RUN" test-output.log || echo "0")
82-
PASSED_TESTS=$(grep -c "--- PASS:" test-output.log || echo "0")
83-
FAILED_TESTS=$(grep -c "--- FAIL:" test-output.log || echo "0")
84-
SKIPPED_TESTS=$(grep -c "--- SKIP:" test-output.log || echo "0")
84+
PASSED_TESTS=$(grep -c -- "--- PASS:" test-output.log || echo "0")
85+
FAILED_TESTS=$(grep -c -- "--- FAIL:" test-output.log || echo "0")
86+
SKIPPED_TESTS=$(grep -c -- "--- SKIP:" test-output.log || echo "0")
8587
8688
# Generate test summary
8789
cat >> $GITHUB_STEP_SUMMARY << EOF
@@ -120,20 +122,18 @@ jobs:
120122
### ❌ Failed Tests Details
121123
```
122124
EOF
123-
grep -A 10 "--- FAIL:" test-output.log | head -100 >> $GITHUB_STEP_SUMMARY
125+
grep -A 10 -- "--- FAIL:" test-output.log | head -100 >> $GITHUB_STEP_SUMMARY
124126
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
125127
```
126128
127129
EOF
128130
fi
129131
130132
# Set outputs for other steps
131-
cat >> $GITHUB_OUTPUT << EOF
132-
test-status=$TEST_STATUS
133-
total-tests=$TOTAL_TESTS
134-
passed-tests=$PASSED_TESTS
135-
failed-tests=$FAILED_TESTS
136-
EOF
133+
echo "test-status=$TEST_STATUS" >> $GITHUB_OUTPUT
134+
echo "total-tests=$TOTAL_TESTS" >> $GITHUB_OUTPUT
135+
echo "passed-tests=$PASSED_TESTS" >> $GITHUB_OUTPUT
136+
echo "failed-tests=$FAILED_TESTS" >> $GITHUB_OUTPUT
137137
138138
# Exit with the original test status
139139
exit $TEST_STATUS

.github/workflows/codeql.yml

Lines changed: 104 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,104 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
12-
name: "CodeQL"
13-
14-
# This workflow is configured to be called by other workflows for more controlled execution
15-
# This allows integration with the main CI pipeline and avoids redundant runs
16-
# To enable automatic execution, uncomment the triggers below:
17-
on:
18-
workflow_call:
19-
schedule:
20-
- cron: '44 16 * * 6'
21-
# push:
22-
# branches: [ "master" ]
23-
# pull_request:
24-
# branches: [ "master" ]
25-
26-
jobs:
27-
analyze:
28-
name: Analyze (${{ matrix.language }})
29-
# Runner size impacts CodeQL analysis time. To learn more, please see:
30-
# - https://gh.io/recommended-hardware-resources-for-running-codeql
31-
# - https://gh.io/supported-runners-and-hardware-resources
32-
# - https://gh.io/using-larger-runners (GitHub.com only)
33-
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
34-
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
35-
permissions:
36-
# required for all workflows
37-
security-events: write
38-
39-
# required to fetch internal or private CodeQL packs
40-
packages: read
41-
42-
# only required for workflows in private repositories
43-
actions: read
44-
contents: read
45-
46-
strategy:
47-
fail-fast: false
48-
matrix:
49-
include:
50-
- language: actions
51-
build-mode: none
52-
- language: go
53-
build-mode: autobuild
54-
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
55-
# Use `c-cpp` to analyze code written in C, C++ or both
56-
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
57-
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
58-
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
59-
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
60-
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
61-
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
62-
steps:
63-
- name: Checkout repository
64-
uses: actions/checkout@v5
65-
66-
# Add any setup steps before running the `github/codeql-action/init` action.
67-
# This includes steps like installing compilers or runtimes (`actions/setup-node`
68-
# or others). This is typically only required for manual builds.
69-
# - name: Setup runtime (example)
70-
# uses: actions/setup-example@v1
71-
72-
# Initializes the CodeQL tools for scanning.
73-
- name: Initialize CodeQL
74-
uses: github/codeql-action/init@v4
75-
with:
76-
languages: ${{ matrix.language }}
77-
build-mode: ${{ matrix.build-mode }}
78-
# If you wish to specify custom queries, you can do so here or in a config file.
79-
# By default, queries listed here will override any specified in a config file.
80-
# Prefix the list here with "+" to use these queries and those in the config file.
81-
82-
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
83-
# queries: security-extended,security-and-quality
84-
85-
# If the analyze step fails for one of the languages you are analyzing with
86-
# "We were unable to automatically build your code", modify the matrix above
87-
# to set the build mode to "manual" for that language. Then modify this step
88-
# to build your code.
89-
# ℹ️ Command-line programs to run using the OS shell.
90-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
91-
- if: matrix.build-mode == 'manual'
92-
shell: bash
93-
run: |
94-
echo 'If you are using a "manual" build mode for one or more of the' \
95-
'languages you are analyzing, replace this with the commands to build' \
96-
'your code, for example:'
97-
echo ' make bootstrap'
98-
echo ' make release'
99-
exit 1
100-
101-
- name: Perform CodeQL Analysis
102-
uses: github/codeql-action/analyze@v4
103-
with:
104-
category: "/language:${{matrix.language}}"
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
# This workflow is configured to be called by other workflows for more controlled execution
15+
# This allows integration with the main CI pipeline and avoids redundant runs
16+
# To enable automatic execution, uncomment the triggers below:
17+
on:
18+
workflow_call:
19+
schedule:
20+
- cron: '44 16 * * 6'
21+
# push:
22+
# branches: [ "master" ]
23+
# pull_request:
24+
# branches: [ "master" ]
25+
26+
jobs:
27+
analyze:
28+
name: Analyze (${{ matrix.language }})
29+
# Runner size impacts CodeQL analysis time. To learn more, please see:
30+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
31+
# - https://gh.io/supported-runners-and-hardware-resources
32+
# - https://gh.io/using-larger-runners (GitHub.com only)
33+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
34+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
35+
permissions:
36+
# required for all workflows
37+
security-events: write
38+
39+
# required to fetch internal or private CodeQL packs
40+
packages: read
41+
42+
# only required for workflows in private repositories
43+
actions: read
44+
contents: read
45+
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
include:
50+
- language: actions
51+
build-mode: none
52+
- language: go
53+
build-mode: autobuild
54+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
55+
# Use `c-cpp` to analyze code written in C, C++ or both
56+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
57+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
58+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
59+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
60+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
61+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v5
65+
66+
# Add any setup steps before running the `github/codeql-action/init` action.
67+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
68+
# or others). This is typically only required for manual builds.
69+
# - name: Setup runtime (example)
70+
# uses: actions/setup-example@v1
71+
72+
# Initializes the CodeQL tools for scanning.
73+
- name: Initialize CodeQL
74+
uses: github/codeql-action/init@v4
75+
with:
76+
languages: ${{ matrix.language }}
77+
build-mode: ${{ matrix.build-mode }}
78+
# If you wish to specify custom queries, you can do so here or in a config file.
79+
# By default, queries listed here will override any specified in a config file.
80+
# Prefix the list here with "+" to use these queries and those in the config file.
81+
82+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
83+
# queries: security-extended,security-and-quality
84+
85+
# If the analyze step fails for one of the languages you are analyzing with
86+
# "We were unable to automatically build your code", modify the matrix above
87+
# to set the build mode to "manual" for that language. Then modify this step
88+
# to build your code.
89+
# ℹ️ Command-line programs to run using the OS shell.
90+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
91+
- if: matrix.build-mode == 'manual'
92+
shell: bash
93+
run: |
94+
echo 'If you are using a "manual" build mode for one or more of the' \
95+
'languages you are analyzing, replace this with the commands to build' \
96+
'your code, for example:'
97+
echo ' make bootstrap'
98+
echo ' make release'
99+
exit 1
100+
101+
- name: Perform CodeQL Analysis
102+
uses: github/codeql-action/analyze@v4
103+
with:
104+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)