fix: resolve golangci-lint CI failures, simplify CI, tidy docs (#29)

* fix(lint): resolve golangci-lint failures and modernize string handling

CI's golangci-lint (v2.12.2) job was failing with 14 issues, which blocked
the dependent test job. This addresses all of them:

- goconst: extract repeated string literals into constants
  - format aliases ("md", "word", "htm") in the exporter factory
  - "section" lesson type shared by markdown and HTML exporters
  - default Articulate Rise base URL and host in the parser
  - reuse existing itemType* constants in the markdown switch
- staticcheck (QF1012): replace buf.WriteString(fmt.Sprintf(...)) with
  fmt.Fprintf(...) in the markdown exporter

Also drop the hardcoded `go: "1.24"` from .golangci.yml so the target Go
version is autodetected from go.mod.

* ci: drop test matrix, run a single Go version from go.mod

The test job ran a 1.24.x/1.25.x matrix, but go.mod requires go 1.25.0, so the
1.24 entry just auto-downloaded the 1.25 toolchain and tested the same thing
twice. Replace the matrix with a single job that sources its Go version from
go.mod via go-version-file, and reference the resolved version through the
setup-go step output in summaries, artifact names, and Codecov flags.

* docs: remove emojis from README

* ci: pin modernize tool to gopls v0.21.x for Go 1.25 compatibility

The autofix workflow's `task modernize` step installed the modernize
analyzer from gopls@latest, which as of v0.22.0 requires Go 1.26. The
project targets Go 1.25 (go.mod) and CI runs with GOTOOLCHAIN=local, so
the install failed. Pin to the v0.21.x line, which supports Go >= 1.25.

* ci: keep modernize@latest, fetch its toolchain via GOTOOLCHAIN=auto

Replaces the earlier v0.21.0 pin. The modernize analyzer (gopls v0.22+)
requires Go 1.26, which the project doesn't target yet — and bumping the
module to 1.26 isn't viable because the current golangci-lint release is
built with Go 1.25 and refuses to lint a newer target. Instead, let the
modernize task fetch the toolchain it needs on demand via GOTOOLCHAIN=auto
(setup-go pins GOTOOLCHAIN=local in CI), so we stay on the latest analyzer
without touching the module's Go version.

Also bump golang.org/x/image v0.34.0 -> v0.42.0 via `go get -u ./...`.

* ci: set GOTOOLCHAIN=auto inline for the modernize task

A task-level env: entry does not override GOTOOLCHAIN when setup-go has
already exported GOTOOLCHAIN=local job-wide, so the autofix job still
failed. Set GOTOOLCHAIN=auto inline on the modernize command itself, which
reliably overrides the inherited value and lets Go fetch the toolchain the
modernize analyzer requires.

* ci: bump to Go 1.26 and address PR review feedback

The autofix failure is fixed properly by moving to Go 1.26 instead of the
GOTOOLCHAIN workaround. The official golangci-lint v2.12.2 binary is built
with go1.26.2 and lints a Go 1.26 target fine (the earlier "not ready"
claim was from a locally go-installed binary compiled with Go 1.25), and
the Dockerfiles already use golang:1.26-alpine, so this also aligns the
module with the images.

- go.mod: go 1.25.0 -> 1.26.0, drop the toolchain pin (keeps the lint
  target at the go directive).
- Taskfile: revert modernize to plain modernize@latest; on Go 1.26 the
  GOTOOLCHAIN dance and its comments are unnecessary.
- ci.yml: pass the resolved Go version through an env var (GO_VERSION)
  instead of interpolating steps.setup-go.outputs.go-version directly into
  shell scripts (script-injection hygiene); grant the dependency-review job
  pull-requests: write so it can post its summary.
- parser.go: derive defaultBaseURL from riseHost instead of duplicating the
  host string; drop the redundant per-const comments.
- .golangci.yml: remove the redundant go-version comment.
- regenerate internal/exporters/output.docx.
This commit is contained in:
2026-06-15 21:46:57 +02:00
committed by GitHub
parent 9ea51458c3
commit 144125d355
10 changed files with 76 additions and 59 deletions
+23 -17
View File
@@ -35,21 +35,24 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
go:
- 1.24.x
- 1.25.x
steps:
- uses: actions/checkout@v6
- name: Set up Go ${{ matrix.go }}
- name: Set up Go
id: setup-go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
go-version-file: go.mod
check-latest: true
# Expose the resolved Go version as an env var so it is never
# interpolated directly into a shell script (avoids script injection).
- name: Export Go version
env:
GO_VERSION: ${{ steps.setup-go.outputs.go-version }}
run: echo "GO_VERSION=$GO_VERSION" >> "$GITHUB_ENV"
- name: Install Task
uses: go-task/setup-task@v1
@@ -70,7 +73,7 @@ jobs:
{
cat << EOF
## 🔧 Test Environment
- **Go Version:** ${{ matrix.go }}
- **Go Version:** $GO_VERSION
- **OS:** ubuntu-latest
- **Timestamp:** $(date -u)
@@ -90,7 +93,7 @@ jobs:
# Generate test summary
{
cat << EOF
## 🧪 Test Results (Go ${{ matrix.go }})
## 🧪 Test Results (Go $GO_VERSION)
| Metric | Value |
| ----------- | ------------------------------------------------------------- |
@@ -152,7 +155,7 @@ jobs:
{
cat << EOF
## 📊 Code Coverage (Go ${{ matrix.go }})
## 📊 Code Coverage (Go $GO_VERSION)
**Total Coverage: $COVERAGE**
@@ -213,7 +216,7 @@ jobs:
if: failure()
uses: actions/upload-artifact@v6
with:
name: test-results-go-${{ matrix.go }}
name: test-results-go-${{ env.GO_VERSION }}
path: |
test-output.log
coverage/
@@ -223,7 +226,7 @@ jobs:
run: |
{
cat << EOF
## 🔍 Static Analysis (Go ${{ matrix.go }})
## 🔍 Static Analysis (Go $GO_VERSION)
EOF
@@ -267,9 +270,10 @@ jobs:
- name: Job Summary
if: always()
run: |
cat >> "$GITHUB_STEP_SUMMARY" << 'EOF'
## 📋 Job Summary (Go ${{ matrix.go }})
{
echo "## 📋 Job Summary (Go $GO_VERSION)"
echo ""
cat << 'EOF'
| Step | Status |
| --------------- | --------------------------------------------------------------- |
| Dependencies | Success |
@@ -279,12 +283,13 @@ jobs:
| Static Analysis | ${{ job.status == 'success' && 'Clean' || 'Issues' }} |
| Code Formatting | ${{ job.status == 'success' && 'Clean' || 'Issues' }} |
EOF
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/coverage.out
flags: Go ${{ matrix.go }}
flags: Go ${{ env.GO_VERSION }}
slug: kjanat/articulate-parser
token: ${{ secrets.CODECOV_TOKEN }}
@@ -292,7 +297,7 @@ jobs:
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
flags: Go ${{ matrix.go }}
flags: Go ${{ env.GO_VERSION }}
token: ${{ secrets.CODECOV_TOKEN }}
docker-test:
@@ -348,6 +353,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
if: github.event_name == 'pull_request'
steps:
- name: "Checkout Repository"