mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-01-16 07:02:09 +01:00
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.
This commit is contained in:
2
.github/workflows/autofix.yml
vendored
2
.github/workflows/autofix.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
||||
run: golangci-lint run --fix
|
||||
|
||||
- name: Run golangci-lint format
|
||||
run: golangci-lint format
|
||||
run: golangci-lint fmt
|
||||
|
||||
- name: Run go mod tidy
|
||||
run: go mod tidy
|
||||
|
||||
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
@ -64,6 +64,8 @@ jobs:
|
||||
|
||||
- name: Run tests with enhanced reporting
|
||||
id: test
|
||||
env:
|
||||
CGO_ENABLED: 1
|
||||
run: |
|
||||
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||
## 🔧 Test Environment
|
||||
@ -79,9 +81,9 @@ jobs:
|
||||
# Extract test results for summary
|
||||
TEST_STATUS=$?
|
||||
TOTAL_TESTS=$(grep -c "=== RUN" test-output.log || echo "0")
|
||||
PASSED_TESTS=$(grep -c "--- PASS:" test-output.log || echo "0")
|
||||
FAILED_TESTS=$(grep -c "--- FAIL:" test-output.log || echo "0")
|
||||
SKIPPED_TESTS=$(grep -c "--- SKIP:" test-output.log || echo "0")
|
||||
PASSED_TESTS=$(grep -c -- "--- PASS:" test-output.log || echo "0")
|
||||
FAILED_TESTS=$(grep -c -- "--- FAIL:" test-output.log || echo "0")
|
||||
SKIPPED_TESTS=$(grep -c -- "--- SKIP:" test-output.log || echo "0")
|
||||
|
||||
# Generate test summary
|
||||
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||
@ -120,7 +122,7 @@ jobs:
|
||||
### ❌ Failed Tests Details
|
||||
```
|
||||
EOF
|
||||
grep -A 10 "--- FAIL:" test-output.log | head -100 >> $GITHUB_STEP_SUMMARY
|
||||
grep -A 10 -- "--- FAIL:" test-output.log | head -100 >> $GITHUB_STEP_SUMMARY
|
||||
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
|
||||
```
|
||||
|
||||
@ -128,12 +130,10 @@ jobs:
|
||||
fi
|
||||
|
||||
# Set outputs for other steps
|
||||
cat >> $GITHUB_OUTPUT << EOF
|
||||
test-status=$TEST_STATUS
|
||||
total-tests=$TOTAL_TESTS
|
||||
passed-tests=$PASSED_TESTS
|
||||
failed-tests=$FAILED_TESTS
|
||||
EOF
|
||||
echo "test-status=$TEST_STATUS" >> $GITHUB_OUTPUT
|
||||
echo "total-tests=$TOTAL_TESTS" >> $GITHUB_OUTPUT
|
||||
echo "passed-tests=$PASSED_TESTS" >> $GITHUB_OUTPUT
|
||||
echo "failed-tests=$FAILED_TESTS" >> $GITHUB_OUTPUT
|
||||
|
||||
# Exit with the original test status
|
||||
exit $TEST_STATUS
|
||||
|
||||
@ -4,10 +4,31 @@ repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v6.0.0
|
||||
hooks:
|
||||
# File quality
|
||||
- id: trailing-whitespace
|
||||
exclude: '^\.github/ISSUE_TEMPLATE/.*\.yml$'
|
||||
- id: end-of-file-fixer
|
||||
- id: mixed-line-ending
|
||||
args: ['--fix=lf']
|
||||
|
||||
# File validation
|
||||
- id: check-yaml
|
||||
- id: check-json
|
||||
- id: check-toml
|
||||
|
||||
# Security
|
||||
- id: detect-private-key
|
||||
|
||||
# Git safety
|
||||
- id: check-merge-conflict
|
||||
- id: check-case-conflict
|
||||
- id: no-commit-to-branch
|
||||
args: ['--branch=master', '--branch=main']
|
||||
|
||||
# File structure
|
||||
- id: check-added-large-files
|
||||
- id: check-symlinks
|
||||
- id: check-executables-have-shebangs
|
||||
- repo: https://github.com/golangci/golangci-lint
|
||||
rev: v2.6.1
|
||||
hooks:
|
||||
|
||||
@ -316,13 +316,13 @@ tasks:
|
||||
docker:run:
|
||||
desc: Run Docker container
|
||||
aliases: [dr]
|
||||
deps: [docker:build]
|
||||
deps: ['docker:build']
|
||||
cmds:
|
||||
- docker run --rm {{.APP_NAME}}:{{.VERSION}} --help
|
||||
|
||||
docker:test:
|
||||
desc: Test Docker image
|
||||
deps: [docker:build]
|
||||
deps: ['docker:build']
|
||||
cmds:
|
||||
- docker run --rm {{.APP_NAME}}:{{.VERSION}} --version
|
||||
- echo "Docker image tested successfully"
|
||||
@ -434,7 +434,7 @@ tasks:
|
||||
|
||||
docs:coverage:
|
||||
desc: Open coverage report in browser
|
||||
deps: [test:coverage]
|
||||
deps: ['test:coverage']
|
||||
cmds:
|
||||
- '{{if eq OS "darwin"}}open {{.COVERAGE_DIR}}/coverage.html{{else if eq OS "windows"}}start {{.COVERAGE_DIR}}/coverage.html{{else}}xdg-open {{.COVERAGE_DIR}}/coverage.html 2>/dev/null || echo "Please open {{.COVERAGE_DIR}}/coverage.html in your browser"{{end}}'
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
//go:embed html_styles.css
|
||||
var defaultCSS string
|
||||
|
||||
//go:embed html_template.html
|
||||
//go:embed html_template.gohtml
|
||||
var htmlTemplate string
|
||||
|
||||
// HTMLExporter implements the Exporter interface for HTML format.
|
||||
|
||||
@ -9,4 +9,3 @@ Course description
|
||||
- **Navigation Mode**:
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user