Skip to content

Commit

Permalink
build(localstorage): fix crossplatform compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme committed Oct 29, 2024
1 parent 29b2a6a commit 8caae4b
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 6 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,32 @@ jobs:
create_a_dev_release:
name: create a dev release
runs-on: ubuntu-latest
container:
image: ghcr.io/goreleaser/goreleaser-cross:v1.23.2
env:
GOPRIVATE: "github.com/humanlogio/humanlog-pro"
GH_ACCESS_TOKEN_FOR_HUMANLOGPRO: ${{ secrets.GH_ACCESS_TOKEN_FOR_HUMANLOGPRO }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git config --global --add safe.directory '*'
- run: git config --global url.https://[email protected]/.insteadOf https://github.com/
- run: git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: ">=1.23"
cache: true
- run: git config --global url.https://[email protected]/.insteadOf https://github.com/
- run: echo "${HOME}/.humanlog/bin" >> $GITHUB_PATH
- run: curl https://humanlog.dev/install_apictl.sh | bash
- run: go install github.com/goware/modvendor@latest
- run: go mod vendor
- run: modvendor -copy="**/*.a **/*.h" -v
- uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: v2
args: release --clean --draft --skip validate --config .goreleaser-dev.yaml
args: release --verbose --clean --draft --skip validate --config .goreleaser-dev.yaml
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_BINARIES_BUCKET_KEY_ID }}
Expand Down
100 changes: 97 additions & 3 deletions .goreleaser-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,114 @@ before:
- go generate ./...
- mkdir -p dist-extra
- script/write_version_info.sh "{{.Major}}" "{{.Minor}}" "{{.Patch}}" "next.{{ .CommitTimestamp }}" "{{.ShortCommit}}" "https://humanlog-binaries.sfo3.cdn.digitaloceanspaces.com/humanlog-binaries/{{ .ProjectName }}/dev/{{ .CommitTimestamp }}/{{ .ShortCommit }}"
# builds:
# - main: ./cmd/humanlog/
# binary: humanlog
# env:
# - CGO_ENABLED=1
# tags:
# - pro
# ldflags:
# - -s -w -X main.versionMajor={{.Major}} -X main.versionMinor={{.Minor}} -X main.versionPatch={{.Patch}} -X main.versionPrerelease=next.{{ .CommitTimestamp }} -X main.versionBuild={{.ShortCommit}} -X main.defaultApiAddr=https://api.humanlog.dev -X main.defaultBaseSiteAddr=https://humanlog.dev
# goos:
# # - windows
# - darwin
# - linux
# goarch:
# - amd64
# - arm64

builds:
- main: ./cmd/humanlog/
- id: humanlog-darwin-amd64
binary: humanlog
main: ./cmd/humanlog
tags:
- pro
goarch:
- amd64
goos:
- darwin
env:
- CGO_ENABLED=1
- CC=o64-clang
- CXX=o64-clang++
flags:
- -trimpath
ldflags:
- -s -w -X main.versionMajor={{.Major}} -X main.versionMinor={{.Minor}} -X main.versionPatch={{.Patch}} -X main.versionPrerelease=next.{{ .CommitTimestamp }} -X main.versionBuild={{.ShortCommit}} -X main.defaultApiAddr=https://api.humanlog.dev -X main.defaultBaseSiteAddr=https://humanlog.dev

- id: humanlog-darwin-arm64
binary: humanlog
main: ./cmd/humanlog
tags:
- pro
goarch:
- arm64
goos:
# - windows
- darwin
- linux
env:
- CGO_ENABLED=1
- CC=oa64-clang
- CXX=oa64-clang++
flags:
- -trimpath
ldflags:
- -s -w -X main.versionMajor={{.Major}} -X main.versionMinor={{.Minor}} -X main.versionPatch={{.Patch}} -X main.versionPrerelease=next.{{ .CommitTimestamp }} -X main.versionBuild={{.ShortCommit}} -X main.defaultApiAddr=https://api.humanlog.dev -X main.defaultBaseSiteAddr=https://humanlog.dev

- id: humanlog-linux-amd64
binary: humanlog
main: ./cmd/humanlog
tags:
- pro
env:
- CGO_ENABLED=1
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
goarch:
- amd64
goos:
- linux
flags:
- -trimpath
ldflags:
- -extldflags "-lc -lrt -lpthread --static" -s -w -X main.versionMajor={{.Major}} -X main.versionMinor={{.Minor}} -X main.versionPatch={{.Patch}} -X main.versionPrerelease=next.{{ .CommitTimestamp }} -X main.versionBuild={{.ShortCommit}} -X main.defaultApiAddr=https://api.humanlog.dev -X main.defaultBaseSiteAddr=https://humanlog.dev

- id: humanlog-linux-arm64
binary: humanlog
main: ./cmd/humanlog
tags:
- pro
goarch:
- arm64
goos:
- linux
env:
- CGO_ENABLED=1
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
flags:
- -trimpath
ldflags:
- -extldflags "-lc -lrt -lpthread --static" -s -w -X main.versionMajor={{.Major}} -X main.versionMinor={{.Minor}} -X main.versionPatch={{.Patch}} -X main.versionPrerelease=next.{{ .CommitTimestamp }} -X main.versionBuild={{.ShortCommit}} -X main.defaultApiAddr=https://api.humanlog.dev -X main.defaultBaseSiteAddr=https://humanlog.dev

# - id: humanlog-windows-amd64
# binary: humanlog
# main: ./cmd/humanlog
# tags:
# - pro
# goarch:
# - amd64
# goos:
# - windows
# env:
# - CC=x86_64-w64-mingw32-gcc
# - CXX=x86_64-w64-mingw32-g++
# flags:
# - -trimpath
# - -buildmode=exe
# ldflags:
# - -s -w -X main.versionMajor={{.Major}} -X main.versionMinor={{.Minor}} -X main.versionPatch={{.Patch}} -X main.versionPrerelease=next.{{ .CommitTimestamp }} -X main.versionBuild={{.ShortCommit}} -X main.defaultApiAddr=https://api.humanlog.dev -X main.defaultBaseSiteAddr=https://humanlog.dev

release:
disable: true
blobs:
Expand Down
4 changes: 4 additions & 0 deletions cmd/humanlog/localhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import (
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"golang.org/x/sys/unix"

// imported for side-effect of `init()` registration
_ "github.com/humanlogio/humanlog/internal/diskstorage"
_ "github.com/humanlogio/humanlog/internal/memstorage"
)

func isEADDRINUSE(err error) bool {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/go-logfmt/logfmt v0.5.1
github.com/google/uuid v1.6.0
github.com/humanlogio/api/go v0.0.0-20241027163319-aa04487ea614
github.com/humanlogio/humanlog-pro v0.0.0-20241028134505-e9bf80d75533
github.com/humanlogio/humanlog-pro v0.0.0-20241029032705-0ce172ecfc87
github.com/kr/logfmt v0.0.0-20210122060352-19f9bcb100e6
github.com/lrstanley/bubblezone v0.0.0-20240914071701-b48c55a5e78e
github.com/matoous/go-nanoid v1.5.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ github.com/humanlogio/api/go v0.0.0-20241027163319-aa04487ea614 h1:YxgFfohQN7m4I
github.com/humanlogio/api/go v0.0.0-20241027163319-aa04487ea614/go.mod h1:+hU/MU1g6QvtbeknKOlUI1yEStVqkPJ8jmYIj63OV5I=
github.com/humanlogio/humanlog-pro v0.0.0-20241028134505-e9bf80d75533 h1:E60b80WZ060kM1PPF5oK5rVkZi+O4UKSmC2ZpaQZxyU=
github.com/humanlogio/humanlog-pro v0.0.0-20241028134505-e9bf80d75533/go.mod h1:1aHRO1O8oH4Mht2hOAo+kiLalHNu1SpFDcvuyauZuos=
github.com/humanlogio/humanlog-pro v0.0.0-20241029032705-0ce172ecfc87 h1:z6x3cbdSyvnlmiuQ0v3Qi2iuJoRh1dyKydHIFy4J0is=
github.com/humanlogio/humanlog-pro v0.0.0-20241029032705-0ce172ecfc87/go.mod h1:1aHRO1O8oH4Mht2hOAo+kiLalHNu1SpFDcvuyauZuos=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
Expand Down
1 change: 1 addition & 0 deletions internal/diskstorage/pkg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package diskstorage
2 changes: 2 additions & 0 deletions pkg/localstorage/queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package localstorage
import (
"context"
"fmt"
"log"
"log/slog"
"time"

Expand All @@ -15,6 +16,7 @@ type StorageBuilder func(ctx context.Context, ll *slog.Logger, cfg map[string]in
var registry = make(map[string]StorageBuilder)

func RegisterStorage(name string, builder StorageBuilder) {
log.Printf("registered storage engine %q", name)
_, ok := registry[name]
if ok {
panic(fmt.Sprintf("already used: %q", name))
Expand Down

0 comments on commit 8caae4b

Please sign in to comment.