Skip to content

Commit 1d10426

Browse files
authored
Merge pull request #2039 from dolthub/elian/1374
Fix test expectations to include new author columns
2 parents 9313c0e + d01459e commit 1d10426

17 files changed

Lines changed: 581 additions & 57 deletions

File tree

.github/workflows/regression-tests.yml

Lines changed: 171 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,67 +11,181 @@ permissions:
1111
contents: read
1212
pull-requests: write
1313

14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
16+
cancel-in-progress: true
17+
1418
jobs:
15-
regression-tests:
19+
resolve-main:
20+
name: Resolve main
21+
runs-on: ubuntu-latest
22+
outputs:
23+
main_sha: ${{ steps.resolve.outputs.main_sha }}
24+
25+
steps:
26+
- name: Checkout DoltgreSQL
27+
uses: actions/checkout@v6
28+
with:
29+
ref: main
30+
31+
- name: Resolve main SHA
32+
id: resolve
33+
run: echo "main_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
34+
35+
pr-regression:
36+
name: PR regression
1637
runs-on: ubuntu-latest
38+
needs: resolve-main
1739

1840
steps:
1941
- name: Checkout DoltgreSQL
2042
uses: actions/checkout@v6
2143
with:
2244
ref: ${{ github.event.pull_request.head.sha }}
45+
fetch-depth: 0
2346

2447
- name: Setup Git User
2548
uses: fregante/setup-git-user@v2
2649

27-
- name: Merge main into PR
28-
id: merge_main
50+
- name: Merge base into PR
2951
run: |
30-
git fetch --all --unshallow
31-
git merge origin/main --no-commit --no-ff
32-
if [ $? -ne 0 ]; then
33-
echo "Skipping the remainder of the workflow due to a merge conflict."
34-
echo "skip=true" >> $GITHUB_OUTPUT
35-
else
36-
echo "Merge performed successfully, continuing workflow."
37-
echo "skip=false" >> $GITHUB_OUTPUT
38-
fi
52+
git fetch origin ${{ needs.resolve-main.outputs.main_sha }}
53+
git merge ${{ needs.resolve-main.outputs.main_sha }} --no-commit --no-ff
3954
4055
- name: Install Go
4156
uses: actions/setup-go@v5
42-
if: steps.merge_main.outputs.skip == 'false'
4357
with:
4458
go-version-file: go.mod
59+
cache: true
4560

4661
- name: Test PR branch
47-
id: test_doltgresql_pr
48-
if: steps.merge_main.outputs.skip == 'false'
4962
continue-on-error: true
5063
run: |
5164
./postgres/parser/build.sh
5265
cd testing/go/regression
5366
mkdir -p out
67+
{
68+
echo "pr_head=${{ github.event.pull_request.head.sha }}"
69+
echo "main_head=${{ needs.resolve-main.outputs.main_sha }}"
70+
echo "merge_base=$(git merge-base HEAD ${{ needs.resolve-main.outputs.main_sha }})"
71+
git status --short --branch
72+
git diff --cached --stat
73+
go version
74+
go env
75+
go list -m github.com/dolthub/dolt/go github.com/dolthub/go-mysql-server
76+
} > out/pr-metadata.txt
5477
cd tool
55-
go test --timeout=90m ./... --count=1
56-
cp ../out/results.trackers ../out/results2.trackers
78+
set +e
79+
go test --timeout=90m ./... --count=1 2>&1 | tee ../out/pr-go-test.log
80+
test_status=${PIPESTATUS[0]}
81+
set -e
82+
if [ -f ../out/results.trackers ]; then
83+
cp ../out/results.trackers ../out/results2.trackers
84+
fi
85+
exit "$test_status"
86+
87+
- name: Upload PR regression artifacts
88+
if: always()
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: regression-pr-${{ github.run_id }}-${{ github.run_attempt }}
92+
path: |
93+
testing/go/regression/out/results2.trackers
94+
testing/go/regression/out/pr-go-test.log
95+
testing/go/regression/out/pr-metadata.txt
96+
if-no-files-found: warn
97+
retention-days: 14
98+
compression-level: 0
99+
100+
main-regression:
101+
name: Main regression
102+
runs-on: ubuntu-latest
103+
needs: resolve-main
104+
105+
steps:
106+
- name: Checkout DoltgreSQL
107+
uses: actions/checkout@v6
108+
with:
109+
ref: ${{ needs.resolve-main.outputs.main_sha }}
110+
111+
- name: Install Go
112+
uses: actions/setup-go@v5
113+
with:
114+
go-version-file: go.mod
115+
cache: true
57116

58117
- name: Test main branch
59-
id: test_doltgresql_main
60-
if: steps.merge_main.outputs.skip == 'false'
61118
continue-on-error: true
62119
run: |
63-
git reset --hard
64-
git checkout origin/main
65120
./postgres/parser/build.sh
66121
cd testing/go/regression
67122
mkdir -p out
123+
{
124+
echo "main_head=${{ needs.resolve-main.outputs.main_sha }}"
125+
git status --short --branch
126+
go version
127+
go env
128+
go list -m github.com/dolthub/dolt/go github.com/dolthub/go-mysql-server
129+
} > out/main-metadata.txt
68130
cd tool
69-
go test --timeout=90m ./... --count=1
70-
cp ../out/results.trackers ../out/results1.trackers
131+
set +e
132+
go test --timeout=90m ./... --count=1 2>&1 | tee ../out/main-go-test.log
133+
test_status=${PIPESTATUS[0]}
134+
set -e
135+
if [ -f ../out/results.trackers ]; then
136+
cp ../out/results.trackers ../out/results1.trackers
137+
fi
138+
exit "$test_status"
139+
140+
- name: Upload main regression artifacts
141+
if: always()
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: regression-main-${{ github.run_id }}-${{ github.run_attempt }}
145+
path: |
146+
testing/go/regression/out/results1.trackers
147+
testing/go/regression/out/main-go-test.log
148+
testing/go/regression/out/main-metadata.txt
149+
if-no-files-found: warn
150+
retention-days: 14
151+
compression-level: 0
152+
153+
regression-tests:
154+
runs-on: ubuntu-latest
155+
needs:
156+
- resolve-main
157+
- pr-regression
158+
- main-regression
159+
if: always() && needs.pr-regression.result != 'cancelled' && needs.main-regression.result != 'cancelled'
160+
161+
steps:
162+
- name: Checkout DoltgreSQL
163+
uses: actions/checkout@v6
164+
with:
165+
ref: ${{ needs.resolve-main.outputs.main_sha }}
166+
167+
- name: Install Go
168+
uses: actions/setup-go@v5
169+
with:
170+
go-version-file: go.mod
171+
cache: true
172+
173+
- name: Download PR regression artifacts
174+
uses: actions/download-artifact@v4
175+
continue-on-error: true
176+
with:
177+
name: regression-pr-${{ github.run_id }}-${{ github.run_attempt }}
178+
path: testing/go/regression/out
179+
180+
- name: Download main regression artifacts
181+
uses: actions/download-artifact@v4
182+
continue-on-error: true
183+
with:
184+
name: regression-main-${{ github.run_id }}-${{ github.run_attempt }}
185+
path: testing/go/regression/out
71186

72187
- name: Check result trackers
73188
id: check_trackers
74-
if: steps.merge_main.outputs.skip == 'false'
75189
run: |
76190
cd testing/go/regression/out
77191
if [[ -f "results1.trackers" && -f "results2.trackers" ]]; then
@@ -80,20 +194,35 @@ jobs:
80194
else
81195
echo "trackers_exist=false" >> $GITHUB_OUTPUT
82196
echo "One of the branches could not successfully complete their tests."
83-
echo "Please review them for errors, which must be fixed."
197+
echo "Please review uploaded regression artifacts for errors, which must be fixed."
84198
exit 1
85199
fi
86200
87201
- name: Build Regression Test Results Comment
88202
id: build_results
89203
if: steps.check_trackers.outputs.trackers_exist == 'true'
90204
run: |
205+
./postgres/parser/build.sh
91206
cd testing/go/regression/tool
92-
output=$(go run . results1.trackers results2.trackers)
93-
echo "program_output<<EOF" >> $GITHUB_OUTPUT
94-
echo "$output" >> $GITHUB_OUTPUT
95-
echo "EOF" >> $GITHUB_OUTPUT
96-
echo "$output"
207+
# Pass via file, not $GITHUB_OUTPUT: large output through env trips ARG_MAX in github-script.
208+
go run . results1.trackers results2.trackers > "$RUNNER_TEMP/regression-comment.md"
209+
cp "$RUNNER_TEMP/regression-comment.md" ../out/regression-comment.md
210+
cat "$RUNNER_TEMP/regression-comment.md"
211+
if [ -s "$RUNNER_TEMP/regression-comment.md" ]; then
212+
echo "has_output=true" >> "$GITHUB_OUTPUT"
213+
else
214+
echo "has_output=false" >> "$GITHUB_OUTPUT"
215+
fi
216+
217+
- name: Upload comparison artifacts
218+
if: always()
219+
uses: actions/upload-artifact@v4
220+
with:
221+
name: regression-comparison-${{ github.run_id }}-${{ github.run_attempt }}
222+
path: testing/go/regression/out/regression-comment.md
223+
if-no-files-found: warn
224+
retention-days: 14
225+
compression-level: 0
97226

98227
- name: Is PR From Fork
99228
id: from_fork
@@ -107,16 +236,23 @@ jobs:
107236
fi
108237
109238
- name: Post Comment
110-
if: steps.from_fork.outputs.fork == 'false' && steps.build_results.outputs.program_output
111-
uses: actions/github-script@v6
239+
if: steps.from_fork.outputs.fork == 'false' && steps.build_results.outputs.has_output == 'true'
240+
uses: actions/github-script@v7
112241
env:
113-
PROGRAM_OUTPUT: ${{ steps.build_results.outputs.program_output }}
242+
COMMENT_PATH: ${{ runner.temp }}/regression-comment.md
114243
with:
115244
github-token: ${{ secrets.GITHUB_TOKEN }}
116245
script: |
246+
const fs = require('fs')
117247
const commentMarker = '<!-- go-run-output -->'
118-
const output = process.env.PROGRAM_OUTPUT
119-
const body = `${commentMarker}\n${output}`
248+
// GitHub caps comment bodies at 65536 chars.
249+
const MAX_BODY = 65000
250+
let output = fs.readFileSync(process.env.COMMENT_PATH, 'utf8')
251+
let body = `${commentMarker}\n${output}`
252+
if (body.length > MAX_BODY) {
253+
const notice = '\n\n_Output truncated; see workflow logs for the full report._'
254+
body = body.slice(0, MAX_BODY - notice.length) + notice
255+
}
120256
121257
// List comments on the PR
122258
const { data: comments } = await github.rest.issues.listComments({

core/context.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ func GetSequencesCollectionFromContext(ctx *sql.Context, database string) (*sequ
337337
}
338338
if cv.seqs == nil {
339339
cv.seqs = make(map[string]*sequences.Collection)
340+
}
341+
if cv.seqs[database] == nil {
340342
_, root, err := getRootFromContextForDatabase(ctx, database)
341343
if err != nil {
342344
return nil, err
@@ -430,7 +432,7 @@ func updateSessionRootForDatabase(ctx *sql.Context, db string, cv *contextValues
430432
return err
431433
}
432434
newRoot = retRoot.(*RootValue)
433-
cv.seqs = nil
435+
delete(cv.seqs, db)
434436
}
435437

436438
if cv.funcs != nil && cv.funcs.DiffersFrom(ctx, root) {

core/sequences/collection.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,12 @@ func (pgs *Collection) DropSequence(ctx context.Context, names ...id.Sequence) (
172172
return err
173173
}
174174
}
175-
pgs.underlyingMap, err = mapEditor.Flush(ctx)
176-
return err
175+
flushed, err := mapEditor.Flush(ctx)
176+
if err != nil {
177+
return err
178+
}
179+
pgs.underlyingMap = flushed
180+
return nil
177181
}
178182

179183
// resolveName returns the fully resolved name of the given sequence. Returns an error if the name is ambiguous.
@@ -416,10 +420,13 @@ func (pgs *Collection) writeCache(ctx context.Context) (err error) {
416420
return err
417421
}
418422
}
419-
pgs.underlyingMap, err = mapEditor.Flush(ctx)
423+
// Assign underlyingMap only after the error check. Flush returns a
424+
// zero AddressMap on failure, which would corrupt the Collection.
425+
flushed, err := mapEditor.Flush(ctx)
420426
if err != nil {
421427
return err
422428
}
429+
pgs.underlyingMap = flushed
423430
clear(pgs.accessedMap)
424431
return nil
425432
}

0 commit comments

Comments
 (0)