chore: bump actions, reflow configs, fix examples

Bump codecov/codecov-action to v7 and docker/metadata-action
to v6 in the CI and release workflows.

Reflow .golangci.yml and html_styles.css under
the prettier plugin dprint now loads.

Exporter examples hand their export to the temp-dir helper instead of
pairing defer cleanup with log.Fatal. log.Fatal exits the process, so
the deferred cleanup never ran and a failed export left its temp dir
behind. gocritic reported it as exitAfterDefer.
This commit is contained in:
2026-09-21 10:10:40 +02:00
parent 7d3487312f
commit 76f8017ea7
5 changed files with 140 additions and 150 deletions
+2 -2
View File
@@ -286,7 +286,7 @@ jobs:
} >> "$GITHUB_STEP_SUMMARY" } >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage reports to Codecov - name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v7
with: with:
files: ./coverage/coverage.out files: ./coverage/coverage.out
flags: Go ${{ env.GO_VERSION }} flags: Go ${{ env.GO_VERSION }}
@@ -401,7 +401,7 @@ jobs:
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v6
with: with:
images: | images: |
${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}
+1 -1
View File
@@ -111,7 +111,7 @@ jobs:
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v6
with: with:
images: | images: |
${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}
+2 -1
View File
@@ -346,7 +346,8 @@ linters:
# stylecheck settings # stylecheck settings
staticcheck: staticcheck:
checks: [ checks:
[
"all", "all",
"-ST1000", "-ST1000",
"-ST1003", "-ST1003",
+18 -23
View File
@@ -12,15 +12,19 @@ import (
"github.com/kjanat/articulate-parser/internal/services" "github.com/kjanat/articulate-parser/internal/services"
) )
// tempOutput returns a path inside a fresh temp dir plus a cleanup func, so // exportToTemp runs export against a path in a fresh temp dir and removes the
// example exports don't pollute the package source tree. Example functions // dir afterwards. Example functions can't take *testing.T, so t.TempDir is
// can't take *testing.T, so t.TempDir is unavailable here. // unavailable here.
func tempOutput(name string) (path string, cleanup func()) { func exportToTemp(name string, export func(path string) error) {
dir, err := os.MkdirTemp("", "exporters-example-*") dir, err := os.MkdirTemp("", "exporters-example-*")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
return filepath.Join(dir, name), func() { _ = os.RemoveAll(dir) } err = export(filepath.Join(dir, name))
_ = os.RemoveAll(dir)
if err != nil {
log.Fatal(err)
}
} }
// ExampleNewFactory demonstrates creating an exporter factory. // ExampleNewFactory demonstrates creating an exporter factory.
@@ -82,12 +86,9 @@ func ExampleMarkdownExporter_Export() {
} }
// Export to markdown file // Export to markdown file
out, cleanup := tempOutput("output.md") exportToTemp("output.md", func(path string) error {
defer cleanup() return exporter.Export(course, path)
err := exporter.Export(course, out) })
if err != nil {
log.Fatal(err)
}
fmt.Println("Export complete") fmt.Println("Export complete")
// Output: Export complete // Output: Export complete
@@ -106,12 +107,9 @@ func ExampleDocxExporter_Export() {
} }
// Export to Word document // Export to Word document
out, cleanup := tempOutput("output.docx") exportToTemp("output.docx", func(path string) error {
defer cleanup() return exporter.Export(course, path)
err := exporter.Export(course, out) })
if err != nil {
log.Fatal(err)
}
fmt.Println("DOCX export complete") fmt.Println("DOCX export complete")
// Output: DOCX export complete // Output: DOCX export complete
@@ -138,12 +136,9 @@ func ExampleHTMLExporter_Export() {
} }
// Export to HTML file // Export to HTML file
out, cleanup := tempOutput("output.html") exportToTemp("output.html", func(path string) error {
defer cleanup() return exporter.Export(course, path)
err := exporter.Export(course, out) })
if err != nil {
log.Fatal(err)
}
fmt.Println("HTML export complete") fmt.Println("HTML export complete")
// Output: HTML export complete // Output: HTML export complete
+2 -8
View File
@@ -1,13 +1,7 @@
body { body {
font-family: font-family:
-apple-system, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
BlinkMacSystemFont, Cantarell, sans-serif;
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
sans-serif;
line-height: 1.6; line-height: 1.6;
color: #333; color: #333;
max-width: 800px; max-width: 800px;