Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: golangci-lint
name: precious

on:
push:
Expand All @@ -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
32 changes: 32 additions & 0 deletions .precious.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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"]

[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
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"proseWrap": "always",
"printWidth": 80,
"tabWidth": 2,
"useTabs": false
}
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
29 changes: 14 additions & 15 deletions README.dev.md
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -45,19 +44,18 @@ $ ./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 {
```

## 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

Expand All @@ -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.
147 changes: 147 additions & 0 deletions mise.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This auto-generated lock file contains invalid versions for the tools which will cause mise install to fail.

  • golangci-lint version 2.11.3 (line 4) does not exist. The official releases are in the 1.x.y range (e.g., 1.59.1).
  • go version 1.26.1 (line 43) does not exist. The latest stable Go version is 1.22.x.

The download URLs for these versions are invalid. This file should be regenerated by running mise lock after correcting the tool versions in mise.toml to point to valid, existing releases.


[[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."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"

[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"

[[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"
20 changes: 20 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[settings]
lockfile = true
disable_backends = [
"asdf",
"vfox",
]

[tools]
go = "latest"
"github:golangci/golangci-lint" = "latest"
Comment on lines +9 to +10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Using latest for tool versions can lead to non-reproducible environments because the actual version can change over time. It is better to pin specific versions in this file.

Furthermore, latest appears to have resolved to invalid versions for both go (1.26.1) and golangci-lint (2.11.3), as seen in the mise.lock file. These versions do not exist, and their download URLs are invalid, which will cause mise install to fail.

Please pin to valid, existing versions. For go, you should use a version compatible with go 1.24 from your go.mod. For golangci-lint, you should use a valid release version (e.g., the latest is 1.59.1).

Suggested change
go = "latest"
"github:golangci/golangci-lint" = "latest"
go = "1.24"
"github:golangci/golangci-lint" = "1.59.1"

"github:houseabsolute/precious" = "latest"
node = "latest"
"npm:prettier" = "latest"

[hooks]
enter = "mise install --quiet"

[[watch_files]]
patterns = ["mise.toml", "mise.lock"]
run = "mise install --quiet"
Loading