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/buildgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}/...
Comment thread
bubunyo marked this conversation as resolved.

- name: Test ${{ matrix.service }}
working-directory: testproject
run: go test -v ./services/${{ matrix.service }}/...
2 changes: 1 addition & 1 deletion action
Submodule action updated 1 files
+18 −5 action.yml
8 changes: 7 additions & 1 deletion cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package cli

import (
"errors"
"log"
"os"
"strings"
Expand Down Expand Up @@ -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)
}
}
Expand Down
55 changes: 34 additions & 21 deletions testproject/.buildgraph/baseline.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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": "",
Expand Down Expand Up @@ -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"
}
]
},
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -278,15 +291,15 @@
},
"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"
]
},
"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"
Expand Down
40 changes: 40 additions & 0 deletions testproject/README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions testproject/core/module-a/foo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "fmt"

func Process(input string) string {
result := Transform(input)
fmt.Println("Syntetic change 3")
Comment thread
bubunyo marked this conversation as resolved.
return result
}

Expand Down
Loading