Skip to content

Commit aeedcb9

Browse files
Merge branch 'main' into unsafe_slice
2 parents c9419cb + 80cf21c commit aeedcb9

100 files changed

Lines changed: 4249 additions & 511 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/cd-dgraph.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ jobs:
8181
badger/badger-linux-amd64.tar.gz
8282
dgraph/dgraph-checksum-linux-amd64.sha256
8383
dgraph/dgraph-linux-amd64.tar.gz
84-
- name: Move Badger Binary into Linux Directory
85-
run: |
86-
tar -xzf badger/badger-linux-amd64.tar.gz --directory badger
87-
[ -d "linux" ] || mkdir linux
88-
# linux directory will be added to docker image in build step
89-
cp badger/badger-linux-amd64 linux/badger
9084
- name: Make Dgraph Docker Image
9185
run: |
9286
set -e
@@ -181,12 +175,6 @@ jobs:
181175
badger/badger-linux-arm64.tar.gz
182176
dgraph/dgraph-checksum-linux-arm64.sha256
183177
dgraph/dgraph-linux-arm64.tar.gz
184-
- name: Move Badger Binary into Linux Directory
185-
run: |
186-
tar -xzf badger/badger-linux-arm64.tar.gz --directory badger
187-
[ -d "linux" ] || mkdir linux
188-
# linux directory will be added to docker image in build step
189-
cp badger/badger-linux-arm64 linux/badger
190178
- name: Make Dgraph Docker Image
191179
run: |
192180
set -e
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: ci-dgraph-nightly-cves
2+
3+
on:
4+
schedule:
5+
- cron: 0 0 * * * # Run daily at midnight UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
cve-scan:
13+
runs-on: blacksmith-4vcpu-ubuntu-2404
14+
timeout-minutes: 30
15+
steps:
16+
- name: Checkout main branch
17+
uses: actions/checkout@v5
18+
with:
19+
ref: main
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v6
23+
with:
24+
go-version-file: go.mod
25+
26+
- name: Build Dgraph
27+
run: make dgraph
28+
29+
- name: Build Docker image
30+
run: |
31+
mkdir -p linux
32+
cp ./dgraph/dgraph ./linux/dgraph
33+
docker build -f contrib/Dockerfile -t dgraph/dgraph:nightly-scan .
34+
35+
- name: Run Trivy vulnerability scanner
36+
uses: aquasecurity/trivy-action@master
37+
with:
38+
image-ref: dgraph/dgraph:nightly-scan
39+
format: table
40+
exit-code: 1
41+
severity: CRITICAL,HIGH

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ x/log_test/*.enc
4848
*.buf
4949
.osgrep
5050
.worktrees/
51+
AGENTS.md
52+
CLAUDE.md

CONTRIBUTING.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
```bash
4141
git clone https://github.com/dgraph-io/dgraph.git
4242
cd ./dgraph
43-
make install
43+
make setup # auto-install tool dependencies (gotestsum, ack, etc.)
44+
make install # build and install the dgraph binary
4445
```
4546

4647
This will put the source code in a Git repo under `$GOPATH/src/github.com/dgraph-io/dgraph` and
@@ -144,16 +145,26 @@ directory, providing control and flexibility beyond the standard Go testing fram
144145
The simplest way to run tests is via Make:
145146

146147
```bash
147-
# Run all tests
148+
# First-time setup: install tool dependencies
149+
make setup
150+
151+
# Run default tests (~30 min): integration suite + integration2
148152
make test
149153

154+
# Run every test in the repo
155+
make test-all
156+
150157
# Run specific test types
151-
make test-unit # Unit tests only (no Docker)
152-
make test-integration2 # Integration2 tests via dgraphtest
153-
make test-upgrade # Upgrade tests
158+
make test-unit # True unit tests only — no Docker, no build tags
159+
make test-integration # Integration tests via t/ runner with Docker
160+
make test-integration-heavy # All heavy tests: systest-heavy + ldbc + load
161+
make test-integration2 # Integration2 tests via dgraphtest
162+
make test-upgrade # Upgrade tests
154163

155164
# Use variables for more control
156165
make test TAGS=integration2 PKG=systest/vector
166+
make test SUITE=all # All t/ runner suites
167+
make test TIMEOUT=90m # Override per-package timeout (default: 30m)
157168
```
158169

159170
Run `make help` to see all available targets and variables.

Makefile

Lines changed: 76 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@ ifeq ($(GOPATH),)
1818
$(error GOPATH is not set. Please set it explicitly, e.g. export GOPATH=$$HOME/go)
1919
endif
2020

21-
# On non-Linux systems, use a separate directory for Linux binaries
21+
# On non-Linux systems, use a separate directory for Linux binaries and
22+
# a cross-compiler so that CGO is available (required for plugin support).
2223
ifeq ($(GOHOSTOS),linux)
2324
export LINUX_GOBIN ?= $(GOPATH)/bin
25+
LINUX_CC ?= gcc
2426
else
2527
export LINUX_GOBIN ?= $(GOPATH)/linux_$(GOHOSTARCH)
28+
ifeq ($(GOHOSTARCH),arm64)
29+
LINUX_CC ?= aarch64-unknown-linux-gnu-gcc
30+
else ifeq ($(GOHOSTARCH),amd64)
31+
LINUX_CC ?= x86_64-unknown-linux-gnu-gcc
32+
else
33+
LINUX_CC ?= gcc
34+
endif
2635
endif
2736

2837
######################
@@ -60,7 +69,7 @@ install: ## Install dgraph binary
6069
ifneq ($(GOHOSTOS),linux)
6170
@mkdir -p $(LINUX_GOBIN)
6271
@echo "Installing dgraph (linux/$(GOHOSTARCH))..."
63-
@GOOS=linux GOARCH=$(GOHOSTARCH) $(MAKE) -C dgraph dgraph
72+
@GOOS=linux GOARCH=$(GOHOSTARCH) CGO_ENABLED=1 CC=$(LINUX_CC) $(MAKE) -C dgraph BUILD_TAGS= EXTLDFLAGS=-fuse-ld=bfd dgraph
6473
@mv dgraph/dgraph $(LINUX_GOBIN)/dgraph
6574
@echo "Installed dgraph (linux/$(GOHOSTARCH)) to $(LINUX_GOBIN)/dgraph"
6675
endif
@@ -73,13 +82,18 @@ uninstall: ## Uninstall dgraph binary
7382

7483
.PHONY: dgraph-installed
7584
dgraph-installed:
76-
@if [ ! -f "$(GOPATH)/bin/dgraph" ] || [ ! -f "$(LINUX_GOBIN)/dgraph" ]; then \
77-
echo "Dgraph binary missing, running make install..."; \
78-
$(MAKE) install; \
79-
fi
85+
$(MAKE) install
86+
87+
.PHONY: check-deps
88+
check-deps: ## Check test dependencies (pass AUTO_INSTALL=true to auto-install missing ones)
89+
$(MAKE) -C t check-deps
90+
91+
.PHONY: setup
92+
setup: ## Install all test dependencies automatically
93+
$(MAKE) check-deps AUTO_INSTALL=true
8094

8195
.PHONY: test
82-
test: dgraph-installed local-image ## Run tests (see 'make help' for options)
96+
test: check-deps dgraph-installed local-image ## Run tests (default: integration + integration2)
8397
ifdef TAGS
8498
@echo "Running tests with tags: $(TAGS)"
8599
go test -v --tags="$(TAGS)" \
@@ -97,62 +111,83 @@ else
97111
done
98112
endif
99113
else
100-
@echo "Running test suite: $(or $(SUITE),all)"
101-
$(MAKE) -C t test args="--suite=$(or $(SUITE),all) $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\")"
114+
ifdef SUITE
115+
@echo "Running test suite: $(SUITE)"
116+
$(MAKE) -C t test args="--suite=$(SUITE) $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\") $(if $(TIMEOUT),--timeout=$(TIMEOUT))"
117+
else
118+
@echo "Running test suite: integration"
119+
$(MAKE) -C t test args="--suite=integration $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\") $(if $(TIMEOUT),--timeout=$(TIMEOUT))"
120+
@echo "Running integration2 tests..."
121+
go test -v --tags="integration2" \
122+
$(if $(TEST),--run="$(TEST)") \
123+
$(if $(PKG),./$(PKG)/...,./...)
124+
endif
102125
endif
103-
104-
.PHONY: test-all
105-
test-all: ## All test suites via t/ runner (i.e. 'make test SUITE=all')
106-
@SUITE=all $(MAKE) test
107126

108127
.PHONY: test-unit
109-
test-unit: ## Unit tests, no Docker (i.e. 'make test SUITE=unit')
128+
test-unit: ## True unit tests only — no Docker, no integration build tag (i.e. 'make test SUITE=unit')
129+
$(if $(filter command line,$(origin SUITE)),$(error SUITE= cannot be passed to test-unit; use 'make test SUITE=...' instead))
110130
@SUITE=unit $(MAKE) test
111131

132+
.PHONY: test-integration
133+
test-integration: ## Integration tests via t/ runner with Docker (i.e. 'make test SUITE=integration')
134+
$(if $(filter command line,$(origin SUITE)),$(error SUITE= cannot be passed to test-integration; use 'make test SUITE=...' instead))
135+
@SUITE=integration $(MAKE) test
136+
112137
.PHONY: test-core
113138
test-core: ## Core tests (i.e. 'make test SUITE=core')
139+
$(if $(filter command line,$(origin SUITE)),$(error SUITE= cannot be passed to test-core; use 'make test SUITE=...' instead))
114140
@SUITE=core $(MAKE) test
115141

116-
.PHONY: test-integration
117-
test-integration: ## Integration tests (i.e. 'make test TAGS=integration')
118-
@TAGS=integration $(MAKE) test
119-
120142
.PHONY: test-integration2
121143
test-integration2: ## Integration2 tests via dgraphtest (i.e. 'make test TAGS=integration2')
144+
$(if $(filter command line,$(origin TAGS)),$(error TAGS= cannot be passed to test-integration2; use 'make test TAGS=...' instead))
122145
@TAGS=integration2 $(MAKE) test
123146

124147
.PHONY: test-upgrade
125148
test-upgrade: ## Upgrade tests (i.e. 'make test TAGS=upgrade')
149+
$(if $(filter command line,$(origin TAGS)),$(error TAGS= cannot be passed to test-upgrade; use 'make test TAGS=...' instead))
126150
@TAGS=upgrade $(MAKE) test
127151

128152
.PHONY: test-systest
129-
test-systest: ## System integration tests (i.e. 'make test SUITE=systest')
153+
test-systest: ## All systest packages: systest-baseline + systest-heavy (i.e. 'make test SUITE=systest')
154+
$(if $(filter command line,$(origin SUITE)),$(error SUITE= cannot be passed to test-systest; use 'make test SUITE=...' instead))
130155
@SUITE=systest $(MAKE) test
131156

157+
.PHONY: test-integration-heavy
158+
test-integration-heavy: ## All heavy tests: systest-heavy + ldbc + load
159+
$(if $(filter command line,$(origin SUITE)),$(error SUITE= cannot be passed to test-integration-heavy; use 'make test SUITE=...' instead))
160+
@SUITE=systest-heavy,ldbc,load $(MAKE) test
161+
132162
.PHONY: test-vector
133163
test-vector: ## Vector search tests (i.e. 'make test SUITE=vector')
164+
$(if $(filter command line,$(origin SUITE)),$(error SUITE= cannot be passed to test-vector; use 'make test SUITE=...' instead))
134165
@SUITE=vector $(MAKE) test
135166

136167
.PHONY: test-fuzz
137-
test-fuzz: ## Fuzz tests, auto-discovers packages (i.e. 'make test FUZZ=1')
168+
test-fuzz: ## Fuzz tests (i.e. 'make test FUZZ=1')
169+
$(if $(filter command line,$(origin FUZZ)),$(error FUZZ= cannot be passed to test-fuzz; use 'make test FUZZ=...' instead))
138170
@FUZZ=1 $(MAKE) test
139171

140-
.PHONY: test-ldbc
141-
test-ldbc: ## LDBC benchmark tests (i.e. 'make test SUITE=ldbc')
142-
@SUITE=ldbc $(MAKE) test
143-
144-
.PHONY: test-load
145-
test-load: ## Heavy load tests (i.e. 'make test SUITE=load')
146-
@SUITE=load $(MAKE) test
172+
.PHONY: test-all
173+
test-all: ## Every test: all t/ suites + integration2 + upgrade + fuzz
174+
$(MAKE) test SUITE=all
175+
$(MAKE) test-integration2
176+
$(MAKE) test-upgrade
177+
$(MAKE) test-fuzz
147178

148179
.PHONY: test-benchmark
149-
test-benchmark: ## Go benchmarks (i.e. 'go test -bench')
180+
test-benchmark: check-deps ## Go benchmarks (i.e. 'go test -bench')
150181
go test -bench=. -benchmem $(if $(PKG),./$(PKG)/...,./...)
151182

152183
.PHONY: local-image
153184
local-image: ## Build local Docker image (dgraph/dgraph:local)
154185
@echo building local docker image
155-
@GOOS=linux GOARCH=amd64 $(MAKE) dgraph
186+
ifneq ($(GOHOSTOS),linux)
187+
@GOOS=linux GOARCH=$(GOHOSTARCH) CGO_ENABLED=1 CC=$(LINUX_CC) $(MAKE) BUILD_TAGS= EXTLDFLAGS=-fuse-ld=bfd dgraph
188+
else
189+
@GOOS=linux GOARCH=$(GOHOSTARCH) $(MAKE) dgraph
190+
endif
156191
@mkdir -p linux
157192
@mv ./dgraph/dgraph ./linux/dgraph
158193
@docker build -f contrib/Dockerfile -t dgraph/dgraph:local .
@@ -161,6 +196,13 @@ local-image: ## Build local Docker image (dgraph/dgraph:local)
161196
.PHONY: image-local
162197
image-local: local-image ## Alias for local-image
163198

199+
.PHONY: clean
200+
clean: ## Clean build artifacts
201+
$(MAKE) -C dgraph clean
202+
$(MAKE) -C compose clean
203+
@rm -rf linux
204+
@go clean -testcache
205+
164206
.PHONY: docker-image
165207
docker-image: dgraph ## Build Docker image (dgraph/dgraph:$VERSION)
166208
@mkdir -p linux
@@ -201,10 +243,11 @@ help: ## Show available targets and variables
201243
awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
202244
@echo ""
203245
@echo "Variables that can be passed to 'test':"
204-
@echo " SUITE Select t/ runner suite (e.g., make test SUITE=systest)"
246+
@echo " SUITE Select t/ runner suite (default: integration + integration2)"
205247
@echo " TAGS Go build tags - bypasses t/ runner (e.g., make test TAGS=integration2)"
206248
@echo " PKG Limit to specific package (e.g., make test PKG=systest/export)"
207249
@echo " TEST Run specific test function (e.g., make test TEST=TestGQLSchema)"
250+
@echo " TIMEOUT Per-package test timeout (e.g., make test TIMEOUT=60m). Default: 30m"
208251
@echo " FUZZ Enable fuzz testing (e.g., make test FUZZ=1)"
209252
@echo " FUZZTIME Fuzz duration per package (e.g., make test FUZZ=1 FUZZTIME=60s)"
210253
@echo ""
@@ -215,12 +258,14 @@ help: ## Show available targets and variables
215258
@printf " Available TAGS values: "
216259
@grep -roh "//go:build [a-z0-9]*" --include="*_test.go" . 2>/dev/null | \
217260
awk '{print $$2}' | \
218-
grep -E '^(integration|integration2|upgrade)$$' | \
261+
grep -E '^(integration2|upgrade)$$' | \
219262
sort -u | tr '\n' ' ' && echo ""
263+
@echo " Note: 'integration' tests require the t/ runner (use SUITE=, not TAGS=)"
220264
@echo ""
221265
@echo "Examples:"
222266
@echo " make test TAGS=integration2 PKG=systest/vector # integration2 tests for vector"
223267
@echo " make test TAGS=upgrade PKG=acl TEST=TestACL # specific upgrade test"
224268
@echo " make test FUZZ=1 PKG=dql FUZZTIME=30s # fuzz dql package for 30s"
225269
@echo " make test SUITE=systest PKG=systest/backup/filesystem # systest for backup pkg"
270+
@echo " make test TIMEOUT=90m # all suites with 90m timeout"
226271
@echo " make test-benchmark PKG=posting # benchmark posting package"

0 commit comments

Comments
 (0)