mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-01-16 12:22:08 +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
|
run: golangci-lint run --fix
|
||||||
|
|
||||||
- name: Run golangci-lint format
|
- name: Run golangci-lint format
|
||||||
run: golangci-lint format
|
run: golangci-lint fmt
|
||||||
|
|
||||||
- name: Run go mod tidy
|
- name: Run go mod tidy
|
||||||
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
|
- name: Run tests with enhanced reporting
|
||||||
id: test
|
id: test
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: 1
|
||||||
run: |
|
run: |
|
||||||
cat >> $GITHUB_STEP_SUMMARY << EOF
|
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||||
## 🔧 Test Environment
|
## 🔧 Test Environment
|
||||||
@ -79,9 +81,9 @@ jobs:
|
|||||||
# Extract test results for summary
|
# Extract test results for summary
|
||||||
TEST_STATUS=$?
|
TEST_STATUS=$?
|
||||||
TOTAL_TESTS=$(grep -c "=== RUN" test-output.log || echo "0")
|
TOTAL_TESTS=$(grep -c "=== RUN" test-output.log || echo "0")
|
||||||
PASSED_TESTS=$(grep -c "--- PASS:" 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")
|
FAILED_TESTS=$(grep -c -- "--- FAIL:" test-output.log || echo "0")
|
||||||
SKIPPED_TESTS=$(grep -c "--- SKIP:" test-output.log || echo "0")
|
SKIPPED_TESTS=$(grep -c -- "--- SKIP:" test-output.log || echo "0")
|
||||||
|
|
||||||
# Generate test summary
|
# Generate test summary
|
||||||
cat >> $GITHUB_STEP_SUMMARY << EOF
|
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||||
@ -120,7 +122,7 @@ jobs:
|
|||||||
### ❌ Failed Tests Details
|
### ❌ Failed Tests Details
|
||||||
```
|
```
|
||||||
EOF
|
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'
|
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -128,12 +130,10 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Set outputs for other steps
|
# Set outputs for other steps
|
||||||
cat >> $GITHUB_OUTPUT << EOF
|
echo "test-status=$TEST_STATUS" >> $GITHUB_OUTPUT
|
||||||
test-status=$TEST_STATUS
|
echo "total-tests=$TOTAL_TESTS" >> $GITHUB_OUTPUT
|
||||||
total-tests=$TOTAL_TESTS
|
echo "passed-tests=$PASSED_TESTS" >> $GITHUB_OUTPUT
|
||||||
passed-tests=$PASSED_TESTS
|
echo "failed-tests=$FAILED_TESTS" >> $GITHUB_OUTPUT
|
||||||
failed-tests=$FAILED_TESTS
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Exit with the original test status
|
# Exit with the original test status
|
||||||
exit $TEST_STATUS
|
exit $TEST_STATUS
|
||||||
|
|||||||
@ -4,10 +4,31 @@ repos:
|
|||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v6.0.0
|
rev: v6.0.0
|
||||||
hooks:
|
hooks:
|
||||||
|
# File quality
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
|
exclude: '^\.github/ISSUE_TEMPLATE/.*\.yml$'
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
|
- id: mixed-line-ending
|
||||||
|
args: ['--fix=lf']
|
||||||
|
|
||||||
|
# File validation
|
||||||
- id: check-yaml
|
- 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-added-large-files
|
||||||
|
- id: check-symlinks
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
- repo: https://github.com/golangci/golangci-lint
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v2.6.1
|
rev: v2.6.1
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
@ -316,13 +316,13 @@ tasks:
|
|||||||
docker:run:
|
docker:run:
|
||||||
desc: Run Docker container
|
desc: Run Docker container
|
||||||
aliases: [dr]
|
aliases: [dr]
|
||||||
deps: [docker:build]
|
deps: ['docker:build']
|
||||||
cmds:
|
cmds:
|
||||||
- docker run --rm {{.APP_NAME}}:{{.VERSION}} --help
|
- docker run --rm {{.APP_NAME}}:{{.VERSION}} --help
|
||||||
|
|
||||||
docker:test:
|
docker:test:
|
||||||
desc: Test Docker image
|
desc: Test Docker image
|
||||||
deps: [docker:build]
|
deps: ['docker:build']
|
||||||
cmds:
|
cmds:
|
||||||
- docker run --rm {{.APP_NAME}}:{{.VERSION}} --version
|
- docker run --rm {{.APP_NAME}}:{{.VERSION}} --version
|
||||||
- echo "Docker image tested successfully"
|
- echo "Docker image tested successfully"
|
||||||
@ -434,7 +434,7 @@ tasks:
|
|||||||
|
|
||||||
docs:coverage:
|
docs:coverage:
|
||||||
desc: Open coverage report in browser
|
desc: Open coverage report in browser
|
||||||
deps: [test:coverage]
|
deps: ['test:coverage']
|
||||||
cmds:
|
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}}'
|
- '{{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
|
//go:embed html_styles.css
|
||||||
var defaultCSS string
|
var defaultCSS string
|
||||||
|
|
||||||
//go:embed html_template.html
|
//go:embed html_template.gohtml
|
||||||
var htmlTemplate string
|
var htmlTemplate string
|
||||||
|
|
||||||
// HTMLExporter implements the Exporter interface for HTML format.
|
// HTMLExporter implements the Exporter interface for HTML format.
|
||||||
|
|||||||
@ -9,4 +9,3 @@ Course description
|
|||||||
- **Navigation Mode**:
|
- **Navigation Mode**:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user