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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Configure git identity
run: |
git config --global user.name "CI"
git config --global user.email "ci@test"

# Persist Bazel's disk cache (see .bazelrc: --disk_cache) across runs. The
# integration test drives nested `bazel query` against the repo itself; a
# integration test drives nested `bazel query` against a fixture repo; a
# cold cache makes the first GetChangedTargets pay the full analysis cost
# and pushes the run against its deadline. Warming it removes that spike
# and speeds every run. restore-keys lets a stale cache seed a new one.
Expand Down
37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build cover test test-integration bench lint proto gazelle clean clean-proto run-server run-client-get-graph run-client-changed-targets version help
.PHONY: build cover test test-integration test-integration-tgb test-integration-gob bench lint proto gazelle clean clean-proto run-server run-client-get-graph run-client-changed-targets version help

# Bazel wrapper
BAZEL = ./tools/bazel
Expand All @@ -15,11 +15,32 @@ test:
@$(BAZEL) test //...
@echo "All tests passed!"

# Run integration tests (requires bazel; may take several minutes)
test-integration:
@echo "Running integration tests..."
@$(BAZEL) test //integration:integration_test --test_output=errors --test_env=TANGO_REPO_REMOTE=$$(git rev-parse --show-toplevel) --test_env=HOME=$$HOME
@echo "Integration tests passed!"
FIXTURE_REMOTE ?= https://github.com/xytan0056/bazel-fixture.git
FIXTURE_BASE_SHA ?= 0d79296cfd507440f536ea01e626b294d74d19a8
FIXTURE_HEAD_SHA ?= b5f81eb872dfcbe4c13131a73367122eb2d92065
FIXTURE_PR_URL ?= github://github.com/xytan0056/bazel-fixture/pull/2/$(FIXTURE_HEAD_SHA)

INTEGRATION_ENV = \
--test_env=HOME=$$HOME \
--test_env=TANGO_REPO_REMOTE=$(FIXTURE_REMOTE) \
--test_env=TANGO_BASE_SHA=$(FIXTURE_BASE_SHA) \
--test_env=TANGO_HEAD_SHA=$(FIXTURE_HEAD_SHA) \
--test_env=TANGO_PR_URL=$(FIXTURE_PR_URL)

# Run integration tests with both graph formats
test-integration: test-integration-tgb test-integration-gob

test-integration-tgb:
@echo "Running integration tests (tgb)..."
@$(BAZEL) test //integration:integration_test --test_output=errors \
$(INTEGRATION_ENV) --test_env=TANGO_GRAPH_FORMAT=tgb
@echo "Integration tests (tgb) passed!"

test-integration-gob:
@echo "Running integration tests (gob)..."
@$(BAZEL) test //integration:integration_test --test_output=errors \
$(INTEGRATION_ENV) --test_env=TANGO_GRAPH_FORMAT=gob
@echo "Integration tests (gob) passed!"

# Run GetChangedTargets benchmarks against fixed, checked-in commit pairs.
# Measurement only: not part of `make test` / `make test-integration` and not
Expand Down Expand Up @@ -116,7 +137,9 @@ help:
@echo "Build & Test:"
@echo " make build - Build all targets"
@echo " make test - Run all tests"
@echo " make test-integration - Run integration tests (slow)"
@echo " make test-integration - Run integration tests with both formats (needs network, slow)"
@echo " make test-integration-tgb - Run integration tests with TGB format"
@echo " make test-integration-gob - Run integration tests with gob format"
@echo " make bench - Run GetChangedTargets benchs (measurement only, not in CI)"
@echo " make lint - Run golangci-lint"
@echo " make gazelle - Update BUILD.bazel files"
Expand Down
12 changes: 6 additions & 6 deletions integration/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"go.uber.org/zap/zapcore"
)

// coldCommitPairs are distinct consecutive commit pairs from repo history.
// coldCommitPairs are distinct consecutive commit pairs from tango repo history.
// Each pair produces a unique treehash, guaranteeing a cache miss per call.
var coldCommitPairs = []struct{ first, second string }{
{"57162624a45965a7e783072c56561f91c5d4084d", "74d1cd55155e5f4f43aa92b4e0146a0c528a0d96"},
Expand Down Expand Up @@ -54,7 +54,7 @@ func BenchmarkGetChangedTargets_Cold(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
pair := coldCommitPairs[i]
getChangedTargets(b, client, remote, pair.first, pair.second)
getChangedTargets(b, client, buildDesc(remote, pair.first), buildDesc(remote, pair.second))
}
}

Expand All @@ -67,13 +67,13 @@ func BenchmarkGetChangedTargets_Cached(b *testing.B) {
addr := startServerWithLogger(b, remote, logger)
client := newClient(b, addr)

firstSHA := "57162624a45965a7e783072c56561f91c5d4084d"
secondSHA := "74d1cd55155e5f4f43aa92b4e0146a0c528a0d96"
first := buildDesc(remote, "57162624a45965a7e783072c56561f91c5d4084d")
second := buildDesc(remote, "74d1cd55155e5f4f43aa92b4e0146a0c528a0d96")

getChangedTargets(b, client, remote, firstSHA, secondSHA)
getChangedTargets(b, client, first, second)

b.ResetTimer()
for i := 0; i < b.N; i++ {
getChangedTargets(b, client, remote, firstSHA, secondSHA)
getChangedTargets(b, client, first, second)
}
}
Loading
Loading