mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-10-13 00:15:28 +02:00
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:
@@ -286,7 +286,7 @@ jobs:
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@v7
|
||||
with:
|
||||
files: ./coverage/coverage.out
|
||||
flags: Go ${{ env.GO_VERSION }}
|
||||
@@ -401,7 +401,7 @@ jobs:
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: |
|
||||
${{ env.IMAGE_NAME }}
|
||||
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: |
|
||||
${{ env.IMAGE_NAME }}
|
||||
|
||||
+2
-1
@@ -346,7 +346,8 @@ linters:
|
||||
|
||||
# stylecheck settings
|
||||
staticcheck:
|
||||
checks: [
|
||||
checks:
|
||||
[
|
||||
"all",
|
||||
"-ST1000",
|
||||
"-ST1003",
|
||||
|
||||
@@ -12,15 +12,19 @@ import (
|
||||
"github.com/kjanat/articulate-parser/internal/services"
|
||||
)
|
||||
|
||||
// tempOutput returns a path inside a fresh temp dir plus a cleanup func, so
|
||||
// example exports don't pollute the package source tree. Example functions
|
||||
// can't take *testing.T, so t.TempDir is unavailable here.
|
||||
func tempOutput(name string) (path string, cleanup func()) {
|
||||
// exportToTemp runs export against a path in a fresh temp dir and removes the
|
||||
// dir afterwards. Example functions can't take *testing.T, so t.TempDir is
|
||||
// unavailable here.
|
||||
func exportToTemp(name string, export func(path string) error) {
|
||||
dir, err := os.MkdirTemp("", "exporters-example-*")
|
||||
if err != nil {
|
||||
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.
|
||||
@@ -82,12 +86,9 @@ func ExampleMarkdownExporter_Export() {
|
||||
}
|
||||
|
||||
// Export to markdown file
|
||||
out, cleanup := tempOutput("output.md")
|
||||
defer cleanup()
|
||||
err := exporter.Export(course, out)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
exportToTemp("output.md", func(path string) error {
|
||||
return exporter.Export(course, path)
|
||||
})
|
||||
|
||||
fmt.Println("Export complete")
|
||||
// Output: Export complete
|
||||
@@ -106,12 +107,9 @@ func ExampleDocxExporter_Export() {
|
||||
}
|
||||
|
||||
// Export to Word document
|
||||
out, cleanup := tempOutput("output.docx")
|
||||
defer cleanup()
|
||||
err := exporter.Export(course, out)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
exportToTemp("output.docx", func(path string) error {
|
||||
return exporter.Export(course, path)
|
||||
})
|
||||
|
||||
fmt.Println("DOCX export complete")
|
||||
// Output: DOCX export complete
|
||||
@@ -138,12 +136,9 @@ func ExampleHTMLExporter_Export() {
|
||||
}
|
||||
|
||||
// Export to HTML file
|
||||
out, cleanup := tempOutput("output.html")
|
||||
defer cleanup()
|
||||
err := exporter.Export(course, out)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
exportToTemp("output.html", func(path string) error {
|
||||
return exporter.Export(course, path)
|
||||
})
|
||||
|
||||
fmt.Println("HTML export complete")
|
||||
// Output: HTML export complete
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
body {
|
||||
font-family:
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
Roboto,
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
sans-serif;
|
||||
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
||||
Cantarell, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
max-width: 800px;
|
||||
|
||||
Reference in New Issue
Block a user