From 580bb375c781875d16948da0b148719edb7f118f Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 03:57:29 +0100 Subject: [PATCH 1/9] fix build pipeline --- .github/workflows/buildgraph.yml | 7 +++++- cli/root.go | 8 ++++++- testproject/README.md | 40 ++++++++++++++++++++++++++++++++ testproject/core/module-a/foo.go | 1 + testproject/core/module-b/bar.go | 2 +- 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 testproject/README.md diff --git a/.github/workflows/buildgraph.yml b/.github/workflows/buildgraph.yml index 01228bb..1b1f306 100644 --- a/.github/workflows/buildgraph.yml +++ b/.github/workflows/buildgraph.yml @@ -37,6 +37,9 @@ jobs: - name: Run BuildGraph id: buildgraph uses: ./action + with: + working-directory: testproject + go-version-file: testproject/go.mod # ── 2. Build affected services ─────────────────────────────────────────────── build: @@ -55,12 +58,14 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version-file: testproject/go.mod cache: true # ── Customize this step to match your project layout ── - name: Build ${{ matrix.service }} + working-directory: testproject run: go build -v -o bin/${{ matrix.service }} ./services/${{ matrix.service }}/... - name: Test ${{ matrix.service }} + working-directory: testproject run: go test -v ./services/${{ matrix.service }}/... diff --git a/cli/root.go b/cli/root.go index 3cc3b91..8c5ea90 100644 --- a/cli/root.go +++ b/cli/root.go @@ -3,6 +3,7 @@ package cli import ( + "errors" "log" "os" "strings" @@ -64,7 +65,12 @@ func initConfig() { viper.SetDefault("exclude.patterns", defaults.Exclude.Patterns) if err := viper.ReadInConfig(); err != nil { - if _, ok := err.(viper.ConfigFileNotFoundError); !ok { + // When SetConfigFile is used, viper returns a plain *fs.PathError for + // a missing file — not viper.ConfigFileNotFoundError (which is only + // returned when searching via SetConfigName/AddConfigPath). Use + // errors.Is(err, os.ErrNotExist) to correctly catch the missing-file + // case and only fatal on genuine read errors (bad permissions, etc.). + if !errors.Is(err, os.ErrNotExist) { log.Fatalf("error reading config file %s: %v", cfgFile, err) } } diff --git a/testproject/README.md b/testproject/README.md new file mode 100644 index 0000000..147a227 --- /dev/null +++ b/testproject/README.md @@ -0,0 +1,40 @@ +# testproject + +A minimal Go monorepo used as a fixture for `pkg/analyzer` integration tests +and as the target project for the BuildGraph CI workflow. + +## Structure + +``` +testproject/ +├── buildgraph.yaml # BuildGraph config — scans services/ +├── go.mod # module: github.com/bubunyo/buildgraph/testproject +├── core/ +│ ├── module-a/ # Shared library used by both services +│ │ └── foo.go # Process(), Fetch(), Transform() +│ └── module-b/ # Shared library used only by service-a +│ └── bar.go # Save(), Delete() +└── services/ + ├── service-a/ # Depends on module-a and module-b + │ └── main.go # Calls module_a.Process → module_b.Save + └── service-b/ # Depends on module-a only + └── main.go # Calls module_a.Fetch, module_a.Transform +``` + +## Dependency graph + +``` +service-a → module-a (Process, via Transform) +service-a → module-b (Save) +service-b → module-a (Fetch, Transform) +``` + +Because `module-a` is shared, a change there will cause **both** services to +be flagged for rebuild. A change to `module-b` only affects `service-a`. +`service-b` is isolated from `module-b` entirely. + +## What tests it + +The `pkg/analyzer` integration tests load this project via `go/packages` to +exercise the full analysis pipeline — call graph construction, hash +computation, and source hash caching — against real Go source. diff --git a/testproject/core/module-a/foo.go b/testproject/core/module-a/foo.go index faa5aa9..4601a2f 100644 --- a/testproject/core/module-a/foo.go +++ b/testproject/core/module-a/foo.go @@ -4,6 +4,7 @@ import "fmt" func Process(input string) string { result := Transform(input) + fmt.Println("Syntetic change") return result } diff --git a/testproject/core/module-b/bar.go b/testproject/core/module-b/bar.go index 982a1be..35f805d 100644 --- a/testproject/core/module-b/bar.go +++ b/testproject/core/module-b/bar.go @@ -8,6 +8,6 @@ func Save(data string) error { } func Delete(id string) error { - fmt.Println("Deleting:", id) + fmt.Println("Deleting: ", id) return nil } From 61fa6c82606f8e149b3cf1ae135b111c77cf2820 Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 03:59:00 +0100 Subject: [PATCH 2/9] add build trigger --- testproject/core/module-a/foo.go | 3 +++ testproject/core/module-b/bar.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/testproject/core/module-a/foo.go b/testproject/core/module-a/foo.go index 4601a2f..8b9baa4 100644 --- a/testproject/core/module-a/foo.go +++ b/testproject/core/module-a/foo.go @@ -3,15 +3,18 @@ package module_a import "fmt" func Process(input string) string { + _ = 1 result := Transform(input) fmt.Println("Syntetic change") return result } func Fetch() string { + _ = 1 return "data" } func Transform(data string) string { + _ = 1 return fmt.Sprintf("processed and transformed: %s", data) } diff --git a/testproject/core/module-b/bar.go b/testproject/core/module-b/bar.go index 35f805d..870744d 100644 --- a/testproject/core/module-b/bar.go +++ b/testproject/core/module-b/bar.go @@ -3,11 +3,13 @@ package module_b import "fmt" func Save(data string) error { + _ = 1 fmt.Println("Saving:", data) return nil } func Delete(id string) error { + _ = 1 fmt.Println("Deleting: ", id) return nil } From eb20a183665091ed92e356c6b034bafcd11b04c8 Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 04:07:03 +0100 Subject: [PATCH 3/9] minor change --- testproject/core/module-a/foo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testproject/core/module-a/foo.go b/testproject/core/module-a/foo.go index 8b9baa4..fc8e146 100644 --- a/testproject/core/module-a/foo.go +++ b/testproject/core/module-a/foo.go @@ -3,7 +3,7 @@ package module_a import "fmt" func Process(input string) string { - _ = 1 + _ = 2 result := Transform(input) fmt.Println("Syntetic change") return result From 9de59e7269a7c8b389b5b995b4b36c9a46b16248 Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 04:18:05 +0100 Subject: [PATCH 4/9] new generate --- testproject/.buildgraph/baseline.json | 55 +++++++++++++++++---------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/testproject/.buildgraph/baseline.json b/testproject/.buildgraph/baseline.json index 5c30400..107fa30 100644 --- a/testproject/.buildgraph/baseline.json +++ b/testproject/.buildgraph/baseline.json @@ -1,7 +1,7 @@ { "version": "1.0", - "generated_at": "2026-03-07T16:37:56.954428+01:00", - "commit": "7f06877b7034f2f5d047264c051f10a1ba2c608f", + "generated_at": "2026-03-08T04:17:49.934595+01:00", + "commit": "eb20a183665091ed92e356c6b034bafcd11b04c8", "go_version": "go1.24.2", "module_path": "github.com/bubunyo/buildgraph/testproject", "graph": { @@ -11,8 +11,8 @@ "full_name": "github.com/bubunyo/buildgraph/testproject/core/module-a.Fetch", "package": "github.com/bubunyo/buildgraph/testproject/core/module-a", "file": "core/module-a/foo.go", - "start_line": 10, - "end_line": 10, + "start_line": 12, + "end_line": 12, "is_exported": true, "is_main": false, "ast_hash": "", @@ -41,6 +41,17 @@ "type": "internal", "name": "Transform", "full_name": "github.com/bubunyo/buildgraph/testproject/core/module-a.Transform" + }, + { + "package": { + "path": "fmt", + "name": "fmt", + "version": "", + "module": "fmt" + }, + "type": "external", + "name": "Println", + "full_name": "fmt.Println" } ] }, @@ -49,8 +60,8 @@ "full_name": "github.com/bubunyo/buildgraph/testproject/core/module-a.Transform", "package": "github.com/bubunyo/buildgraph/testproject/core/module-a", "file": "core/module-a/foo.go", - "start_line": 14, - "end_line": 14, + "start_line": 17, + "end_line": 17, "is_exported": true, "is_main": false, "ast_hash": "", @@ -74,8 +85,8 @@ "full_name": "github.com/bubunyo/buildgraph/testproject/core/module-b.Delete", "package": "github.com/bubunyo/buildgraph/testproject/core/module-b", "file": "core/module-b/bar.go", - "start_line": 10, - "end_line": 10, + "start_line": 11, + "end_line": 11, "is_exported": true, "is_main": false, "ast_hash": "", @@ -222,8 +233,8 @@ "github.com/bubunyo/buildgraph/testproject/services/service-a.main" ], "github.com/bubunyo/buildgraph/testproject/core/module-a.Transform": [ - "github.com/bubunyo/buildgraph/testproject/services/service-b.main", - "github.com/bubunyo/buildgraph/testproject/core/module-a.Process" + "github.com/bubunyo/buildgraph/testproject/core/module-a.Process", + "github.com/bubunyo/buildgraph/testproject/services/service-b.main" ], "github.com/bubunyo/buildgraph/testproject/core/module-b.Save": [ "github.com/bubunyo/buildgraph/testproject/services/service-a.main" @@ -241,28 +252,30 @@ }, "function_hashes": { "github.com/bubunyo/buildgraph/testproject/core/module-a.Fetch": { - "ast_hash": "sha256:5327810cfd8a408b88efe27f692bf8e9bf2dfa04b305eeb318f69d30dceff7e3", - "transitive_hash": "sha256:bb4d99c46014d97034fb67690a66d43290fa35904e3613f4665d3bd61876373e", + "ast_hash": "sha256:3021ccf5567e3c72f785030c2051fcf0b781826084b2d7682040fa1306677a22", + "transitive_hash": "sha256:d20792fcba5f1ab337e8084c060562e81531e21f93a4d2a70b98daa973f49669", "deps_hash": "", "external_deps": null }, "github.com/bubunyo/buildgraph/testproject/core/module-a.Process": { - "ast_hash": "sha256:d875a15f77128861bcaf64e487f4c1313363f8a3746f6f20fa05b285fe9758fc", - "transitive_hash": "sha256:c4a9866cb819111932045fbcca32e5e16dd256d02df6e09915a5bf5a57c7efcc", + "ast_hash": "sha256:7e3acc042a595f937d69d71d830bead9b5a8fecf80eb712fd560862b144013a9", + "transitive_hash": "sha256:cb63b3f89736f46e972dad5d870c9d436d1856307f54486458116de770ad02e2", "deps_hash": "", - "external_deps": null + "external_deps": [ + "fmt" + ] }, "github.com/bubunyo/buildgraph/testproject/core/module-a.Transform": { - "ast_hash": "sha256:9eb1c193ecb1cd9466b59b73e568bfbe94a329dddc40618d0c4252771900436e", - "transitive_hash": "sha256:9d796685935eb3e31f60e7fc5329cccac208714a92b8127c1d0d85e2fbf3ace0", + "ast_hash": "sha256:2479b9059a0497952bb56c013f24aa0514ee9f685be16b6920252d29c64215a3", + "transitive_hash": "sha256:62b22b56e613ee61695a05c6a8cfd481f400653e9e5c7b805d7719f8ae031b76", "deps_hash": "", "external_deps": [ "fmt" ] }, "github.com/bubunyo/buildgraph/testproject/core/module-b.Delete": { - "ast_hash": "sha256:2f493b90b3b1eccda25859e3e3b25c2042bba69fbf6c258a96d844262078851d", - "transitive_hash": "sha256:2e0f94d48b710de5db0de8cecb9cac3ac002ba88428d70d8848534eac7c0272c", + "ast_hash": "sha256:32a122d9d36f00b8d0b164a36ef8240f67cd698e6bbc6783b351128483c9c389", + "transitive_hash": "sha256:4b3161289620ba7dfc7fd712a9873d62d9f7e1f11a3fa91f53f8eb2d5e855cdd", "deps_hash": "", "external_deps": [ "fmt" @@ -278,7 +291,7 @@ }, "github.com/bubunyo/buildgraph/testproject/services/service-a.main": { "ast_hash": "sha256:1a597aedbc5452adebf65614dd3e540a46c94ca959fad3d20a8702ec4b6ad934", - "transitive_hash": "sha256:f845f9cde7af38e09553571c2f1284da87b9123005fb9c51d1b6c45c4397281c", + "transitive_hash": "sha256:c0777cdd121ac0357fdfd9dd1bb37c67dcc06942e9bc2e575a45885e870f79f9", "deps_hash": "", "external_deps": [ "fmt" @@ -286,7 +299,7 @@ }, "github.com/bubunyo/buildgraph/testproject/services/service-b.main": { "ast_hash": "sha256:9cee7f741285afcc51ac1c37c1e34fd3880420f417a3d374091911e1187b2a13", - "transitive_hash": "sha256:12bad9e597d8dd6c250994783344a2510e6125b958031625b7778beb2b2834bd", + "transitive_hash": "sha256:091b00e1706de1df7463c31567025ba5f3f831224961a8f512802adcdedc46d2", "deps_hash": "", "external_deps": [ "fmt" From 1995820a459dc196c7dcf039c5bf5227b8c52490 Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 04:22:50 +0100 Subject: [PATCH 5/9] change set sorks --- testproject/core/module-a/foo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testproject/core/module-a/foo.go b/testproject/core/module-a/foo.go index fc8e146..0d2d2c0 100644 --- a/testproject/core/module-a/foo.go +++ b/testproject/core/module-a/foo.go @@ -3,9 +3,9 @@ package module_a import "fmt" func Process(input string) string { - _ = 2 + _ = 3 result := Transform(input) - fmt.Println("Syntetic change") + fmt.Println("Syntetic change 3") return result } From 0aa15ceff50b6a270c035e1579e48c022017c581 Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 04:39:25 +0100 Subject: [PATCH 6/9] update actions --- action | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action b/action index 19970eb..5d7e7c5 160000 --- a/action +++ b/action @@ -1 +1 @@ -Subproject commit 19970eb3bc406129b95d7e8837b88e64b22f4c1e +Subproject commit 5d7e7c5d812dcb4aedea290987924681e5da66e1 From 76ee7c96b3c9c2630e1841cf193974d54bc48316 Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 04:42:28 +0100 Subject: [PATCH 7/9] clean up --- testproject/core/module-a/foo.go | 3 --- testproject/core/module-b/bar.go | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/testproject/core/module-a/foo.go b/testproject/core/module-a/foo.go index 0d2d2c0..0ef196c 100644 --- a/testproject/core/module-a/foo.go +++ b/testproject/core/module-a/foo.go @@ -3,18 +3,15 @@ package module_a import "fmt" func Process(input string) string { - _ = 3 result := Transform(input) fmt.Println("Syntetic change 3") return result } func Fetch() string { - _ = 1 return "data" } func Transform(data string) string { - _ = 1 return fmt.Sprintf("processed and transformed: %s", data) } diff --git a/testproject/core/module-b/bar.go b/testproject/core/module-b/bar.go index 870744d..982a1be 100644 --- a/testproject/core/module-b/bar.go +++ b/testproject/core/module-b/bar.go @@ -3,13 +3,11 @@ package module_b import "fmt" func Save(data string) error { - _ = 1 fmt.Println("Saving:", data) return nil } func Delete(id string) error { - _ = 1 - fmt.Println("Deleting: ", id) + fmt.Println("Deleting:", id) return nil } From 27be105be94ff5dc6115d33116a8a7909e18fbfd Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 04:47:58 +0100 Subject: [PATCH 8/9] trigger deploy and push to stage From 1b13998aa11b05834710e713777d2e8fba21d7a8 Mon Sep 17 00:00:00 2001 From: Bubunyo Nyavor Date: Sun, 8 Mar 2026 04:52:51 +0100 Subject: [PATCH 9/9] updat action --- action | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action b/action index 5d7e7c5..d540b64 160000 --- a/action +++ b/action @@ -1 +1 @@ -Subproject commit 5d7e7c5d812dcb4aedea290987924681e5da66e1 +Subproject commit d540b64e26dc195256b424d21ee2f4d95faf0820