Skip to content

Commit ee5818b

Browse files
authored
Merge pull request #53 from illegalstudio/fix/linux-release-ci
fix(ci): unblock Linux desktop releases
2 parents bf4ca8c + 75f4beb commit ee5818b

2 files changed

Lines changed: 62 additions & 10 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212
goreleaser:
1313
runs-on: macos-latest
1414
steps:
15-
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
15+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1616
with:
1717
fetch-depth: 0
1818

19-
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
19+
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
2020
with:
2121
go-version-file: go.mod
2222

23-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
23+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2424
with:
2525
node-version: 22
2626

@@ -46,7 +46,7 @@ jobs:
4646
security list-keychains -d user -s "$KEYCHAIN_PATH" login.keychain
4747
4848
# Build, sign, archive, publish release, and update Homebrew cask
49-
- uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
49+
- uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
5050
with:
5151
version: "~> v2"
5252
args: release --clean
@@ -152,15 +152,15 @@ jobs:
152152
needs: goreleaser
153153
runs-on: ubuntu-22.04
154154
steps:
155-
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
155+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
156156
with:
157157
fetch-depth: 0
158158

159-
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
159+
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
160160
with:
161161
go-version-file: go.mod
162162

163-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
163+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
164164
with:
165165
node-version: 22
166166
cache: npm

internal/claude/cwdindex_test.go

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"path/filepath"
77
"testing"
8+
"time"
89

910
"github.com/illegalstudio/lazyagent/internal/model"
1011
)
@@ -59,11 +60,13 @@ func TestCWDIndex_HeadHitAvoidsReread(t *testing.T) {
5960
}
6061
}
6162

62-
// TestCWDIndex_InvalidatedOnChange confirms a changed file (different mtime
63-
// and size) is never trusted from a stale entry -- the brief's "use the
63+
// TestCWDIndex_InvalidatedOnSizeChange confirms a changed file with a new
64+
// size is never trusted from a stale entry -- the brief's "use the
6465
// same invalidate-on-change rule for uniformity and safety" requirement for
6566
// claude, even though first-cwd-wins is technically stable across appends.
66-
func TestCWDIndex_InvalidatedOnChange(t *testing.T) {
67+
func TestCWDIndex_InvalidatedOnSizeChange(t *testing.T) {
68+
const replacementCWD = "/tmp/project-b-longer"
69+
6770
dir := t.TempDir()
6871
path := filepath.Join(dir, "session.jsonl")
6972
if err := os.WriteFile(path, []byte(cwdLine("/tmp/project-a")+"\n"), 0o644); err != nil {
@@ -82,14 +85,63 @@ func TestCWDIndex_InvalidatedOnChange(t *testing.T) {
8285
}
8386

8487
// Replace the file with new (different-length) content under a new cwd.
88+
if err := os.WriteFile(path, []byte(cwdLine(replacementCWD)+"\n"), 0o644); err != nil {
89+
t.Fatal(err)
90+
}
91+
info2, err := os.Stat(path)
92+
if err != nil {
93+
t.Fatal(err)
94+
}
95+
mtime2, size2 := info2.ModTime(), info2.Size()
96+
if size2 == size1 {
97+
t.Fatalf("replacement size = %d, want a different size from original %d", size2, size1)
98+
}
99+
100+
cwd, ok = idx.headCWDIndexed(path, mtime2, size2)
101+
if !ok || cwd != replacementCWD {
102+
t.Fatalf("after replace, headCWDIndexed = (%q, %v), want (%s, true) -- the stale project-a entry must not be trusted", cwd, ok, replacementCWD)
103+
}
104+
}
105+
106+
// TestCWDIndex_InvalidatedOnMtimeChange covers the other half of the cache
107+
// key: a same-size rewrite must be detected when only mtime changes. Set the
108+
// timestamp explicitly so the test is reliable on coarse-mtime filesystems.
109+
func TestCWDIndex_InvalidatedOnMtimeChange(t *testing.T) {
110+
dir := t.TempDir()
111+
path := filepath.Join(dir, "session.jsonl")
112+
if err := os.WriteFile(path, []byte(cwdLine("/tmp/project-a")+"\n"), 0o644); err != nil {
113+
t.Fatal(err)
114+
}
115+
info, err := os.Stat(path)
116+
if err != nil {
117+
t.Fatal(err)
118+
}
119+
mtime1, size1 := info.ModTime(), info.Size()
120+
121+
idx := NewCWDIndex()
122+
cwd, ok := idx.headCWDIndexed(path, mtime1, size1)
123+
if !ok || cwd != "/tmp/project-a" {
124+
t.Fatalf("first scan = (%q, %v), want (/tmp/project-a, true)", cwd, ok)
125+
}
126+
85127
if err := os.WriteFile(path, []byte(cwdLine("/tmp/project-b")+"\n"), 0o644); err != nil {
86128
t.Fatal(err)
87129
}
130+
replacementMtime := mtime1.Add(2 * time.Second)
131+
if err := os.Chtimes(path, replacementMtime, replacementMtime); err != nil {
132+
t.Fatal(err)
133+
}
88134
info2, err := os.Stat(path)
89135
if err != nil {
90136
t.Fatal(err)
91137
}
92138
mtime2, size2 := info2.ModTime(), info2.Size()
139+
if size2 != size1 {
140+
t.Fatalf("replacement size = %d, want original size %d", size2, size1)
141+
}
142+
if mtime2.Equal(mtime1) {
143+
t.Fatalf("replacement mtime = %s, want a different mtime from original %s", mtime2, mtime1)
144+
}
93145

94146
cwd, ok = idx.headCWDIndexed(path, mtime2, size2)
95147
if !ok || cwd != "/tmp/project-b" {

0 commit comments

Comments
 (0)