11load ("@gazelle//:def.bzl" , "gazelle" )
2- load ("@rules_go//go:def.bzl" , "go_library" , "go_test" )
3- load ("helper.bzl" , "cross_compile_binary" )
4- load ("platforms.def.bzl" , "PLATFORMS" )
2+ load ("@rules_go//go:def.bzl" , "go_binary" , "go_library" , "go_test" )
3+ load ("crosscompile.bzl" , "create_cross_platform_targets" )
54
65gazelle (name = "gazelle" )
76
8- # Name of the binary
97NAME = "tdiscuss"
108
9+ go_test (
10+ name = "tdiscuss_test" ,
11+ size = "small" ,
12+ srcs = [
13+ "config_test.go" ,
14+ "csrf_test.go" ,
15+ "helpers_test.go" ,
16+ "metrics_test.go" ,
17+ "parser_test.go" ,
18+ "server_test.go" ,
19+ ],
20+ embed = [":tdiscuss_lib" ],
21+ target_compatible_with = select ({
22+ "@platforms//os:linux" : [],
23+ "@platforms//os:macos" : [],
24+ "//conditions:default" : ["@platforms//:incompatible" ],
25+ }),
26+ deps = [
27+ "@com_github_jackc_pgx_v5//:pgx" ,
28+ "@com_github_jackc_pgx_v5//pgtype" ,
29+ "@com_github_jackc_pgx_v5//pgxpool" ,
30+ "@com_github_stretchr_testify//assert" ,
31+ "@com_github_stretchr_testify//require" ,
32+ "@com_tailscale//client/tailscale/apitype" ,
33+ "@com_tailscale//ipn/ipnstate" ,
34+ "@com_tailscale//tailcfg" ,
35+ ],
36+ )
37+
38+ # To allow running all tests without external deps
39+ test_suite (
40+ name = "all_tests" ,
41+ tests = [":tdiscuss_test" ],
42+ )
43+
44+ # Default binary for the current platform
45+ go_binary (
46+ name = "tdiscuss" ,
47+ embed = [":tdiscuss_lib" ],
48+ visibility = ["//visibility:public" ],
49+ )
50+
51+ create_cross_platform_targets (
52+ name = "tdiscuss" ,
53+ embed = [":tdiscuss_lib" ],
54+ )
55+
56+ # Define the filegroup to collect all platform binaries
57+ filegroup (
58+ name = "all_platforms" ,
59+ srcs = [
60+ ":tdiscuss-linux-amd64" ,
61+ ":tdiscuss-linux-arm64" ,
62+ ":tdiscuss-darwin-amd64" ,
63+ ":tdiscuss-darwin-arm64" ,
64+ ],
65+ visibility = ["//visibility:public" ],
66+ )
67+
1168go_library (
12- name = "{}_lib" . format ( NAME ) ,
69+ name = "tdiscuss_lib" ,
1370 srcs = [
1471 "config.go" ,
1572 "csrf.go" ,
@@ -18,16 +75,19 @@ go_library(
1875 "main.go" ,
1976 "metrics.go" ,
2077 "models.go" ,
78+ "otel.go" ,
2179 "parser.go" ,
2280 "querier.go" ,
2381 "queries.sql.go" ,
2482 "server.go" ,
83+ "traced_querier.go" ,
2584 ],
2685 embedsrcs = [
86+ "static/style.css" ,
2787 "tmpl/admin.html" ,
2888 "tmpl/edit-profile.html" ,
29- "tmpl/edit-thread.html" ,
3089 "tmpl/edit-thread-post.html" ,
90+ "tmpl/edit-thread.html" ,
3191 "tmpl/error.html" ,
3292 "tmpl/footer.html" ,
3393 "tmpl/header.html" ,
@@ -37,64 +97,41 @@ go_library(
3797 "tmpl/menu.html" ,
3898 "tmpl/newthread.html" ,
3999 "tmpl/thread.html" ,
40- "static/style.css" ,
41100 ],
42- importpath = "github.com/imeyer/{}" . format ( NAME ) ,
101+ importpath = "github.com/imeyer/tdiscuss" ,
43102 visibility = ["//visibility:private" ],
44- x_defs = {
45- "version" : "{STABLE_VERSION}" ,
46- "gitSha" : "{STABLE_GIT_SHA}" ,
47- },
48103 deps = [
49104 "@com_github_google_uuid//:uuid" ,
50105 "@com_github_jackc_pgx_v5//:pgx" ,
51106 "@com_github_jackc_pgx_v5//pgconn" ,
52107 "@com_github_jackc_pgx_v5//pgtype" ,
53108 "@com_github_jackc_pgx_v5//pgxpool" ,
54109 "@com_github_microcosm_cc_bluemonday//:bluemonday" ,
55- "@com_github_prometheus_client_golang//prometheus" ,
56110 "@com_github_prometheus_client_golang//prometheus/promhttp" ,
57- "@com_github_prometheus_client_golang//prometheus/testutil" ,
58111 "@com_github_yuin_goldmark//:goldmark" ,
59112 "@com_github_yuin_goldmark//extension" ,
60113 "@com_github_yuin_goldmark//renderer/html" ,
61114 "@com_github_yuin_goldmark_emoji//:goldmark-emoji" ,
62- "@com_tailscale//client/tailscale" ,
63115 "@com_tailscale//client/tailscale/apitype" ,
64116 "@com_tailscale//hostinfo" ,
65117 "@com_tailscale//ipn/ipnstate" ,
66- "@com_tailscale//tailcfg" ,
67118 "@com_tailscale//tsnet" ,
68119 "@com_tailscale//types/logger" ,
69- ],
70- )
71-
72- [cross_compile_binary (
73- name = NAME ,
74- goarch = goarch ,
75- goos = goos ,
76- ) for (goos , goarch ) in PLATFORMS ]
77-
78- go_test (
79- name = "tdiscuss_test" ,
80- size = "small" ,
81- srcs = [
82- "config_test.go" ,
83- "csrf_test.go" ,
84- "helpers_test.go" ,
85- "metrics_test.go" ,
86- "parser_test.go" ,
87- "server_test.go" ,
88- ],
89- embed = [":tdiscuss_lib" ],
90- deps = [
91- "@com_github_jackc_pgx_v5//:pgx" ,
92- "@com_github_jackc_pgx_v5//pgtype" ,
93- "@com_github_jackc_pgx_v5//pgxpool" ,
94- "@com_github_stretchr_testify//assert" ,
95- "@com_github_stretchr_testify//require" ,
96- "@com_tailscale//client/tailscale/apitype" ,
97- "@com_tailscale//ipn/ipnstate" ,
98- "@com_tailscale//tailcfg" ,
120+ "@io_opentelemetry_go_contrib_bridges_otelslog//:otelslog" ,
121+ "@io_opentelemetry_go_contrib_processors_minsev//:minsev" ,
122+ "@io_opentelemetry_go_otel//:otel" ,
123+ "@io_opentelemetry_go_otel//attribute" ,
124+ "@io_opentelemetry_go_otel//semconv/v1.21.0:v1_21_0" ,
125+ "@io_opentelemetry_go_otel_exporters_otlp_otlplog_otlploghttp//:otlploghttp" ,
126+ "@io_opentelemetry_go_otel_exporters_otlp_otlpmetric_otlpmetrichttp//:otlpmetrichttp" ,
127+ "@io_opentelemetry_go_otel_exporters_otlp_otlptrace_otlptracehttp//:otlptracehttp" ,
128+ "@io_opentelemetry_go_otel_exporters_prometheus//:prometheus" ,
129+ "@io_opentelemetry_go_otel//codes" ,
130+ "@io_opentelemetry_go_otel_metric//:metric" ,
131+ "@io_opentelemetry_go_otel_sdk//resource" ,
132+ "@io_opentelemetry_go_otel_sdk//trace" ,
133+ "@io_opentelemetry_go_otel_sdk_log//:log" ,
134+ "@io_opentelemetry_go_otel_sdk_metric//:metric" ,
135+ "@io_opentelemetry_go_otel_trace//:trace" ,
99136 ],
100137)
0 commit comments