From 398f4293ba395a7055c0a23d0a7c8060cf43ac81 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 10 Mar 2026 17:05:15 +0000 Subject: [PATCH 1/3] Update golangci-lint to 2.11.3 via mise Co-Authored-By: Claude Opus 4.6 --- mise.lock | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ mise.toml | 17 +++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 mise.lock create mode 100644 mise.toml diff --git a/mise.lock b/mise.lock new file mode 100644 index 0000000..bba1a44 --- /dev/null +++ b/mise.lock @@ -0,0 +1,72 @@ +# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html + +[[tools."github:golangci/golangci-lint"]] +version = "2.11.3" +backend = "github:golangci/golangci-lint" + +[tools."github:golangci/golangci-lint"."platforms.linux-arm64"] +checksum = "sha256:ee3d95f301359e7d578e6d99c8ad5aeadbabc5a13009a30b2b0df11c8058afe9" +url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-linux-arm64.tar.gz" +url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370749014" + +[tools."github:golangci/golangci-lint"."platforms.linux-arm64-musl"] +checksum = "sha256:ee3d95f301359e7d578e6d99c8ad5aeadbabc5a13009a30b2b0df11c8058afe9" +url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-linux-arm64.tar.gz" +url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370749014" + +[tools."github:golangci/golangci-lint"."platforms.linux-x64"] +checksum = "sha256:87bb8cddbcc825d5778b64e8a91b46c0526b247f4e2f2904dea74ec7450475d1" +url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-linux-amd64.tar.gz" +url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370748984" + +[tools."github:golangci/golangci-lint"."platforms.linux-x64-musl"] +checksum = "sha256:87bb8cddbcc825d5778b64e8a91b46c0526b247f4e2f2904dea74ec7450475d1" +url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-linux-amd64.tar.gz" +url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370748984" + +[tools."github:golangci/golangci-lint"."platforms.macos-arm64"] +checksum = "sha256:30ee39979c516b9d1adca289a3f93429d130c4c0fda5e57d637850894221f6cc" +url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-darwin-arm64.tar.gz" +url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370749042" + +[tools."github:golangci/golangci-lint"."platforms.macos-x64"] +checksum = "sha256:f93bda1f2cc981fd1326464020494be62f387bbf262706e1b3b644e5afacc440" +url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-darwin-amd64.tar.gz" +url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370749038" + +[tools."github:golangci/golangci-lint"."platforms.windows-x64"] +checksum = "sha256:cd42e890176bc5cfeb36225a77e66b9410ddd3a59a03551e23f6b210d29e1f67" +url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-windows-amd64.zip" +url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370749053" + +[[tools.go]] +version = "1.26.1" +backend = "core:go" + +[tools.go."platforms.linux-arm64"] +checksum = "sha256:a290581cfe4fe28ddd737dde3095f3dbeb7f2e4065cab4eae44dfc53b760c2f7" +url = "https://dl.google.com/go/go1.26.1.linux-arm64.tar.gz" + +[tools.go."platforms.linux-arm64-musl"] +checksum = "sha256:a290581cfe4fe28ddd737dde3095f3dbeb7f2e4065cab4eae44dfc53b760c2f7" +url = "https://dl.google.com/go/go1.26.1.linux-arm64.tar.gz" + +[tools.go."platforms.linux-x64"] +checksum = "sha256:031f088e5d955bab8657ede27ad4e3bc5b7c1ba281f05f245bcc304f327c987a" +url = "https://dl.google.com/go/go1.26.1.linux-amd64.tar.gz" + +[tools.go."platforms.linux-x64-musl"] +checksum = "sha256:031f088e5d955bab8657ede27ad4e3bc5b7c1ba281f05f245bcc304f327c987a" +url = "https://dl.google.com/go/go1.26.1.linux-amd64.tar.gz" + +[tools.go."platforms.macos-arm64"] +checksum = "sha256:353df43a7811ce284c8938b5f3c7df40b7bfb6f56cb165b150bc40b5e2dd541f" +url = "https://dl.google.com/go/go1.26.1.darwin-arm64.tar.gz" + +[tools.go."platforms.macos-x64"] +checksum = "sha256:65773dab2f8cc4cd23d93ba6d0a805de150ca0b78378879292be0b903b8cdd08" +url = "https://dl.google.com/go/go1.26.1.darwin-amd64.tar.gz" + +[tools.go."platforms.windows-x64"] +checksum = "sha256:9b68112c913f45b7aebbf13c036721264bbba7e03a642f8f7490c561eebd1ecc" +url = "https://dl.google.com/go/go1.26.1.windows-amd64.zip" diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..4045f42 --- /dev/null +++ b/mise.toml @@ -0,0 +1,17 @@ +[settings] +lockfile = true +disable_backends = [ + "asdf", + "vfox", +] + +[tools] +go = "latest" +"github:golangci/golangci-lint" = "latest" + +[hooks] +enter = "mise install --quiet" + +[[watch_files]] +patterns = ["mise.toml", "mise.lock"] +run = "mise install --quiet" From 17fc5f359bcfe99f7bc628966eda83cc9b64b78a Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 10 Mar 2026 19:37:39 +0000 Subject: [PATCH 2/3] Use precious for linting in GitHub Actions Co-Authored-By: Claude Opus 4.6 --- .../{golangci-lint.yml => precious.yml} | 12 +++--- .precious.toml | 23 +++++++++++ mise.lock | 39 +++++++++++++++++++ mise.toml | 1 + 4 files changed, 70 insertions(+), 5 deletions(-) rename .github/workflows/{golangci-lint.yml => precious.yml} (56%) create mode 100644 .precious.toml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/precious.yml similarity index 56% rename from .github/workflows/golangci-lint.yml rename to .github/workflows/precious.yml index 2c56bac..b621b88 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/precious.yml @@ -1,4 +1,4 @@ -name: golangci-lint +name: precious on: push: @@ -9,14 +9,16 @@ on: permissions: {} jobs: - golangci: + precious: name: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: golangci-lint - uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # 9.2.0 + - name: Setup mise + uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 with: - version: latest + cache: true + - name: Run precious lint + run: precious lint --all diff --git a/.precious.toml b/.precious.toml new file mode 100644 index 0000000..023c6be --- /dev/null +++ b/.precious.toml @@ -0,0 +1,23 @@ +exclude = [ + ".git", +] + +[commands.golangci-lint-fmt] +type = "both" +cmd = ["golangci-lint", "fmt"] +lint-flags = "--diff" +ok-exit-codes = 0 +invoke = "once" +include = ["**/*.go"] +exclude = ["**/testdata/**/*.go"] + +[commands.golangci-lint] +type = "both" +cmd = ["golangci-lint", "run"] +tidy-flags = ["--fix"] +ok-exit-codes = 0 +ignore-stderr = ".*" +invoke = "once" +path-args = "dir" +include = ["**/*.go"] +exclude = ["**/testdata/**/*.go"] diff --git a/mise.lock b/mise.lock index bba1a44..ee302ea 100644 --- a/mise.lock +++ b/mise.lock @@ -39,6 +39,45 @@ checksum = "sha256:cd42e890176bc5cfeb36225a77e66b9410ddd3a59a03551e23f6b210d29e1 url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-windows-amd64.zip" url_api = "https://api.github.com/repos/golangci/golangci-lint/releases/assets/370749053" +[[tools."github:houseabsolute/precious"]] +version = "0.10.2" +backend = "github:houseabsolute/precious" + +[tools."github:houseabsolute/precious"."platforms.linux-arm64"] +checksum = "sha256:8fbaead9f9626170549c3121e67d1bc81193b3bb086e29576f548aefa839fcc4" +url = "https://github.com/houseabsolute/precious/releases/download/v0.10.2/precious-Linux-musl-arm64.tar.gz" +url_api = "https://api.github.com/repos/houseabsolute/precious/releases/assets/345520042" + +[tools."github:houseabsolute/precious"."platforms.linux-arm64-musl"] +checksum = "sha256:8fbaead9f9626170549c3121e67d1bc81193b3bb086e29576f548aefa839fcc4" +url = "https://github.com/houseabsolute/precious/releases/download/v0.10.2/precious-Linux-musl-arm64.tar.gz" +url_api = "https://api.github.com/repos/houseabsolute/precious/releases/assets/345520042" + +[tools."github:houseabsolute/precious"."platforms.linux-x64"] +checksum = "sha256:3d717d906db338f63017766b07982dc9055773e1b3bec6d3f432d1f0ad9676bb" +url = "https://github.com/houseabsolute/precious/releases/download/v0.10.2/precious-Linux-musl-x86_64.tar.gz" +url_api = "https://api.github.com/repos/houseabsolute/precious/releases/assets/345519861" + +[tools."github:houseabsolute/precious"."platforms.linux-x64-musl"] +checksum = "sha256:3d717d906db338f63017766b07982dc9055773e1b3bec6d3f432d1f0ad9676bb" +url = "https://github.com/houseabsolute/precious/releases/download/v0.10.2/precious-Linux-musl-x86_64.tar.gz" +url_api = "https://api.github.com/repos/houseabsolute/precious/releases/assets/345519861" + +[tools."github:houseabsolute/precious"."platforms.macos-arm64"] +checksum = "sha256:04157c64459bb6ab029295b21b112077040ad2575b34508d84b19a839551cddb" +url = "https://github.com/houseabsolute/precious/releases/download/v0.10.2/precious-macOS-arm64.tar.gz" +url_api = "https://api.github.com/repos/houseabsolute/precious/releases/assets/345519985" + +[tools."github:houseabsolute/precious"."platforms.macos-x64"] +checksum = "sha256:9932defd246d0771530357463bdb55582557fd7381853cb4dc2074e36ad0cc84" +url = "https://github.com/houseabsolute/precious/releases/download/v0.10.2/precious-macOS-x86_64.tar.gz" +url_api = "https://api.github.com/repos/houseabsolute/precious/releases/assets/345519772" + +[tools."github:houseabsolute/precious"."platforms.windows-x64"] +checksum = "sha256:9d683d1730e302c646ccb90a23d313e7a548c8b23b5abf7d24e19ff6befe763d" +url = "https://github.com/houseabsolute/precious/releases/download/v0.10.2/precious-Windows-msvc-x86_64.zip" +url_api = "https://api.github.com/repos/houseabsolute/precious/releases/assets/345520544" + [[tools.go]] version = "1.26.1" backend = "core:go" diff --git a/mise.toml b/mise.toml index 4045f42..ef7cc81 100644 --- a/mise.toml +++ b/mise.toml @@ -8,6 +8,7 @@ disable_backends = [ [tools] go = "latest" "github:golangci/golangci-lint" = "latest" +"github:houseabsolute/precious" = "latest" [hooks] enter = "mise install --quiet" From 887383e01b66c0073c1dfd9f2737762cbe3b21d6 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 10 Mar 2026 19:38:26 +0000 Subject: [PATCH 3/3] Add prettier markdown linting Co-Authored-By: Claude Opus 4.6 --- .precious.toml | 9 +++++++++ .prettierrc.json | 6 ++++++ CHANGELOG.md | 5 +++-- README.dev.md | 29 ++++++++++++++--------------- README.md | 20 ++++++++++---------- mise.lock | 36 ++++++++++++++++++++++++++++++++++++ mise.toml | 2 ++ 7 files changed, 80 insertions(+), 27 deletions(-) create mode 100644 .prettierrc.json diff --git a/.precious.toml b/.precious.toml index 023c6be..0172904 100644 --- a/.precious.toml +++ b/.precious.toml @@ -21,3 +21,12 @@ invoke = "once" path-args = "dir" include = ["**/*.go"] exclude = ["**/testdata/**/*.go"] + +[commands.prettier-markdown] +type = "both" +cmd = ["prettier", "--prose-wrap", "always"] +lint-flags = ["--check"] +tidy-flags = ["--write"] +path-args = "absolute-file" +include = "**/*.md" +ok-exit-codes = 0 diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..70ac175 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "proseWrap": "always", + "printWidth": 80, + "tabWidth": 2, + "useTabs": false +} diff --git a/CHANGELOG.md b/CHANGELOG.md index de64065..9a97fe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,9 @@ ## 1.0.0 -* Refactored the codebase to allow using the code generation functionality as a library. +- Refactored the codebase to allow using the code generation functionality as a + library. ## 0.1.0 (2022-10-06) -* Initial version. +- Initial version. diff --git a/README.dev.md b/README.dev.md index 7c7c517..cd13e4a 100644 --- a/README.dev.md +++ b/README.dev.md @@ -1,18 +1,17 @@ # Releasing -* Install `goreleaser`. Refer to its docs. -* Set a `GITHUB_TOKEN` environment variable. Refer to `goreleaser` docs for +- Install `goreleaser`. Refer to its docs. +- Set a `GITHUB_TOKEN` environment variable. Refer to `goreleaser` docs for information. -* Update `CHANGELOG.md`. - * Mention recent changes. - * Set a version if there is not one. - * Set a release date. -* Set version in `version.go`. -* Commit `CHANGELOG.md` and `version.go`. -* Tag the release: `git tag -a v1.2.3 -m 'Tag v1.2.3'`. -* Push the tag: `git push origin v1.2.3`. -* Run `goreleaser release`. -* Edit the release on - [GitHub](https://github.com/maxmind/xgb2code/releases) to include the - changelog changes. -* Make sure to push the rest of your changes. +- Update `CHANGELOG.md`. + - Mention recent changes. + - Set a version if there is not one. + - Set a release date. +- Set version in `version.go`. +- Commit `CHANGELOG.md` and `version.go`. +- Tag the release: `git tag -a v1.2.3 -m 'Tag v1.2.3'`. +- Push the tag: `git push origin v1.2.3`. +- Run `goreleaser release`. +- Edit the release on [GitHub](https://github.com/maxmind/xgb2code/releases) to + include the changelog changes. +- Make sure to push the rest of your changes. diff --git a/README.md b/README.md index 80ded21..708fdda 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,8 @@ This program takes an XGB model (in JSON format) and generates code for it. -Generating code for a model avoids having to call out to a different -language (e.g., C) as well as avoids the need for using the XGB libraries -at runtime. +Generating code for a model avoids having to call out to a different language +(e.g., C) as well as avoids the need for using the XGB libraries at runtime. ## Model Support @@ -45,8 +44,8 @@ $ ./xgb2code -function-name predict \ -output-file predict.go ``` -produces a file `predict.go` where the primary model prediction function -has the signature: +produces a file `predict.go` where the primary model prediction function has the +signature: ```go func predict(data []*float32, predMargin bool) float32 { @@ -54,10 +53,9 @@ func predict(data []*float32, predMargin bool) float32 { ## Installation -[Release binaries and -packages](https://github.com/maxmind/xgb2code/releases) have been made -available for several popular platforms. Simply download the binary for -your platform and run it. +[Release binaries and packages](https://github.com/maxmind/xgb2code/releases) +have been made available for several popular platforms. Simply download the +binary for your platform and run it. ## Bug Reports @@ -68,4 +66,6 @@ Please report bugs by filing an issue with our GitHub issue tracker at This software is Copyright (c) 2022 - 2025 by MaxMind, Inc. -This is free software, licensed under the [Apache License, Version 2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT), at your option. +This is free software, licensed under the +[Apache License, Version 2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT), +at your option. diff --git a/mise.lock b/mise.lock index ee302ea..0fccd35 100644 --- a/mise.lock +++ b/mise.lock @@ -109,3 +109,39 @@ url = "https://dl.google.com/go/go1.26.1.darwin-amd64.tar.gz" [tools.go."platforms.windows-x64"] checksum = "sha256:9b68112c913f45b7aebbf13c036721264bbba7e03a642f8f7490c561eebd1ecc" url = "https://dl.google.com/go/go1.26.1.windows-amd64.zip" + +[[tools.node]] +version = "25.8.0" +backend = "core:node" + +[tools.node."platforms.linux-arm64"] +checksum = "sha256:54c128f5286a4392a1fd1c765729b074a6873abff8a4f9bb3d63d571c2855e41" +url = "https://nodejs.org/dist/v25.8.0/node-v25.8.0-linux-arm64.tar.gz" + +[tools.node."platforms.linux-arm64-musl"] +checksum = "sha256:54c128f5286a4392a1fd1c765729b074a6873abff8a4f9bb3d63d571c2855e41" +url = "https://nodejs.org/dist/v25.8.0/node-v25.8.0-linux-arm64.tar.gz" + +[tools.node."platforms.linux-x64"] +checksum = "sha256:2ae6f70d74a459c0a96456e486dc60f3e7e65d7752ad302771834e58b27500af" +url = "https://nodejs.org/dist/v25.8.0/node-v25.8.0-linux-x64.tar.gz" + +[tools.node."platforms.linux-x64-musl"] +checksum = "sha256:2ae6f70d74a459c0a96456e486dc60f3e7e65d7752ad302771834e58b27500af" +url = "https://nodejs.org/dist/v25.8.0/node-v25.8.0-linux-x64.tar.gz" + +[tools.node."platforms.macos-arm64"] +checksum = "sha256:75ff6fd07e0a85fb4d2529f6189c996014b1d3d83180c31e65feb2b3eaeec5d9" +url = "https://nodejs.org/dist/v25.8.0/node-v25.8.0-darwin-arm64.tar.gz" + +[tools.node."platforms.macos-x64"] +checksum = "sha256:03fb559600c3ede0228d8b588ac6ad8b7b2cd0bac9422b56e7e2ef7f5c11b67c" +url = "https://nodejs.org/dist/v25.8.0/node-v25.8.0-darwin-x64.tar.gz" + +[tools.node."platforms.windows-x64"] +checksum = "sha256:5744746371a417179a701044739b5fa2b3164e943aa57f86059fb312f8032e86" +url = "https://nodejs.org/dist/v25.8.0/node-v25.8.0-win-x64.zip" + +[[tools."npm:prettier"]] +version = "3.8.1" +backend = "npm:prettier" diff --git a/mise.toml b/mise.toml index ef7cc81..b424d4e 100644 --- a/mise.toml +++ b/mise.toml @@ -9,6 +9,8 @@ disable_backends = [ go = "latest" "github:golangci/golangci-lint" = "latest" "github:houseabsolute/precious" = "latest" +node = "latest" +"npm:prettier" = "latest" [hooks] enter = "mise install --quiet"