@@ -58,33 +58,33 @@ function test_push() {
58
58
59
59
# Push multiple branches
60
60
setup_cache " org/repo:heads/change:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
61
- " org/repo:heads/nochange:a5984bb887dd2fcdc2892cd906d6f004844d1142"
61
+ " org/repo:heads/nochange:a5984bb887dd2fcdc2892cd906d6f004844d1142"
62
62
setup_dest " org/repo:heads/change:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
63
- " org/repo:heads/nochange:a5984bb887dd2fcdc2892cd906d6f004844d1142"
63
+ " org/repo:heads/nochange:a5984bb887dd2fcdc2892cd906d6f004844d1142"
64
64
65
65
push " pushing multiple branches"
66
66
assert_dest_sha " org/repo" " heads/change" " e9009d51dd6da2c363d1d14779c53dd27fcb0c52" " updating org/repo:heads/change to new commit"
67
67
assert_dest_sha " org/repo" " heads/nochange" " a5984bb887dd2fcdc2892cd906d6f004844d1142" " leaving org/repo:heads/nochange at existing commit"
68
68
69
69
# Pushing multiple branches and tags
70
70
setup_cache " org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
71
- " org/repo:tags/v1:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
71
+ " org/repo:tags/v1:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
72
72
setup_dest " org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
73
- " org/repo:tags/v1:a5984bb887dd2fcdc2892cd906d6f004844d1142"
73
+ " org/repo:tags/v1:a5984bb887dd2fcdc2892cd906d6f004844d1142"
74
74
75
75
push " pushing multiple branches and tags"
76
76
assert_dest_sha " org/repo" " heads/main" " e9009d51dd6da2c363d1d14779c53dd27fcb0c52" " updating org/repo:heads/main to new commit"
77
77
assert_dest_sha " org/repo" " tags/v1" " e9009d51dd6da2c363d1d14779c53dd27fcb0c52" " updating org/repo:tags/v1 to new commit"
78
78
79
79
# Pushing multiple repositories
80
80
setup_cache " org1/repo1:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
81
- " org1/repo2:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
82
- " org1/repo2:tags/v1:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
83
- " org2/repo1:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
81
+ " org1/repo2:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
82
+ " org1/repo2:tags/v1:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
83
+ " org2/repo1:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
84
84
setup_dest " org1/repo1:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
85
- " org1/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
86
- " org1/repo2:tags/v1:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
87
- " org2/repo1:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
85
+ " org1/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
86
+ " org1/repo2:tags/v1:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
87
+ " org2/repo1:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
88
88
89
89
push " pushing multiple repositories"
90
90
assert_dest_sha " org1/repo1" " heads/main" " e9009d51dd6da2c363d1d14779c53dd27fcb0c52" " updating org1/repo1:heads/main to new commit"
@@ -94,9 +94,9 @@ function test_push() {
94
94
95
95
# Honor --repo-name flag, ignore other cache entries
96
96
setup_cache " org/repo1:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
97
- " org/repo2:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
97
+ " org/repo2:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
98
98
setup_dest " org/repo1:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
99
- " org/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
99
+ " org/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
100
100
101
101
push2args --repo-name " org/repo1" " pushing only one of the repos in the cache"
102
102
assert_dest_sha " org/repo1" " heads/main" " e9009d51dd6da2c363d1d14779c53dd27fcb0c52" " updating org/repo1 passed in repo flag"
@@ -191,9 +191,9 @@ function test_sync() {
191
191
192
192
# Honor --repo-name flag, ignore other cache entries
193
193
setup_cache " org/repo1:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
194
- " org/repo2:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
194
+ " org/repo2:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
195
195
setup_dest " org/repo1:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
196
- " org/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
196
+ " org/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
197
197
198
198
sync --repo-name " org/repo1" " syncing only one of the repos in the cache"
199
199
assert_dest_sha " org/repo1" " heads/main" " e9009d51dd6da2c363d1d14779c53dd27fcb0c52" " updating org/repo1 passed in repo flag"
@@ -208,15 +208,15 @@ function before_suite() {
208
208
rm -rf test/tmp
209
209
mkdir -p test/tmp/dest
210
210
mkdir -p test/tmp/src
211
- ) > /dev/null
211
+ ) > /dev/null
212
212
213
213
git daemon \
214
214
--reuseaddr \
215
215
--verbose \
216
216
--export-all \
217
217
--enable=receive-pack \
218
218
--port=" $SRC_GIT_DAEMON_PORT " \
219
- --base-path=test/tmp/src & > $SRC_GIT_DAEMON_OUTPUT &
219
+ --base-path=test/tmp/src & > $SRC_GIT_DAEMON_OUTPUT &
220
220
SRC_GIT_DAEMON_PID=$!
221
221
222
222
git daemon \
@@ -225,12 +225,24 @@ function before_suite() {
225
225
--export-all \
226
226
--enable=receive-pack \
227
227
--port=" $DEST_GIT_DAEMON_PORT " \
228
- --base-path=test/tmp/dest & > $DEST_GIT_DAEMON_OUTPUT &
228
+ --base-path=test/tmp/dest & > $DEST_GIT_DAEMON_OUTPUT &
229
229
DEST_GIT_DAEMON_PID=$!
230
230
231
+ # wait for the git daemons to start before continuing
232
+
233
+ if ! check_git_daemon $SRC_GIT_DAEMON_PORT ; then
234
+ echo " timeout waiting for src git daemon to start"
235
+ exit 1
236
+ fi
237
+
238
+ if ! check_git_daemon $DEST_GIT_DAEMON_PORT ; then
239
+ echo " timeout waiting for dest git daemon to start"
240
+ exit 1
241
+ fi
242
+
231
243
go run test/github.go \
232
244
-p " $DEST_API_PORT " \
233
- -git-daemon-url " git://localhost:$DEST_GIT_DAEMON_PORT /" & > $DEST_API_OUTPUT &
245
+ -git-daemon-url " git://localhost:$DEST_GIT_DAEMON_PORT /" & > $DEST_API_OUTPUT &
234
246
DEST_API_PID=$!
235
247
236
248
script/build
@@ -257,7 +269,7 @@ function setup_src() {
257
269
258
270
local org=$( echo $nwo | cut -d' /' -f1)
259
271
mkdir -p test/tmp/src/$org && cp -R test/fixtures/repo.git test/tmp/src/$nwo
260
- echo " $sha " > " test/tmp/src/$nwo /refs/$refname "
272
+ echo " $sha " > " test/tmp/src/$nwo /refs/$refname "
261
273
done
262
274
}
263
275
@@ -270,7 +282,7 @@ function setup_cache() {
270
282
local refname=$( echo $r | cut -d' :' -f2)
271
283
local sha=$( echo $r | cut -d' :' -f3)
272
284
mkdir -p test/tmp/cache/$nwo && cp -R test/fixtures/repo.git test/tmp/cache/$nwo /.git
273
- echo " $sha " > " test/tmp/cache/$nwo /.git/refs/$refname "
285
+ echo " $sha " > " test/tmp/cache/$nwo /.git/refs/$refname "
274
286
done
275
287
}
276
288
@@ -283,13 +295,13 @@ function setup_dest() {
283
295
local refname=$( echo $r | cut -d' :' -f2)
284
296
local sha=$( echo $r | cut -d' :' -f3)
285
297
mkdir -p test/tmp/dest/$nwo && cp -R test/fixtures/repo.git test/tmp/dest/$nwo /.git
286
- echo " $sha " > " test/tmp/dest/$nwo /.git/refs/$refname "
298
+ echo " $sha " > " test/tmp/dest/$nwo /.git/refs/$refname "
287
299
done
288
300
}
289
301
290
302
function version() {
291
303
bin/actions-sync version \
292
- & > $OUTPUT ||
304
+ & > $OUTPUT ||
293
305
fail $1
294
306
}
295
307
@@ -298,7 +310,7 @@ function pull() {
298
310
--cache-dir " test/tmp/cache" \
299
311
--source-url " git://localhost:$SRC_GIT_DAEMON_PORT " \
300
312
" $1 " " $2 " \
301
- & > $OUTPUT ||
313
+ & > $OUTPUT ||
302
314
fail $3
303
315
}
304
316
@@ -308,7 +320,7 @@ function push() {
308
320
--disable-push-git-auth \
309
321
--destination-token " token" \
310
322
--destination-url " http://localhost:$DEST_API_PORT " \
311
- & > $OUTPUT ||
323
+ & > $OUTPUT ||
312
324
fail " $1 "
313
325
}
314
326
@@ -319,7 +331,7 @@ function push2args() {
319
331
--destination-token " token" \
320
332
--destination-url " http://localhost:$DEST_API_PORT " \
321
333
" $1 " " $2 " \
322
- & > $OUTPUT ||
334
+ & > $OUTPUT ||
323
335
fail $3
324
336
}
325
337
@@ -330,7 +342,7 @@ function push_impersonation() {
330
342
--destination-token " token" \
331
343
--destination-url " http://localhost:$DEST_API_PORT " \
332
344
--actions-admin-user $1 \
333
- & > $OUTPUT ||
345
+ & > $OUTPUT ||
334
346
fail " $2 "
335
347
}
336
348
@@ -342,7 +354,7 @@ function sync() {
342
354
--destination-token " token" \
343
355
--destination-url " http://localhost:$DEST_API_PORT " \
344
356
" $1 " " $2 " \
345
- & > $OUTPUT ||
357
+ & > $OUTPUT ||
346
358
fail $3
347
359
}
348
360
@@ -383,6 +395,22 @@ function fail() {
383
395
exit 1
384
396
}
385
397
398
+ function check_git_daemon {
399
+ port=$1
400
+ for i in {1..10}; do
401
+ process=$( ps aux | grep " git daemon" | grep $port )
402
+ if [ -z " $process " ]; then
403
+ echo " Waiting for git daemon to start on port $port ..."
404
+ sleep 1
405
+ else
406
+ echo " Git daemon is running on port $port "
407
+ return 0
408
+ fi
409
+ done
410
+ echo " Git daemon did not start within the expected time."
411
+ return 1
412
+ }
413
+
386
414
test_version
387
415
before_suite
388
416
test_pull
0 commit comments