Skip to content

Commit 2edd597

Browse files
authored
Merge branch 'develop' into test/community-ownership-transfer
2 parents 478248c + a1f739a commit 2edd597

166 files changed

Lines changed: 6388 additions & 14500 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ jobs:
5757
uses: golangci/golangci-lint-action@v8
5858
with:
5959
version: v2.3.1
60-
args: --build-tags=gowaku_no_rln,lint,use_logos_storage
60+
args: --build-tags=gowaku_no_rln,lint,use_logos_storage,use_torrent
6161

6262
- name: lint-panics
6363
run: |
64-
make lint-panics USE_LOGOS_STORAGE=true
64+
make lint-panics USE_LOGOS_STORAGE=true USE_TORRENT=true
6565
6666
- name: go mod tidy
6767
run: go mod tidy && git diff --exit-code

.nvim.lua

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
local status_go_root = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h")
2+
local native_root = vim.fs.dirname(status_go_root)
3+
local logos_storage_lib_dir = vim.env.LOGOS_STORAGE_LIB_DIR or native_root .. "/logos-storage-nim/build"
4+
local logos_storage_inc_dir = vim.env.LOGOS_STORAGE_INC_DIR or native_root .. "/logos-storage-nim/library"
5+
local nim_sds_lib_dir = vim.env.NIM_SDS_LIB_DIR or native_root .. "/nim-sds/build"
6+
local nim_sds_inc_dir = vim.env.NIM_SDS_INC_DIR or native_root .. "/nim-sds/library"
7+
local cgo_cflags = vim.env.CGO_CFLAGS and vim.env.CGO_CFLAGS .. " " or ""
8+
local cgo_ldflags = vim.env.CGO_LDFLAGS and vim.env.CGO_LDFLAGS .. " " or ""
9+
10+
local function append_unique_path_list(existing, paths)
11+
local seen = {}
12+
local result = {}
13+
14+
for path in string.gmatch(existing or "", "[^:]+") do
15+
if not seen[path] then
16+
table.insert(result, path)
17+
seen[path] = true
18+
end
19+
end
20+
21+
for _, path in ipairs(paths) do
22+
if not seen[path] then
23+
table.insert(result, path)
24+
seen[path] = true
25+
end
26+
end
27+
28+
return table.concat(result, ":")
29+
end
30+
31+
local native_env = {
32+
LOGOS_STORAGE_LIB_DIR = logos_storage_lib_dir,
33+
LOGOS_STORAGE_INC_DIR = logos_storage_inc_dir,
34+
NIM_SDS_LIB_DIR = nim_sds_lib_dir,
35+
NIM_SDS_INC_DIR = nim_sds_inc_dir,
36+
CGO_CFLAGS = cgo_cflags .. "-I" .. logos_storage_inc_dir .. " -I" .. nim_sds_inc_dir,
37+
CGO_LDFLAGS = cgo_ldflags .. "-L" .. logos_storage_lib_dir .. " -lstorage -Wl,-rpath," .. logos_storage_lib_dir .. " -L" .. nim_sds_lib_dir .. " -lsds",
38+
LD_LIBRARY_PATH = append_unique_path_list(vim.env.LD_LIBRARY_PATH, { logos_storage_lib_dir, nim_sds_lib_dir }),
39+
}
40+
41+
for key, value in pairs(native_env) do
42+
vim.env[key] = value
43+
end
44+
45+
vim.lsp.config("gopls", {
46+
cmd_env = native_env,
47+
settings = {
48+
gopls = {
49+
env = native_env,
50+
analyses = {
51+
ST1000 = false,
52+
ST1003 = false,
53+
},
54+
buildFlags = {
55+
"-tags=gowaku_skip_migrations,gowaku_no_rln,use_logos_storage,use_torrent",
56+
},
57+
},
58+
},
59+
})
60+
61+
local function find_golangci_lint()
62+
for dir in string.gmatch(vim.env.PATH or "", "[^:]+") do
63+
local exe = dir .. "/golangci-lint"
64+
if vim.fn.executable(exe) == 1 and not string.find(exe, "/mason/", 1, true) then
65+
return exe
66+
end
67+
end
68+
end
69+
70+
local function remove_golangci_lint(lint)
71+
local go_linters = lint.linters_by_ft.go
72+
if not go_linters then
73+
return
74+
end
75+
76+
local filtered = {}
77+
for _, linter in ipairs(go_linters) do
78+
if linter ~= "golangcilint" then
79+
table.insert(filtered, linter)
80+
end
81+
end
82+
lint.linters_by_ft.go = filtered
83+
end
84+
85+
local function configure_golangci_lint()
86+
local ok, lint = pcall(require, "lint")
87+
if not ok or not lint.linters.golangcilint then
88+
return
89+
end
90+
91+
local golangci_lint = find_golangci_lint()
92+
if not golangci_lint then
93+
remove_golangci_lint(lint)
94+
return
95+
end
96+
97+
lint.linters.golangcilint.cmd = golangci_lint
98+
lint.linters.golangcilint.cwd = status_go_root
99+
lint.linters.golangcilint.args = {
100+
"--build-tags",
101+
"gowaku_no_rln lint",
102+
"run",
103+
"./...",
104+
"--output.json.path=stdout",
105+
"--output.text.path=",
106+
"--output.tab.path=",
107+
"--output.html.path=",
108+
"--output.checkstyle.path=",
109+
"--output.code-climate.path=",
110+
"--output.junit-xml.path=",
111+
"--output.teamcity.path=",
112+
"--output.sarif.path=",
113+
"--issues-exit-code=0",
114+
"--show-stats=false",
115+
"--path-mode=abs",
116+
}
117+
end
118+
119+
configure_golangci_lint()
120+
121+
vim.api.nvim_create_autocmd("User", {
122+
pattern = "VeryLazy",
123+
callback = configure_golangci_lint,
124+
})

.vscode/settings.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ Thank you for considering contributing to our project! We appreciate your time a
55
## Table of Contents
66
1. [Workflow](#workflow)
77
2. [Code Style](#code-style)
8-
3. [Keep History Clean](#keep-history-clean)
9-
4. [Testing](#testing)
8+
3. [IDE Setup](#ide-setup)
9+
4. [Keep History Clean](#keep-history-clean)
10+
5. [Testing](#testing)
1011
- [Test Validation](#test-validation)
1112
- [Area of Impact](#area-of-impact)
12-
5. [Pull Request Description](#pull-request-description)
13+
6. [Pull Request Description](#pull-request-description)
1314
- [Feature Flags](#feature-flags)
1415
- [Removing Feature Flags](#removing-feature-flags)
15-
6. [Test Coverage](#test-coverage)
16+
7. [Test Coverage](#test-coverage)
1617
- [Maintaining Test Coverage](#maintaining-test-coverage)
1718
- [Metrics for Test Coverage](#metrics-for-test-coverage)
1819

@@ -28,6 +29,18 @@ Thank you for considering contributing to our project! We appreciate your time a
2829

2930
Please note that we follow [Effective Go](https://golang.org/doc/effective_go.html) and [CodeReviewComments](https://github.com/golang/go/wiki/CodeReviewComments) in our code.
3031

32+
## IDE Setup
33+
34+
### Neovim
35+
36+
The repository includes a `.nvim.lua` at the root that auto-configures the Neovim environment for `status-go` development. When `status-go` is opened as a project in Neovim, this script:
37+
38+
- Sets `CGO_CFLAGS`, `CGO_LDFLAGS`, and `LD_LIBRARY_PATH` for the native C dependencies (`libsds` and `libstorage`).
39+
- Configures `gopls` with the correct build tags (`gowaku_skip_migrations`, `gowaku_no_rln`, `use_logos_storage`, `use_torrent`).
40+
- Integrates `golangci-lint` with the project's lint settings.
41+
42+
It supports both paths provided by the Nix development shell (via environment variables) and fallbacks to locally built native libraries. This is the recommended way to work with Neovim on this project, as direct `go test` or `gopls` may fail to resolve native symbols without these flags.
43+
3144
## Keep History Clean
3245

3346
1. **Squash PR before merging**: You can do it either with GitHub API by merging with "Squash and merge" or locally if you want to preserve your signature. It is ok to merge multiple commits with "Rebase and merge" if they are logically separate.

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ ARG enable_go_cache=true
5353
RUN if [ "$enable_go_cache" = "true" ]; then \
5454
go env -w GOCACHE=/root/.cache/go-build; \
5555
fi
56+
ARG use_torrent=false
5657
RUN --mount=type=cache,target="/root/.cache/go-build",id=statusgo-build-$cache_id \
57-
make $build_target BUILD_TAGS="$build_tags" BUILD_FLAGS="$build_flags" USE_LOGOS_STORAGE="$use_logos_storage"
58+
make $build_target BUILD_TAGS="$build_tags" BUILD_FLAGS="$build_flags" USE_LOGOS_STORAGE="$use_logos_storage" USE_TORRENT="$use_torrent"
5859

5960
# Stage runtime shared libraries required by built binaries.
6061
RUN mkdir -p /tmp/status-runtime-libs \

Makefile

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.PHONY: statusgo all test clean help
22
.PHONY: statusgo-ios-library statusgo-android-library
33
.PHONY: build-libsds clean-libsds rebuild-libsds
4-
.PHONY: clone-storage build-storage clean-storage test-storage
5-
.PHONY: storage-help
4+
.PHONY: clone-storage build-storage clean-storage test-storage test-torrent
5+
.PHONY: history-archive-help
66

77
# Clear any GOROOT set outside of the Nix shell
88
export GOROOT=
@@ -107,7 +107,8 @@ BUILD_TAGS ?= gowaku_no_rln
107107
# Pin nim-sds revision here. Can be a tag (default) or commit hash.
108108
NIM_SDS_VERSION ?= v0.2.4
109109

110-
# Option 1: Provide NIM_SDS_SOURCE_DIR. Make clones it if missing.
110+
# Option 1: Provide NIM_SDS_SOURCE_DIR. Make force-reclones a fresh copy (with submodules)
111+
# to guarantee a clean checkout on every build.
111112
NIM_SDS_SOURCE_DIR ?= $(GIT_ROOT)/../nim-sds
112113
# Normalize path separators for Windows (backslashes cause issues when passed through shells)
113114
ifeq ($(mkspecs),win32)
@@ -137,10 +138,12 @@ CGO_LDFLAGS+=-L$(NIM_SDS_LIB_DIR) -lsds
137138

138139
# `logos-storage` variables (opt-in)
139140
USE_LOGOS_STORAGE ?= false
141+
USE_TORRENT ?= false
140142
LOGOS_STORAGE_VERSION ?= 3c09f008bb5266a669fd19f18368f9e8b861b664
141143
LOGOS_STORAGE_SOURCE_DIR ?= $(GIT_ROOT)/../logos-storage-nim
142144

143-
# Option 1: Provide LOGOS_STORAGE_SOURCE_DIR. Make clones it if missing.
145+
# Option 1: Provide LOGOS_STORAGE_SOURCE_DIR. Make force-reclones a fresh copy (with submodules)
146+
# to guarantee a clean checkout on every build.
144147
# Option 2: Provide LOGOS_STORAGE_LIB_DIR and LOGOS_STORAGE_INC_DIR.
145148
ifdef LOGOS_STORAGE_LIB_DIR
146149
ifdef LOGOS_STORAGE_INC_DIR
@@ -159,28 +162,38 @@ LIBSTORAGE ?= $(LOGOS_STORAGE_LIB_DIR)/libstorage.$(LIB_EXT)
159162
RUNTIME_LIB_DIRS := $(NIM_SDS_LIB_DIR)
160163
LOGOS_STORAGE_BUILD_DEPS :=
161164
ifeq ($(USE_LOGOS_STORAGE),true)
162-
BUILD_TAGS += use_logos_storage
165+
override BUILD_TAGS += use_logos_storage
163166
CGO_CFLAGS += -I$(LOGOS_STORAGE_INC_DIR)
164167
CGO_LDFLAGS += -L$(LOGOS_STORAGE_LIB_DIR) -lstorage -Wl,-rpath,$(LOGOS_STORAGE_LIB_DIR)
165168
RUNTIME_LIB_DIRS := $(LOGOS_STORAGE_LIB_DIR):$(RUNTIME_LIB_DIRS)
166169
LOGOS_STORAGE_BUILD_DEPS += $(LIBSTORAGE)
167170
endif
168171

172+
ifeq ($(USE_TORRENT),true)
173+
override BUILD_TAGS += use_torrent
174+
endif
175+
169176
clone-storage: ##@build Clone or update logos-storage-nim
170177
ifeq ($(LOGOS_STORAGE_BUILD_FROM_SOURCE),true)
171178
@echo "Cloning or updating logos-storage-nim ..."
172179
if [ ! -d "$(LOGOS_STORAGE_SOURCE_DIR)" ]; then \
173-
git clone --recurse-submodules https://github.com/logos-storage/logos-storage-nim.git $(LOGOS_STORAGE_SOURCE_DIR); \
180+
git clone --recurse-submodules https://github.com/logos-storage/logos-storage-nim.git "$(LOGOS_STORAGE_SOURCE_DIR)"; \
174181
else \
175-
cd $(LOGOS_STORAGE_SOURCE_DIR) && git fetch --tags; \
182+
cd "$(LOGOS_STORAGE_SOURCE_DIR)" && git fetch --tags; \
176183
fi
177-
cd $(LOGOS_STORAGE_SOURCE_DIR) && git checkout $(LOGOS_STORAGE_VERSION) && git submodule update --init --recursive
184+
cd "$(LOGOS_STORAGE_SOURCE_DIR)" && \
185+
git switch --force --detach "$(LOGOS_STORAGE_VERSION)" && \
186+
git clean -fdx && \
187+
git submodule update --init --recursive --force
178188
endif
179189

180190
$(LIBSTORAGE): clone-storage
181191
ifeq ($(LOGOS_STORAGE_BUILD_FROM_SOURCE),true)
182192
@echo "Building logos-storage: $(LIBSTORAGE)"
183-
$(MAKE) -C $(LOGOS_STORAGE_SOURCE_DIR) libstorage
193+
$(MAKE) -C $(LOGOS_STORAGE_SOURCE_DIR) libstorage USE_SYSTEM_NIM=$(USE_SYSTEM_NIM) SHELL=$(MAKE_SHELL)
194+
@test -f $(LIBSTORAGE) || (echo "Error: libstorage not found at $(LIBSTORAGE) after build" && exit 1)
195+
else
196+
@test -f $(LIBSTORAGE) || (echo "Error: libstorage not found at $(LIBSTORAGE)" && exit 1)
184197
endif
185198

186199
build-storage: $(LIBSTORAGE)
@@ -190,14 +203,29 @@ ifeq ($(LOGOS_STORAGE_BUILD_FROM_SOURCE),true)
190203
@rm -f "$(LOGOS_STORAGE_LIB_DIR)"/libstorage.*
191204
endif
192205

193-
test-storage: build-storage $(LIBSDS) generate ##@tests Run logosstorage package tests via gotestsum
194-
LD_LIBRARY_PATH="$(LOGOS_STORAGE_LIB_DIR):$(RUNTIME_LIB_DIRS)" \
206+
STORAGE_TEST_ENV := LD_LIBRARY_PATH="$(LOGOS_STORAGE_LIB_DIR):$(RUNTIME_LIB_DIRS)" \
195207
CGO_LDFLAGS="$(CGO_LDFLAGS) -L$(LOGOS_STORAGE_LIB_DIR) -lstorage -Wl,-rpath,$(LOGOS_STORAGE_LIB_DIR)" \
196-
CGO_CFLAGS="$(CGO_CFLAGS) -I$(LOGOS_STORAGE_INC_DIR)" \
197-
gotestsum --packages="./services/logosstorage" -f testname -- -count 1 -tags "use_logos_storage $(BUILD_TAGS) gowaku_skip_migrations"
208+
CGO_CFLAGS="$(CGO_CFLAGS) -I$(LOGOS_STORAGE_INC_DIR)"
209+
STORAGE_TEST_TAGS := use_logos_storage $(BUILD_TAGS) gowaku_skip_migrations
210+
211+
test-storage: build-storage $(LIBSDS) generate ##@tests Run logosstorage package tests via gotestsum
212+
$(STORAGE_TEST_ENV) gotestsum --packages="./services/logosstorage" -f testname -- -count 1 -tags "$(STORAGE_TEST_TAGS)"
213+
$(STORAGE_TEST_ENV) gotestsum --packages="./protocol/communities/archive/logosstorage" -f testname -- -count 1 -tags "$(STORAGE_TEST_TAGS)"
214+
$(STORAGE_TEST_ENV) gotestsum --packages="./protocol" -f testname -- -count 1 -tags "$(STORAGE_TEST_TAGS)" \
215+
-run TestMessengerCommunitiesTokenPermissionsSuite/TestUploadDownloadLogosStorageHistoryArchives
216+
217+
TORRENT_TEST_ENV := LD_LIBRARY_PATH="$(RUNTIME_LIB_DIRS)" \
218+
CGO_LDFLAGS="$(CGO_LDFLAGS)" \
219+
CGO_CFLAGS="$(CGO_CFLAGS)"
220+
TORRENT_TEST_TAGS := $(BUILD_TAGS) use_torrent gowaku_skip_migrations
221+
222+
test-torrent: $(LIBSDS) generate ##@tests Run torrent archive package tests via gotestsum
223+
$(TORRENT_TEST_ENV) gotestsum --packages="./protocol/communities/archive/torrent" -f testname -- -count 1 -tags "$(TORRENT_TEST_TAGS)"
224+
$(TORRENT_TEST_ENV) gotestsum --packages="./protocol" -f testname -- -count 1 -tags "$(TORRENT_TEST_TAGS)" \
225+
-run TestMessengerCommunitiesTokenPermissionsSuite/TestImportDecryptedArchiveMessages
198226

199-
storage-help: ##@build Show logos-storage build/test toggles and env vars
200-
@cat services/logosstorage/README.md
227+
history-archive-help: ##@build Show history archive build/test toggles and env vars
228+
@cat protocol/communities/archive/README.md
201229

202230
# mbedtls configuration for go-sqlcipher
203231
ifeq ($(detected_OS),Windows)
@@ -298,18 +326,22 @@ clone-nim-sds: ##@build Clone or update nim-sds
298326
ifeq ($(NIM_SDS_BUILD_FROM_SOURCE),true)
299327
@echo "Cloning or updating nim-sds ..."
300328
if [ ! -d "$(NIM_SDS_SOURCE_DIR)" ]; then \
301-
git clone https://github.com/waku-org/nim-sds.git $(NIM_SDS_SOURCE_DIR); \
329+
git clone --recurse-submodules https://github.com/waku-org/nim-sds.git "$(NIM_SDS_SOURCE_DIR)"; \
302330
else \
303-
cd $(NIM_SDS_SOURCE_DIR) && git fetch --tags; \
331+
cd "$(NIM_SDS_SOURCE_DIR)" && git fetch --tags; \
304332
fi
305-
cd $(NIM_SDS_SOURCE_DIR) && git checkout $(NIM_SDS_VERSION)
333+
cd "$(NIM_SDS_SOURCE_DIR)" && \
334+
git switch --force --detach "$(NIM_SDS_VERSION)" && \
335+
git clean -fdx && \
336+
git submodule update --init --recursive --force
306337
endif
307338

308339
$(LIBSDS): clone-nim-sds
309340
ifeq ($(NIM_SDS_BUILD_FROM_SOURCE),true)
310341
@echo "Building nim-sds: $(LIBSDS)"
311342
$(MAKE) -C $(NIM_SDS_SOURCE_DIR) update USE_SYSTEM_NIM=$(USE_SYSTEM_NIM)
312343
$(MAKE) -C $(NIM_SDS_SOURCE_DIR) libsds USE_SYSTEM_NIM=$(USE_SYSTEM_NIM) NIMFLAGS=-d:noSignalHandler SHELL=$(MAKE_SHELL)
344+
@test -f $(LIBSDS) || (echo "Error: libsds not found at $(LIBSDS) after build" && exit 1)
313345
else
314346
@test -f $(LIBSDS) || (echo "Error: libsds not found at $(LIBSDS)" && exit 1)
315347
endif
@@ -521,7 +553,7 @@ test-unit: ##@tests Run unit and integration tests
521553

522554
test-single: test-unit-prep
523555
LD_LIBRARY_PATH="$(RUNTIME_LIB_DIRS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" \
524-
go test -v $(PKG) -testify.m $(TEST)
556+
go test -v -tags '$(BUILD_TAGS)' $(PKG) -run '$(TEST)' $(if $(TESTIFY_M),-testify.m '$(TESTIFY_M)')
525557

526558
test-unit-network: test-unit-prep
527559
test-unit-network: export UNIT_TEST_RERUN_FAILS ?= false
@@ -536,6 +568,7 @@ test-functional: generate
536568
test-functional: export FUNCTIONAL_TESTS_DOCKER_UID ?= $(call sh, id -u)
537569
test-functional: export FUNCTIONAL_TESTS_REPORT_CODECOV ?= false
538570
test-functional: export USE_LOGOS_STORAGE := $(USE_LOGOS_STORAGE)
571+
test-functional: export USE_TORRENT := $(USE_TORRENT)
539572
test-functional:
540573
@./scripts/run_functional_tests.sh
541574

@@ -544,7 +577,7 @@ test-functional-compatibility: export FUNCTIONAL_TESTS_DOCKER_UID ?= $(call sh,
544577
test-functional-compatibility: export FUNCTIONAL_TESTS_REPORT_CODECOV ?= false
545578
test-functional-compatibility: export USE_LOGOS_STORAGE := $(USE_LOGOS_STORAGE)
546579
test-functional-compatibility: export FUNCTIONAL_TESTS_MARKER := compatibility
547-
test-functional-compatibility: export FUNCTIONAL_TESTS_RERUNS := 1
580+
test-functional-compatibility: export FUNCTIONAL_TESTS_RERUNS := 6
548581
test-functional-compatibility: ##@tests Cross-version chat compatibility smoke tests (set PEER_IMAGES or PEER_REFS)
549582
@./scripts/run_functional_tests.sh
550583

0 commit comments

Comments
 (0)