Skip to content

Commit ce4dfc9

Browse files
committed
Fixing CI failures
1 parent adc26b8 commit ce4dfc9

13 files changed

Lines changed: 116 additions & 65 deletions

‎.github/workflows/dev-setup.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
timeout-minutes: 20
1313
env:
14+
# The runner has podman installed, but only the Docker daemon is running.
15+
# Force the Taskfile's compose engine to docker so it doesn't pick podman.
1416
ENGINE: docker
1517

1618
steps:
@@ -19,6 +21,12 @@ jobs:
1921
- name: Set up Docker Buildx
2022
uses: docker/setup-buildx-action@v3
2123

24+
- name: Install Task
25+
uses: arduino/setup-task@v2
26+
with:
27+
version: 3.x
28+
repo-token: ${{ secrets.GITHUB_TOKEN }}
29+
2230
- name: Prepare dev env file
2331
run: |
2432
cp .env.development.example .env.development
@@ -29,7 +37,7 @@ jobs:
2937
done
3038
3139
- name: Start dev stack
32-
run: make dev-detach
40+
run: task dev-detach
3341

3442
- name: Wait for Rails to be healthy
3543
run: |
@@ -47,7 +55,7 @@ jobs:
4755
exit 1
4856
4957
- name: Run db-reset while stack is running
50-
run: make db-reset
58+
run: task db-reset
5159

5260
- name: Wait for web to restart
5361
run: |
@@ -65,8 +73,8 @@ jobs:
6573
exit 1
6674
6775
- name: Run RSpec tests
68-
run: make test
76+
run: task test
6977

7078
- name: Teardown
7179
if: always()
72-
run: make down
80+
run: task down

‎Taskfile.yml‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3'
22

33
vars:
44
ENGINE:
5-
sh: command -v podman >/dev/null 2>&1 && echo podman || echo docker
5+
sh: echo "${ENGINE:-$(command -v podman >/dev/null 2>&1 && echo podman || echo docker)}"
66
COMPOSE: '{{.ENGINE}} compose --env-file .env.development -f compose.dev.yml'
77
PSQL_IMPORT: "{{.COMPOSE}} exec -T db bash -lc 'psql -v ON_ERROR_STOP=1 -U ${POSTGRES_USER:-hackorum} -d ${POSTGRES_DB:-hackorum_development}'"
88

@@ -54,10 +54,14 @@ tasks:
5454
- '{{.COMPOSE}} exec web bin/rails console'
5555

5656
test:
57-
desc: Run RSpec in the web container (uses test database). Pass args after --, e.g. task test -- spec/models
58-
cmds:
59-
- '{{.COMPOSE}} exec -e RAILS_ENV=test -e DATABASE_URL=postgresql://hackorum:hackorum@db:5432/hackorum_test web bin/rails db:prepare'
60-
- '{{.COMPOSE}} exec -e RAILS_ENV=test -e DATABASE_URL=postgresql://hackorum:hackorum@db:5432/hackorum_test web bundle exec rspec {{.CLI_ARGS}}'
57+
desc: Run RSpec in a one-off container (uses test database). Pass args after --, e.g. task test -- spec/models
58+
cmds:
59+
# Use `run --rm` (a dedicated throwaway container) rather than `exec` into the
60+
# running dev server: that avoids loading rspec on top of the live bin/dev
61+
# process tree, where a foreman/server crash or an OOM victim selection would
62+
# take the exec'd rspec down with it (SIGKILL/exit 137 in CI).
63+
- '{{.COMPOSE}} run --rm -e RAILS_ENV=test -e DATABASE_URL=postgresql://hackorum:hackorum@db:5432/hackorum_test web bin/rails db:prepare'
64+
- '{{.COMPOSE}} run --rm -e RAILS_ENV=test -e DATABASE_URL=postgresql://hackorum:hackorum@db:5432/hackorum_test web bundle exec rspec {{.CLI_ARGS}}'
6165

6266
db-migrate:
6367
desc: Run db:migrate

‎app/services/topic_candidate_search.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def scope
5151

5252
def rank_select
5353
return "0 AS relevance_score" if @q.blank?
54-
Topic.sanitize_sql_array(["ts_rank(topics.title_tsv, websearch_to_tsquery('english', ?)) AS relevance_score", @q])
54+
Topic.sanitize_sql_array([ "ts_rank(topics.title_tsv, websearch_to_tsquery('english', ?)) AS relevance_score", @q ])
5555
end
5656

5757
def apply_text(relation)

‎script/hackorum_commits.rb‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def initialize(path)
105105
def upsert_commit(sha:, subject:, body:, authored_at:, committed_at:,
106106
author_name:, author_email:, committer_name:, committer_email:,
107107
branches:, versions:, stage: "walked")
108-
params = [sha, subject, body, authored_at, committed_at,
108+
params = [ sha, subject, body, authored_at, committed_at,
109109
author_name, author_email, committer_name, committer_email,
110-
JSON.generate(branches), JSON.generate(versions), stage, Time.now.utc.iso8601]
110+
JSON.generate(branches), JSON.generate(versions), stage, Time.now.utc.iso8601 ]
111111
@db.execute(<<~SQL, params)
112112
INSERT INTO commits (sha, subject, body, authored_at, committed_at,
113113
author_name, author_email, committer_name, committer_email,
@@ -119,96 +119,96 @@ def upsert_commit(sha:, subject:, body:, authored_at:, committed_at:,
119119
end
120120

121121
def commit(sha)
122-
@db.execute("SELECT * FROM commits WHERE sha = ?", [sha]).first
122+
@db.execute("SELECT * FROM commits WHERE sha = ?", [ sha ]).first
123123
end
124124

125125
def set_stage(sha, stage)
126126
@db.execute("UPDATE commits SET stage = ?, updated_at = ? WHERE sha = ?",
127-
[stage, Time.now.utc.iso8601, sha])
127+
[ stage, Time.now.utc.iso8601, sha ])
128128
end
129129

130130
def add_relation(from_sha:, to_sha:, kind:, confidence:, method:)
131-
@db.execute(<<~SQL, [from_sha, to_sha, kind, confidence, method])
131+
@db.execute(<<~SQL, [ from_sha, to_sha, kind, confidence, method ])
132132
INSERT OR IGNORE INTO commit_relations (from_sha, to_sha, kind, confidence, method)
133133
VALUES (?,?,?,?,?)
134134
SQL
135135
end
136136

137137
def relations_for(sha)
138-
@db.execute("SELECT * FROM commit_relations WHERE from_sha = ?", [sha])
138+
@db.execute("SELECT * FROM commit_relations WHERE from_sha = ?", [ sha ])
139139
end
140140

141141
def api_cache_get(key)
142-
row = @db.execute("SELECT response FROM api_cache WHERE request_key = ?", [key]).first
142+
row = @db.execute("SELECT response FROM api_cache WHERE request_key = ?", [ key ]).first
143143
row && row["response"]
144144
end
145145

146146
def api_cache_put(key, response)
147147
@db.execute("INSERT OR REPLACE INTO api_cache (request_key, response, fetched_at) VALUES (?,?,?)",
148-
[key, response, Time.now.utc.iso8601])
148+
[ key, response, Time.now.utc.iso8601 ])
149149
end
150150

151151
def add_candidate(sha:, topic_id:, source:, prefilter_score:, metadata:)
152-
@db.execute(<<~SQL, [sha, topic_id, source, prefilter_score, JSON.generate(metadata)])
152+
@db.execute(<<~SQL, [ sha, topic_id, source, prefilter_score, JSON.generate(metadata) ])
153153
INSERT OR REPLACE INTO thread_candidates (sha, topic_id, source, prefilter_score, metadata)
154154
VALUES (?,?,?,?,?)
155155
SQL
156156
end
157157

158158
def candidates_for(sha)
159-
@db.execute("SELECT * FROM thread_candidates WHERE sha = ?", [sha])
159+
@db.execute("SELECT * FROM thread_candidates WHERE sha = ?", [ sha ])
160160
end
161161

162162
def llm_cache_get(key)
163-
row = @db.execute("SELECT response FROM llm_cache WHERE prompt_hash = ?", [key]).first
163+
row = @db.execute("SELECT response FROM llm_cache WHERE prompt_hash = ?", [ key ]).first
164164
row && row["response"]
165165
end
166166

167167
def llm_cache_put(key, response, model)
168168
@db.execute("INSERT OR REPLACE INTO llm_cache (prompt_hash, response, model, created_at) VALUES (?,?,?,?)",
169-
[key, response, model, Time.now.utc.iso8601])
169+
[ key, response, model, Time.now.utc.iso8601 ])
170170
end
171171

172172
def add_link(sha:, topic_id:, mailing_list:, method:, confidence:, verdict:, evidence:, external_message_id:)
173-
@db.execute(<<~SQL, [sha, topic_id, mailing_list, method, confidence, verdict, evidence, external_message_id])
173+
@db.execute(<<~SQL, [ sha, topic_id, mailing_list, method, confidence, verdict, evidence, external_message_id ])
174174
INSERT OR REPLACE INTO thread_links
175175
(sha, topic_id, mailing_list, method, confidence, verdict, evidence, external_message_id)
176176
VALUES (?,?,?,?,?,?,?,?)
177177
SQL
178178
end
179179

180180
def links_for(sha)
181-
@db.execute("SELECT * FROM thread_links WHERE sha = ?", [sha])
181+
@db.execute("SELECT * FROM thread_links WHERE sha = ?", [ sha ])
182182
end
183183

184184
def add_fact(sha:, kind:, value:, method:, confidence:, evidence:)
185-
@db.execute(<<~SQL, [sha, kind, value, method, confidence, evidence])
185+
@db.execute(<<~SQL, [ sha, kind, value, method, confidence, evidence ])
186186
INSERT OR IGNORE INTO commit_facts (sha, kind, value, method, confidence, evidence)
187187
VALUES (?,?,?,?,?,?)
188188
SQL
189189
end
190190

191191
def facts_for(sha)
192-
@db.execute("SELECT * FROM commit_facts WHERE sha = ?", [sha])
192+
@db.execute("SELECT * FROM commit_facts WHERE sha = ?", [ sha ])
193193
end
194194

195195
def each_commit
196196
@db.execute("SELECT * FROM commits ORDER BY committed_at").each { |row| yield row }
197197
end
198198

199199
def each_commit_at_stage(stage)
200-
@db.execute("SELECT * FROM commits WHERE stage = ? ORDER BY committed_at", [stage]).each { |r| yield r }
200+
@db.execute("SELECT * FROM commits WHERE stage = ? ORDER BY committed_at", [ stage ]).each { |r| yield r }
201201
end
202202

203203
def set_message_ids(sha, ids)
204204
ids.each do |id|
205205
@db.execute("INSERT OR IGNORE INTO commit_facts (sha, kind, value, method, confidence, evidence) VALUES (?,?,?,?,?,?)",
206-
[sha, "discussion_message_id", id, "trailer", 1.0, "Discussion: #{id}"])
206+
[ sha, "discussion_message_id", id, "trailer", 1.0, "Discussion: #{id}" ])
207207
end
208208
end
209209

210210
def message_ids_for(sha)
211-
@db.execute("SELECT value FROM commit_facts WHERE sha = ? AND kind = 'discussion_message_id'", [sha])
211+
@db.execute("SELECT value FROM commit_facts WHERE sha = ? AND kind = 'discussion_message_id'", [ sha ])
212212
.map { |r| r["value"] }
213213
end
214214
end
@@ -314,7 +314,7 @@ def default_refs
314314
out = git("for-each-ref", "--format=%(refname:short)", "refs/remotes/origin")
315315
rel = out.lines.map(&:strip).map { |r| r.sub(%r{\Aorigin/}, "") }
316316
.select { |r| r == "master" || r.start_with?("REL") }
317-
(["master"] + rel).uniq
317+
([ "master" ] + rel).uniq
318318
end
319319

320320
def version_for_ref(ref)
@@ -357,7 +357,7 @@ def detect_backport_twins(shas)
357357
row = @store.commit(sha)
358358
next unless row
359359
next if row["subject"].to_s.strip.length < 10 # too generic to match safely
360-
key = [row["subject"], row["author_email"]]
360+
key = [ row["subject"], row["author_email"] ]
361361
by_key[key] << row
362362
end
363363

@@ -376,10 +376,10 @@ def detect_backport_twins(shas)
376376

377377
def list_shas(ref)
378378
args = if ref_exists?("origin/#{ref}")
379-
["rev-list", "origin/#{ref}"]
380-
else
381-
["rev-list", ref]
382-
end
379+
[ "rev-list", "origin/#{ref}" ]
380+
else
381+
[ "rev-list", ref ]
382+
end
383383
args << "--max-count=#{@limit}" if @limit
384384
args << "--since=#{@since}" if @since
385385
git(*args).lines.map(&:strip).reject(&:empty?)
@@ -509,7 +509,7 @@ def discover(commit, facts:, message_ids:)
509509
from, to = date_window(commit["committed_at"])
510510

511511
search_added = 0
512-
[true, false].each do |patches_only|
512+
[ true, false ].each do |patches_only|
513513
hits = @api.search_candidates(q: terms.join(" "), from: from, to: to,
514514
mailing_lists: [], patches_only: patches_only,
515515
limit: @config.candidate_limit)
@@ -626,7 +626,7 @@ def parse_meta(candidate)
626626
end
627627

628628
def build_user_prompt(commit, candidates)
629-
lines = ["COMMIT subject: #{commit['subject']}", "COMMIT body:", commit["body"].to_s, "", "CANDIDATE THREADS:"]
629+
lines = [ "COMMIT subject: #{commit['subject']}", "COMMIT body:", commit["body"].to_s, "", "CANDIDATE THREADS:" ]
630630
candidates.each do |c|
631631
meta = parse_meta(c)
632632
lines << "- topic_id=#{c['topic_id']} lists=#{Array(meta['mailing_lists']).join(',')} " \

‎spec/scripts/hackorum_commits/api_client_spec.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
it "fetches and parses candidate search, caching the second call" do
99
stub = stub_request(:get, "http://hk.test/topics/search_candidates.json")
1010
.with(query: hash_including("q" => "vacuum"))
11-
.to_return(status: 200, body: { candidates: [{ topic_id: 7, title: "T" }] }.to_json,
11+
.to_return(status: 200, body: { candidates: [ { topic_id: 7, title: "T" } ] }.to_json,
1212
headers: { "Content-Type" => "application/json" })
1313

1414
first = client.search_candidates(q: "vacuum", from: "2020-01-01T00:00:00Z",
@@ -25,7 +25,7 @@
2525

2626
it "resolves a message-id, returning nil on 404" do
2727
stub_request(:get, %r{http://hk\.test/messages/by-id/.*\.json})
28-
.to_return(status: 200, body: { topic_id: 9, mailing_lists: ["pgsql-hackers"] }.to_json,
28+
.to_return(status: 200, body: { topic_id: 9, mailing_lists: [ "pgsql-hackers" ] }.to_json,
2929
headers: { "Content-Type" => "application/json" })
3030
expect(client.resolve_message_id("abc@x")["topic_id"]).to eq(9)
3131

‎spec/scripts/hackorum_commits/confirmer_spec.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
let(:commit) { { "sha" => "abc", "subject" => "Fix vacuum", "body" => "details" } }
99
let(:candidates) do
1010
[
11-
{ "topic_id" => 100, "source" => "trailer", "metadata" => { "mailing_lists" => ["pgsql-hackers"] }.to_json },
12-
{ "topic_id" => 200, "source" => "search", "metadata" => { "title" => "vacuum perf", "mailing_lists" => ["pgsql-bugs"] }.to_json }
11+
{ "topic_id" => 100, "source" => "trailer", "metadata" => { "mailing_lists" => [ "pgsql-hackers" ] }.to_json },
12+
{ "topic_id" => 200, "source" => "search", "metadata" => { "title" => "vacuum perf", "mailing_lists" => [ "pgsql-bugs" ] }.to_json }
1313
]
1414
end
1515

@@ -18,7 +18,7 @@
1818
"links" => [
1919
{ "topic_id" => 200, "verdict" => "related", "confidence" => 0.8, "evidence" => "same crash" }
2020
],
21-
"facts" => [{ "kind" => "cve", "value" => "CVE-2025-9999" }]
21+
"facts" => [ { "kind" => "cve", "value" => "CVE-2025-9999" } ]
2222
)
2323

2424
confirmer.confirm(commit, candidates: candidates)

‎spec/scripts/hackorum_commits/discovery_spec.rb‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
subject(:discovery) { described_class.new(config: config, store: store, api: api) }
88

99
it "strips boilerplate and includes contributor names in search terms" do
10-
facts = [{ kind: "author", value: "Dan Dev <dan@x>" }, { kind: "reported_by", value: "Bob <bob@x>" }]
10+
facts = [ { kind: "author", value: "Dan Dev <dan@x>" }, { kind: "reported_by", value: "Bob <bob@x>" } ]
1111
terms = discovery.search_terms(subject: "Fix vacuum throttling bug", facts: facts)
1212
expect(terms).to include("vacuum", "throttling")
1313
expect(terms).not_to include("Fix")
@@ -23,13 +23,13 @@
2323

2424
it "records trailer and search candidates, keeping trailers past the cap" do
2525
allow(api).to receive(:resolve_message_id).with("disc@x")
26-
.and_return({ "topic_id" => 100, "mailing_lists" => ["pgsql-hackers"] })
26+
.and_return({ "topic_id" => 100, "mailing_lists" => [ "pgsql-hackers" ] })
2727
allow(api).to receive(:search_candidates).and_return(
2828
(1..10).map { |i| { "topic_id" => i, "title" => "t#{i}" } }
2929
)
3030

3131
commit = { "sha" => "abc", "subject" => "Fix vacuum", "committed_at" => "2020-06-01T00:00:00Z" }
32-
discovery.discover(commit, facts: [], message_ids: ["disc@x"])
32+
discovery.discover(commit, facts: [], message_ids: [ "disc@x" ])
3333

3434
rows = store.candidates_for("abc")
3535
trailer = rows.select { |r| r["source"] == "trailer" }
@@ -40,7 +40,7 @@
4040

4141
it "trailer candidate wins over search when the same topic_id appears in both" do
4242
allow(api).to receive(:resolve_message_id).with("shared@x")
43-
.and_return({ "topic_id" => 5, "mailing_lists" => ["pgsql-hackers"] })
43+
.and_return({ "topic_id" => 5, "mailing_lists" => [ "pgsql-hackers" ] })
4444
allow(api).to receive(:search_candidates).and_return(
4545
[
4646
{ "topic_id" => 5, "score" => 0.3, "title" => "overlap" },
@@ -50,7 +50,7 @@
5050
)
5151

5252
commit = { "sha" => "def", "subject" => "Fix index vacuum bug", "committed_at" => "2020-06-01T00:00:00Z" }
53-
discovery.discover(commit, facts: [], message_ids: ["shared@x"])
53+
discovery.discover(commit, facts: [], message_ids: [ "shared@x" ])
5454

5555
rows = store.candidates_for("def")
5656
topic5 = rows.find { |r| r["topic_id"] == 5 }
@@ -65,12 +65,12 @@
6565

6666
it "trailer pre-seed does not reduce the search candidate budget" do
6767
allow(api).to receive(:resolve_message_id).with("trailer@x")
68-
.and_return({ "topic_id" => 99, "mailing_lists" => ["pgsql-hackers"] })
68+
.and_return({ "topic_id" => 99, "mailing_lists" => [ "pgsql-hackers" ] })
6969
search_hits = (1..10).map { |i| { "topic_id" => i, "score" => 0.5, "title" => "hit#{i}" } }
7070
allow(api).to receive(:search_candidates).and_return(search_hits, [])
7171

7272
commit = { "sha" => "ghi", "subject" => "Fix index vacuum scan", "committed_at" => "2020-06-01T00:00:00Z" }
73-
discovery.discover(commit, facts: [], message_ids: ["trailer@x"])
73+
discovery.discover(commit, facts: [], message_ids: [ "trailer@x" ])
7474

7575
rows = store.candidates_for("ghi")
7676
trailer = rows.select { |r| r["source"] == "trailer" }

‎spec/scripts/hackorum_commits/exporter_spec.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
authored_at: "2020-01-01", committed_at: "2020-01-02",
1010
author_name: "Dan", author_email: "dan@x",
1111
committer_name: "Andrew", committer_email: "a@x",
12-
branches: ["master", "REL_17_STABLE"], versions: ["devel", "17"])
12+
branches: [ "master", "REL_17_STABLE" ], versions: [ "devel", "17" ])
1313
store.add_fact(sha: "abc", kind: "reviewer", value: "Jane", method: "trailer", confidence: 1.0, evidence: "Reviewed-by: Jane")
1414
store.add_link(sha: "abc", topic_id: 100, mailing_list: "pgsql-hackers", method: "trailer",
1515
confidence: 1.0, verdict: "related", evidence: "trailer", external_message_id: "m@x")
@@ -27,7 +27,7 @@
2727
expect(rec["versions"]).to include("17")
2828
expect(rec["committer"]["name"]).to eq("Andrew")
2929
expect(rec["facts"].map { |f| f["kind"] }).to include("reviewer")
30-
expect(rec["thread_links"].map { |l| l["topic_id"] }).to eq([100])
30+
expect(rec["thread_links"].map { |l| l["topic_id"] }).to eq([ 100 ])
3131
expect(rec["generator"]["tool_version"]).to eq(HackorumCommits::VERSION)
3232
expect(rec["generator"]["model"]).to eq("qwen")
3333
end

0 commit comments

Comments
 (0)