GitRoot
Craft your forge, Build your project, Grow your community freely
1#!/usr/bin/env bash
2
3# SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
4#
5# SPDX-License-Identifier: EUPL-1.2
6
7trap 'catch $LINENO' ERR
8
9MY_LOG=${MY_LOG:-"/tmp/mylog.txt"}
10EXPECTED_ERROR=0
11
12catch() {
13 if [[ $EXPECTED_ERROR == 0 ]]; then
14 echo "🛑 unexpected error line $1"
15 exit 1
16 fi
17 report "🟢 expected err line $1"
18}
19
20mySleep() {
21 echo "🕐 wait $1"
22 echo "🕐 $1" >> $MY_LOG
23 sleep $1
24}
25
26function wait_for() {
27 start=`date +%s`
28 timeout=100
29 until [ $timeout -le 0 ] || (grep -q $1 $2 &> /dev/null); do
30 sleep 0.1
31 timeout=$(( timeout - 1 ))
32 done
33 if [ $timeout -le 0 ]; then
34 return 1
35 fi
36 end=`date +%s`
37 echo "🕐 $@ in `expr $end - $start` seconds"
38}
39
40function wait_ls() {
41 local start=$(date +%s)
42 local timeout=500
43 local target="$1"
44
45 until [ $timeout -le 0 ]; do
46 count=$(find "$target" -maxdepth 1 -mindepth 1 2>/dev/null | wc -l)
47 if [ "$count" -eq 3 ]; then
48 break
49 fi
50 sleep 0.1
51 ((timeout--))
52 done
53 if [ $timeout -le 0 ]; then
54 return 1
55 fi
56 local end=`date +%s`
57 echo "🕐 $@ in `expr $end - $start` seconds"
58 mySleep 0.3
59}
60
61function init_local_git() {
62 git config commit.gpgSign true
63 git config gpg.format ssh
64 git config user.signingkey $3
65 git config core.sshCommand "ssh -i ${4} -o IdentitiesOnly=yes"
66 git config user.email "$1"
67 git config user.name "$2"
68 git config gpg.ssh.allowedSignersFile "$(pwd)/.gitroot/allowed_signers"
69 echo "$1 $(cat $3)" >> "$(pwd)/.gitroot/allowed_signers"
70}
71
72EXIT_CODE=0
73
74SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
75
76source "${SCRIPT_DIR}/lib/pushandwait.sh"
77source "${SCRIPT_DIR}/lib/git.sh"
78source "${SCRIPT_DIR}/lib/report.sh"
79
80SERVER_PORT=${SERVER_PORT:-4545}
81SERVER_PORT_HTTP=${SERVER_PORT_HTTP:-4546}
82SERVER_URL=${1:-"127.0.0.1:$SERVER_PORT"}
83SERVER_DATA_DIR="/tmp/gitrootData"
84
85ROOT_REPO_NAME="root"
86ROOT_REPO_URL="ssh://${SERVER_URL}/${ROOT_REPO_NAME}"
87REPO1_NAME="repo1"
88REPO1_URL="ssh://user@${SERVER_URL}/${REPO1_NAME}"
89REPO2_NAME="repo2"
90REPO2_URL="ssh://user@${SERVER_URL}/${REPO2_NAME}"
91REPO3_NAME="repo3"
92REPO3_URL="ssh://user@${SERVER_URL}/${REPO3_NAME}"
93
94SSH_KEY="${SCRIPT_DIR}/user1/ed25519"
95SSH_KEY2="${SCRIPT_DIR}/user2/ed25519"
96SSH_KEY3="${SCRIPT_DIR}/user3/ed25519"
97
98LADYBUG_WASM="pkg://gitroot/gitroot/ladybug@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/ladybug&checksum=none"
99SILO_WASM="pkg://gitroot/gitroot/silo@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/silo&checksum=none"
100GRAFTER_WASM="pkg://gitroot/gitroot/grafter@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/grafter&checksum=none"
101APEX_WASM="pkg://gitroot/gitroot/apex@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/apex&checksum=none"
102APEX_MARKDOWN_WASM="pkg://gitroot/gitroot/apex_markdown@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/apex&checksum=none"
103APEX_CODE_WASM="pkg://gitroot/gitroot/apex_code@0.0.5?registry=file://${SCRIPT_DIR}/../plugins/apex&checksum=none"
104APEX_CODE_MERMAID_WASM="pkg://gitroot/gitroot/apex_mermaid@0.0.2?registry=file://${SCRIPT_DIR}/../plugins/apex_mermaid&checksum=none"
105POLLEN_WASM="pkg://gitroot/gitroot/pollen@0.0.4?registry=file://${SCRIPT_DIR}/../plugins/pollen&checksum=none"
106HOP_WASM="pkg://gitroot/gitroot/hop@0.0.3?registry=file://${SCRIPT_DIR}/../plugins/hop&checksum=none"
107STIGMA_WASM="pkg://gitroot/gitroot/stigma@0.0.2?registry=file://${SCRIPT_DIR}/../plugins/stigma&checksum=none"
108FIREFLY_WASM="pkg://gitroot/gitroot/firefly@0.0.1?registry=file://${SCRIPT_DIR}/../plugins/firefly&checksum=none"
109
110##### clean
111report "🏁 clean"
112
113cd /tmp
114rm -rf ${SERVER_DATA_DIR}
115rm -rf ${ROOT_REPO_NAME}
116rm -rf ${ROOT_REPO_NAME}_2
117rm -rf ${REPO1_NAME}
118rm -rf ${REPO2_NAME}
119rm -rf ${REPO1_NAME}_2
120rm -rf ${REPO1_NAME}_3
121rm -rf ${REPO2_NAME}_2
122rm -rf ${REPO3_NAME}
123rm -f ${MY_LOG}
124APP=$(lsof -i tcp:${SERVER_PORT} | awk 'NR!=1 {print $2}')
125if [ -z "$APP" ]; then
126 report "🟢 Gitroot not launched"
127else
128 kill ${APP}
129 report "🟢 Gitroot killed"
130fi
131ssh-keygen -f "$HOME/.ssh/known_hosts" -R "[127.0.0.1]:$SERVER_PORT"
132
133##### launch gitroot
134report "🏁 launch gitroot"
135
136cd ${SCRIPT_DIR}/../server
137mkdir -p "${SERVER_DATA_DIR}"
138go run -race . -initConfig="${SERVER_DATA_DIR}/config"
139sed -i -e "s/sshaddr: 0.0.0.0:4545/sshaddr: 0.0.0.0:$SERVER_PORT/g" "${SERVER_DATA_DIR}/config"
140sed -i -e "s/httpaddr: 0.0.0.0:4546/httpaddr: 0.0.0.0:$SERVER_PORT_HTTP/g" "${SERVER_DATA_DIR}/config"
141GIT_TRACE_PACKET=false go run -race . -data="${SERVER_DATA_DIR}" -config="${SERVER_DATA_DIR}/config" &>> $MY_LOG &
142
143wait_for "starting SSH server on" $MY_LOG
144
145##### forgeConfig
146report "🏁 forgeConfig"
147
148cd /tmp
149quiet_git clone -c "core.sshCommand=ssh -i ${SSH_KEY} -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" ${ROOT_REPO_URL}
150cd ${ROOT_REPO_NAME}
151init_local_git forgeConfig@gitroot.dev forgeConfig ${SSH_KEY}.pub ${SSH_KEY}
152
153printf "${REPO1_NAME}:\n defaultbranch: main" >> .gitroot/repositories.yml
154quiet_git add .
155quiet_git commit -m "create first repo"
156quiet_git push origin main
157report "🟢 ${ROOT_REPO_NAME} push first repo"
158
159mySleep 0.05
160
161##### Repo1
162report "🏁 Repo1"
163
164cd /tmp
165GIT_SSH_COMMAND="ssh -i ${SSH_KEY} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO1_URL}"
166cd ${REPO1_NAME}
167init_local_git repo1@gitroot.dev user1 ${SSH_KEY}.pub ${SSH_KEY}
168
169quiet_git add .
170quiet_git commit -m "init user"
171report "🟢 ${REPO1_NAME} commit user"
172
173quiet_git checkout -b "branch1"
174quiet_git push origin main branch1
175report "🟢 ${REPO1_NAME} push main+branch1"
176quiet_git checkout main
177quiet_git push origin :branch1
178report "🟢 ${REPO1_NAME} delete :branch1"
179quiet_git push origin main
180report "🟢 ${REPO1_NAME} push empty main"
181
182##### first plugin
183report "🏁 first plugin"
184
185cd /tmp/${ROOT_REPO_NAME}
186echo "- purl: ${LADYBUG_WASM}" >> .gitroot/plugins.yml
187quiet_git add .
188quiet_git commit -m "init ladybug plugin"
189printf "\n${REPO2_NAME}:\n defaultbranch: main" >> .gitroot/repositories.yml
190quiet_git add .
191quiet_git commit -m "create second repo"
192quiet_git push origin main
193report "🟢 ${ROOT_REPO_NAME} push first plugin and second repo"
194
195wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug"
196
197if [[ $(ls "${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug" | wc -l) -eq 3 ]]; then
198 report "🟢 ${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug loaded"
199else
200 report "🛑 ${SERVER_DATA_DIR}/data/plugins/gitroot-ladybug not downloaded"
201 EXIT_CODE=1
202fi
203
204quiet_git pull origin main
205
206if grep -Fxq " - path: issues/**/*.md" .gitroot/plugins.yml
207then
208 report "🟢 ${ROOT_REPO_NAME} plugin ladybug initialized"
209else
210 report "🛑 ${ROOT_REPO_NAME} plugin ladybug not initialized"
211 EXIT_CODE=1
212fi
213
214if grep -Fxq " metadata:" .gitroot/plugins.yml
215then
216 report "🟢 ${ROOT_REPO_NAME} plugin config initialized"
217else
218 report "🛑 ${ROOT_REPO_NAME} not initialized"
219 EXIT_CODE=1
220fi
221
222if grep -Fxq " - gitroot-ladybug@localhost" .gitroot/users.yml
223then
224 report "🟢 ${ROOT_REPO_NAME} plugin user initialized"
225else
226 report "🛑 ${ROOT_REPO_NAME} plugin user not initialized"
227 EXIT_CODE=1
228fi
229
230cd /tmp
231GIT_SSH_COMMAND="ssh -i ${SSH_KEY} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO2_URL}"
232cd ${REPO2_NAME}
233init_local_git repo2@gitroot.dev user1 ${SSH_KEY}.pub ${SSH_KEY}
234
235if grep -Fxq " metadata:" .gitroot/plugins.yml
236then
237 report "🟢 ${REPO2_NAME} plugin config initialized"
238else
239 report "🛑 ${REPO2_NAME} not initialized"
240 EXIT_CODE=1
241fi
242
243if grep -q " - path: issues/\\*\\*/\\*.md" .gitroot/plugins.yml
244then
245 report "🟢 ${REPO2_NAME} plugin path initialized"
246else
247 report "🛑 ${REPO2_NAME} not initialized"
248 EXIT_CODE=1
249fi
250
251sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
252
253mkdir issues
254echo "#my Issue" >> issues/1.md
255echo "Beatiful issue" >> issues/1.md
256quiet_git add .
257quiet_git commit -m "first issue in second repo"
258quiet_git push origin main
259report "🟢 ${REPO2_NAME} first issue in second repo"
260
261mySleep 0.05
262
263quiet_git pull
264
265if grep -q "priority: 50" issues/1.md
266then
267 report "🟢 issues/1.md initialized"
268else
269 report "🛑 issues/1.md not initialized"
270 EXIT_CODE=1
271fi
272
273##### repo1 should have issue available
274report "🏁 repo1 should have issue available"
275
276cd /tmp/${REPO1_NAME}
277
278quiet_git pull
279
280if grep -q " - path: issues/\\*\\*/\\*.md" .gitroot/plugins.yml
281then
282 report "🟢 ${REPO1_NAME} plugin path initialized"
283else
284 report "🛑 ${REPO1_NAME} not initialized"
285 EXIT_CODE=1
286fi
287
288sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
289
290mkdir issues
291echo "#my Issue" >> issues/1.md
292echo "Beatiful issue" >> issues/1.md
293quiet_git add .
294quiet_git commit -m "first issue in first repo"
295quiet_git push origin main
296report "🟢 ${REPO1_NAME} first issue in first repo"
297
298mySleep 0.05
299
300quiet_git pull
301
302if grep -q "priority: 50" issues/1.md
303then
304 report "🟢 issues/1.md initialized"
305else
306 report "🛑 issues/1.md not initialized"
307 EXIT_CODE=1
308fi
309
310##### user2 rights
311report "🏁 user2 rights"
312
313cd /tmp
314GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO1_URL}" ${REPO1_NAME}_2
315cd ${REPO1_NAME}_2
316git config core.sshCommand "ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes"
317git config user.email user2repo1@gitroot.dev
318git config user.name user2
319
320echo "# my Issue" >> issues/cac-1.md
321echo "Beatiful issue" >> issues/cac-1.md
322
323quiet_git add .
324quiet_git commit -m "user2 config and add an issue"
325EXPECTED_ERROR=1
326quiet_git push origin main
327if [[ "$?" == "0" ]]; then
328 report "🛑 user2 has push on main in repo1"
329 EXIT_CODE=1
330else
331 report "🟢 user2 can not push on main in repo1"
332fi
333EXPECTED_ERROR=0
334
335quiet_git reset --soft HEAD~1
336quiet_git checkout -b user2_branch_on_repo1
337quiet_git add .
338quiet_git commit -m "user2 config and an issue"
339
340echo "# my Issue" >> issues/cac-2.md
341echo "Beatiful issue" >> issues/cac-2.md
342quiet_git add .
343quiet_git commit -m "issue cac2"
344
345quiet_git push origin user2_branch_on_repo1
346
347if [[ "$?" == "0" ]]; then
348 report "🟢 user2 can push on user2_branch_on_repo1 branch in repo1"
349else
350 report "🛑 user2 can not push on user2_branch_on_repo1 branch in repo1"
351 EXIT_CODE=1
352fi
353
354mySleep 0.05
355quiet_git pull origin user2_branch_on_repo1
356
357if grep -q "priority: 50" issues/cac-1.md
358then
359 report "🟢 issues/cac-1.md initialized"
360else
361 report "🛑 issues/cac-1.md not initialized"
362 EXIT_CODE=1
363fi
364
365echo "New readme" > "README.md"
366quiet_git add .
367quiet_git commit -m "update readme"
368quiet_git push origin user2_branch_on_repo1
369
370if [[ "$?" == "0" ]]; then
371 report "🟢 user2 can push on user2_branch_on_repo1 branch in repo1 second time"
372else
373 report "🛑 user2 can not push on user2_branch_on_repo1 branch in repo1 second time"
374 EXIT_CODE=1
375fi
376
377quiet_git checkout main
378
379cd /tmp/${REPO1_NAME}
380quiet_git fetch origin user2_branch_on_repo1
381quiet_git checkout user2_branch_on_repo1
382
383echo "New readme by user 1" > "README.md"
384quiet_git add .
385quiet_git commit -m "update readme"
386quiet_git push origin user2_branch_on_repo1
387report "🟢 user1 can push on user2_branch_on_repo1 branch in repo1"
388
389quiet_git checkout main
390
391##### user3
392report "🏁 user3 on repo2"
393
394cd /tmp
395GIT_SSH_COMMAND="ssh -i ${SSH_KEY3} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO1_URL}" ${REPO1_NAME}_3
396cd ${REPO1_NAME}_3
397git config core.sshCommand "ssh -i ${SSH_KEY3} -o IdentitiesOnly=yes"
398git config user.email user3repo1@gitroot.dev
399git config user.name user3
400
401quiet_git checkout user2_branch_on_repo1
402
403echo "New readme by user 3" > "README.md"
404quiet_git add .
405quiet_git commit -m "update readme"
406
407EXPECTED_ERROR=1
408quiet_git push origin user2_branch_on_repo1
409if [[ "$?" == "0" ]]; then
410 report "🛑 user3 has push on user2_branch_on_repo1 in repo1"
411 EXIT_CODE=1
412else
413 report "🟢 user3 can not push on user2_branch_on_repo1 in repo1"
414fi
415EXPECTED_ERROR=0
416
417cd /tmp/${REPO1_NAME}
418quiet_git pull
419sed -i -e 's/nbmaxbranchesbeforerejectinganonymous: 10/nbmaxbranchesbeforerejectinganonymous: 1/g' .gitroot/repoConfiguration.yml
420quiet_git add .
421quiet_git commit -m "limit anonymous"
422quiet_git push origin main
423
424cd /tmp/${REPO1_NAME}_3
425quiet_git checkout main
426quiet_git checkout -b test22
427
428EXPECTED_ERROR=1
429quiet_git push origin test22
430if [[ "$?" == "0" ]]; then
431 report "🛑 user3 has push test22 in repo1"
432 EXIT_CODE=1
433else
434 report "🟢 user3 can not push test22 in repo1"
435fi
436EXPECTED_ERROR=0
437
438cd /tmp/${REPO1_NAME}
439sed -i -e 's/nbmaxbranchesbeforerejectinganonymous: 1/nbmaxbranchesbeforerejectinganonymous: 10/g' .gitroot/repoConfiguration.yml
440quiet_git add .
441quiet_git commit -m "unlimit anonymous"
442quiet_git push origin main
443cd /tmp/${REPO1_NAME}_3
444quiet_git push origin test22
445report "🟢 user3 can push test22 in repo1"
446
447##### second plugin
448report "🏁 second plugin"
449
450cd /tmp/${ROOT_REPO_NAME}
451echo "- purl: ${SILO_WASM}" >> .gitroot/plugins.yml
452quiet_git add .
453quiet_git commit -m "init silo plugin"
454quiet_git push origin main
455echo "🟢 ${ROOT_REPO_NAME} push second plugin"
456
457wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-silo"
458
459quiet_git pull origin main
460
461cd /tmp/${REPO1_NAME}
462
463quiet_git pull
464
465if grep -q "title: "Roadmaps"" .gitroot/plugins.yml
466then
467 report "🟢 ${REPO1_NAME} plugin path initialized"
468else
469 report "🛑 ${REPO1_NAME} not initialized"
470 EXIT_CODE=1
471fi
472
473sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
474
475echo "---" >> issues/roadmap1.md
476echo "id: 22C3" >> issues/roadmap1.md
477echo "priority: 50" >> issues/roadmap1.md
478echo "assignee: null" >> issues/roadmap1.md
479echo "kind: 'roadmap'" >> issues/roadmap1.md
480echo "---" >> issues/roadmap1.md
481echo "# step 1: conquers the world" >> issues/roadmap1.md
482echo "" >> issues/roadmap1.md
483echo "To do that just imagine the world is small." >> issues/roadmap1.md
484
485echo "---" >> issues/roadmap2.md
486echo "id: 22C3" >> issues/roadmap2.md
487echo "priority: 10" >> issues/roadmap2.md
488echo "assignee: null" >> issues/roadmap2.md
489echo "kind: 'roadmap'" >> issues/roadmap2.md
490echo "---" >> issues/roadmap2.md
491echo "# step 2: profit" >> issues/roadmap2.md
492echo "" >> issues/roadmap2.md
493echo "Finally take in peace." >> issues/roadmap2.md
494
495quiet_git add .
496quiet_git commit -m "active silo and build first roadmap ticket"
497quiet_git push origin main
498
499mySleep 0.1
500
501quiet_git pull
502
503if grep -q "issues/roadmap1.md" boards/roadmap.md
504then
505 report "🟢 ${REPO1_NAME} roadmap initialized"
506else
507 report "🛑 ${REPO1_NAME} roadmap not initialized"
508 EXIT_CODE=1
509fi
510
511if grep -q "issues/1.md" boards/issues.md
512then
513 report "🟢 ${REPO1_NAME} issues board initialized"
514else
515 report "🛑 ${REPO1_NAME} issues board not initialized"
516 EXIT_CODE=1
517fi
518
519if grep -q "issues/1.md" boards/triage.md
520then
521 report "🟢 ${REPO1_NAME} triage board initialized"
522else
523 report "🛑 ${REPO1_NAME} triage board not initialized"
524 EXIT_CODE=1
525fi
526
527quiet_git pull --rebase origin main
528
529for (( i=0; i<=50; i++ ))
530do
531 echo "# My issue $i" >> issues/issue_$i.md
532 echo "" >> issues/issue_$i.md
533 echo "Beatiful issue" >> issues/issue_$i.md
534done
535
536quiet_git add .
537quiet_git commit -m "create lot of issues"
538quiet_git push origin main
539
540mySleep 0.5
541
542quiet_git pull
543
544for (( i=0; i<=50; i++ ))
545do
546 PRIO=$(shuf -i 0-99 -n 1)
547 sed -i -e "s/priority: 50/priority: $PRIO/g" issues/issue_$i.md
548done
549
550quiet_git add .
551quiet_git commit -m "update random prio of lot of issues"
552quiet_git push origin main
553
554mySleep 0.05
555
556quiet_git pull
557
558##### Repo2 don't allow anonymous contrib
559report "🏁 Repo2 don't allow anonymous contrib"
560
561cd /tmp/${REPO2_NAME}
562
563quiet_git pull
564
565echo "" >> .gitroot/users.yml
566echo "\"*\":" >> .gitroot/users.yml
567echo " branches:" >> .gitroot/users.yml
568echo " - name: \"*\"" >> .gitroot/users.yml
569echo " users: []" >> .gitroot/users.yml
570
571quiet_git add .
572quiet_git commit -m "block all modifications of anonymous users"
573quiet_git push origin main
574
575cd /tmp
576GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO2_URL}" ${REPO2_NAME}_2
577cd ${REPO2_NAME}_2
578init_local_git user2repo2@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
579
580quiet_git checkout -b tryToAddMe
581quiet_git add .
582quiet_git commit -m "user2 config"
583
584EXPECTED_ERROR=1
585quiet_git push origin tryToAddMe
586if [[ "$?" == "0" ]]; then
587 report "🛑 user2 can push on tryToAddMe branch in repo2"
588 EXIT_CODE=1
589else
590 report "🟢 user2 can not push on tryToAddMe branch in repo2"
591fi
592EXPECTED_ERROR=0
593
594##### User2 can add issue in repo1 on branch user2_issue_on_repo1
595report "🏁 User2 can add issue in repo1 on branch user2_issue_on_repo1"
596
597cd /tmp/${REPO1_NAME}_2
598
599quiet_git pull origin main
600
601quiet_git checkout -b user2_issue_on_repo1
602
603echo "# My issue" >> issues/2.md
604echo "" >> issues/2.md
605echo "This is my issue" >> issues/2.md
606
607quiet_git add .
608quiet_git commit -m "user2 issue 1"
609
610echo "---" >> issues/roadmap3.md
611echo "id: 22E3" >> issues/roadmap3.md
612echo "priority: 40" >> issues/roadmap3.md
613echo "assignee: null" >> issues/roadmap3.md
614echo "kind: 'roadmap'" >> issues/roadmap3.md
615echo "---" >> issues/roadmap3.md
616echo "# step 3: give" >> issues/roadmap3.md
617echo "" >> issues/roadmap3.md
618echo "Just fun." >> issues/roadmap3.md
619
620quiet_git add .
621quiet_git commit -m "user2 roadmap 3"
622
623quiet_git push origin user2_issue_on_repo1 :user2_branch_on_repo1
624push_and_wait origin user2_issue_on_repo1
625
626quiet_git pull origin user2_issue_on_repo1
627
628if grep -q "id:" issues/2.md
629then
630 report "🟢 ${REPO1_NAME}_2 issues/2.md initialized"
631else
632 report "🛑 ${REPO1_NAME}_2 issues/2.md not initialized"
633 EXIT_CODE=1
634fi
635
636if grep -q "step 3: give" boards/roadmap.md
637then
638 report "🛑 ${REPO1_NAME}_2 boards/roadmap should not be updated has silo is only on main"
639 EXIT_CODE=1
640else
641 report "🟢 ${REPO1_NAME}_2 boards/roadmap not updated"
642fi
643
644quiet_git checkout -b user2_issue2_on_repo1
645
646echo "# My issue" >> issues/3.md
647echo "" >> issues/3.md
648echo "This is my issue" >> issues/3.md
649
650quiet_git add .
651quiet_git commit -m "user2 issue 2"
652push_and_wait origin user2_issue2_on_repo1
653
654quiet_git pull origin user2_issue2_on_repo1
655
656if grep -q "id:" issues/3.md
657then
658 report "🟢 ${REPO1_NAME}_2 issues/3.md initialized"
659else
660 report "🛑 ${REPO1_NAME}_2 issues/3.md not initialized"
661 EXIT_CODE=1
662fi
663
664NB_SILO=$(grep "step 3: give" boards/roadmap.md | wc -l)
665if [[ "$NB_SILO" == "0" ]]; then
666 report "🟢 ${REPO1_NAME}_2 silo has not been called"
667else
668 report "🛑 ${REPO1_NAME}_2 silo has been called $NB_SILO times"
669 EXIT_CODE=1
670fi
671
672##### User1 push force in repo1 on main
673report "🏁 User1 push force in repo1 on main"
674cd /tmp/${REPO1_NAME}
675mySleep 0.1
676quiet_git pull
677echo "not authorized" > issues/1.md
678quiet_git add .
679quiet_git commit --amend --no-edit
680
681EXPECTED_ERROR=1
682quiet_git push -f origin main
683if [[ "$?" == "0" ]]; then
684 report "🛑 user1 can push force on main"
685 EXIT_CODE=1
686else
687 report "🟢 user1 can not push force on main"
688fi
689EXPECTED_ERROR=0
690quiet_git fetch origin main
691quiet_git reset --hard origin/HEAD
692
693##### User2 push force in repo1 on branch user2_branch2_on_repo1
694report "🏁 User2 push force in repo1 on branch user2_branch2_on_repo1"
695
696cd /tmp/${REPO1_NAME}_2
697quiet_git checkout main
698quiet_git checkout -b user2_branch2_on_repo1
699
700#add a commit
701cd /tmp/${REPO1_NAME}
702quiet_git checkout main
703echo "hello" >> README.md
704quiet_git add .
705quiet_git commit -m "fake commit to conflict"
706quiet_git push origin main
707
708mySleep 0.2
709
710cd /tmp/${REPO1_NAME}_2
711echo "---" >> issues/roadmap4.md
712echo "id: 22C3" >> issues/roadmap4.md
713echo "priority: 50" >> issues/roadmap4.md
714echo "assignee: null" >> issues/roadmap4.md
715echo "kind: 'roadmap'" >> issues/roadmap4.md
716echo "---" >> issues/roadmap4.md
717echo "# step 1: conquers the world" >> issues/roadmap4.md
718echo "" >> issues/roadmap4.md
719echo "To do that just imagine the world is small." >> issues/roadmap4.md
720
721quiet_git add .
722quiet_git commit -m "roadmap4"
723quiet_git push origin user2_branch2_on_repo1
724
725quiet_git checkout main
726quiet_git pull --rebase origin main
727quiet_git checkout user2_branch2_on_repo1
728
729quiet_git rebase -X ours main
730report "🟢 Rebase ok"
731
732quiet_git push -f origin user2_branch2_on_repo1
733mySleep 0.05
734quiet_git pull origin user2_branch2_on_repo1
735report "🟢 Push -f ok"
736
737NB_SILO=$(grep "step 1:" boards/roadmap.md | wc -l)
738if [[ "$NB_SILO" == "1" ]]; then
739 report "🟢 ${REPO1_NAME}_2 silo has not been called"
740else
741 report "🛑 ${REPO1_NAME}_2 silo has been called $NB_SILO times"
742 EXIT_CODE=1
743fi
744
745##### Add grafter plugin in repo1
746report "🏁 Add grafter plugin in repo1"
747
748cd /tmp/${ROOT_REPO_NAME}
749echo "- purl: ${GRAFTER_WASM}" >> .gitroot/plugins.yml
750quiet_git add .
751quiet_git commit -m "init grafter plugin"
752quiet_git push origin main
753
754wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-grafter"
755quiet_git pull origin main
756
757cd /tmp/${REPO1_NAME}
758quiet_git pull origin main
759sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
760report "🟢 ${REPO1_NAME} grafter plugin initialized"
761quiet_git add .
762quiet_git commit -m "active grafter plugin"
763quiet_git push origin main
764
765report "🟢 ${REPO1_NAME} grafter plugin activated"
766quiet_git checkout -b graft_something
767echo "hello" >> tada.md
768quiet_git add .
769quiet_git commit -m "first graft"
770push_and_wait origin graft_something
771quiet_git pull origin graft_something
772
773NB_STATUS_DRAFT=$(grep "status: draft" grafts/graft_something.md | wc -l)
774if [[ $NB_STATUS_DRAFT -ge 1 ]]; then
775 report "🟢 ${REPO1_NAME} status: draft ok"
776else
777 report "🛑 ${REPO1_NAME} status: draft ko"
778 EXIT_CODE=1
779fi
780report "🟢 ${REPO1_NAME} first graft created"
781
782rm issues/1.md
783quiet_git add .
784quiet_git commit -m "rm issue first graft"
785echo "second" > issues/2.md
786quiet_git add .
787quiet_git commit -m "second issue first graft"
788mv issues/roadmap1.md issues/roadmap.md
789quiet_git add .
790quiet_git commit -m "move roadmap first graft"
791push_and_wait origin graft_something
792quiet_git pull origin graft_something
793
794NB_PUSH=$(grep "Push " grafts/graft_something.md | wc -l)
795NB_COMMIT=$(grep "### " grafts/graft_something.md | wc -l)
796if [[ "$NB_COMMIT" == "6" ]] && [[ "$NB_PUSH" == "3" ]]; then
797 report "🟢 ${REPO1_NAME} graft has 3 push and 6 commits"
798else
799 report "🛑 ${REPO1_NAME} graft has $NB_PUSH push and $NB_COMMIT commits"
800 EXIT_CODE=1
801fi
802
803NB_COMMIT=$(git log --oneline graft_something ^main | wc -l)
804if [[ $NB_COMMIT -eq 9 ]]; then
805 report "🟢 ${REPO1_NAME} has 9 commits on branch graft_something"
806else
807 report "🛑 ${REPO1_NAME} has $NB_COMMIT commits on branch graft_something"
808 EXIT_CODE=1
809fi
810
811sed -i -e 's/status: draft/status: review/g' grafts/graft_something.md
812quiet_git add .
813quiet_git commit -m "review first graft"
814push_and_wait origin graft_something
815quiet_git pull origin graft_something
816
817NB_STATUS_DRAFT=$(grep "status: draft" grafts/graft_something.md | wc -l)
818if [[ "$NB_STATUS_DRAFT" == "0" ]]; then
819 report "🟢 ${REPO1_NAME} status no more draft"
820else
821 report "🛑 ${REPO1_NAME} status: draft ko"
822 EXIT_CODE=1
823fi
824NB_REVIEWERS=$(grep "reviewers: " grafts/graft_something.md | wc -l)
825if [[ "$NB_REVIEWERS" == "1" ]]; then
826 report "🟢 ${REPO1_NAME} reviewers added"
827else
828 report "🛑 ${REPO1_NAME} reviewers ko"
829 EXIT_CODE=1
830fi
831NB_MENTION_OF_REVIEW=$(grep "review first graft" grafts/graft_something.md | wc -l)
832if [[ "$NB_MENTION_OF_REVIEW" == "0" ]]; then
833 report "🟢 ${REPO1_NAME} commit review skipped"
834else
835 report "🛑 ${REPO1_NAME} commit review not skipped"
836 EXIT_CODE=1
837fi
838report "🟢 ${REPO1_NAME} first graft ready to review"
839
840echo "second is 2" > issues/2.md
841quiet_git add .
842quiet_git commit -m "second issue review first graft"
843push_and_wait origin graft_something
844quiet_git pull origin graft_something
845
846NB_DIFF=$(grep -F '```diff' grafts/graft_something.md | wc -l)
847if [[ "$NB_DIFF" == "2" ]]; then
848 report "🟢 ${REPO1_NAME} diff added"
849else
850 report "🛑 ${REPO1_NAME} diff ko $NB_DIFF"
851 EXIT_CODE=1
852fi
853
854sed -i -e 's/status: review/status: merge/g' grafts/graft_something.md
855quiet_git add .
856quiet_git commit -m "merge first graft"
857quiet_git push origin graft_something
858
859mySleep 0.5
860
861quiet_git checkout main
862quiet_git pull --rebase origin main
863quiet_git fetch --prune
864BRANCH_EXIST=$(git branch -r | grep "origin/graft_something" | wc -l)
865if [[ "$BRANCH_EXIST" == "0" ]]; then
866 report "🟢 ${REPO1_NAME} branch graft_something deleted"
867else
868 report "🛑 ${REPO1_NAME} branch graft_something no deleted"
869 EXIT_CODE=1
870fi
871
872report "🟢 ${REPO1_NAME} recreate branch graft_something for test shallow-exclude"
873quiet_git push origin graft_something
874
875##### Add apex plugin in repo1
876report "🏁 Add apex plugin in repo1"
877
878cd /tmp/${ROOT_REPO_NAME}
879echo "- purl: ${APEX_WASM}" >> .gitroot/plugins.yml
880echo "- purl: ${APEX_CODE_MERMAID_WASM}" >> .gitroot/plugins.yml
881echo "- purl: ${APEX_CODE_WASM}" >> .gitroot/plugins.yml
882echo "- purl: ${APEX_MARKDOWN_WASM}" >> .gitroot/plugins.yml
883quiet_git add .
884quiet_git commit -m "init apex plugin"
885quiet_git push origin main
886
887wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-apex_markdown"
888wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-apex"
889wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-apex_code"
890quiet_git pull origin main
891report "🟢 ${ROOT_REPO_NAME} apex plugin installed"
892
893cd /tmp/${REPO1_NAME}
894quiet_git pull origin main
895sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
896sed -i -e 's/layout: \[\]/layout:\
897 \- glob: issues\/**\
898 path: layout.html/g' .gitroot/plugins.yml
899echo "<dl>" > layout.html
900echo " <dt>priority</dt><dd>{{priority}}</dd>" >> layout.html
901echo " <dt>status</dt><dd>{{status}}</dd>" >> layout.html
902echo " <dt>kind</dt><dd>{{kind}}</dd>" >> layout.html
903echo "</dl>" >> layout.html
904echo "<br />" >> layout.html
905echo "{{content}}" >> layout.html
906report "🟢 ${REPO1_NAME} apex plugin initialized"
907quiet_git add .
908quiet_git commit -m "active apex plugin"
909
910push_and_wait origin main
911
912META_FOUND=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/issues/issue_9.html -O - | grep "<dt>" | wc -l)
913if [[ $META_FOUND -eq 3 ]]; then
914 report "🟢 issue_9.html has 3 meta"
915else
916 report "🛑 issue_9.html has no meta"
917 EXIT_CODE=1
918fi
919
920quiet_git pull origin main
921
922report "🟢 ${REPO1_NAME} apex plugin activated"
923echo "# hello" > hello2.md
924echo "## hello2" >> hello2.md
925echo "### hello3" >> hello2.md
926quiet_git add .
927quiet_git commit -m "first html"
928
929quiet_git push origin main
930
931sed -i -e 's/style: simple.min.css/style: style.css/g' .gitroot/plugins.yml
932sed -i -e 's/header: <h1>{{repo.name}}/header: <h1>{{repo.name}} <small>{{page.title}}<\/small>/g' .gitroot/plugins.yml
933
934cp ${SCRIPT_DIR}/../server/resources/styles/simple.min.css style.css
935cat ${SCRIPT_DIR}/../plugins/apex/resources/styles/add.css >> style.css
936echo "body { background-color: 010409 }" >> style.css
937echo "body > header { background-color: 010409; text-align: left; padding: 0 1rem }" >> style.css
938echo "body > header h1 { font-size: 1rem }" >> style.css
939echo "header > nav ul { place-content: normal }" >> style.css
940echo "header > nav a { margin: 0 .5rem; border: 0 }" >> style.css
941
942echo "# Mermaid" >> apex.md
943echo "" >> apex.md
944echo "Examples of rendering mermaid..." >> apex.md
945echo "" >> apex.md
946echo "## Mermaid flowchart" >> apex.md
947echo "" >> apex.md
948echo "\`\`\`mermaid" >> apex.md
949echo "flowchart LR;" >> apex.md
950echo "ssh-->runtime-->plugin" >> apex.md
951echo "\`\`\`" >> apex.md
952echo "" >> apex.md
953echo "## Mermaid flowchart complexe" >> apex.md
954echo "\`\`\`mermaid" >> apex.md
955echo "flowchart TB" >> apex.md
956echo " subgraph Git" >> apex.md
957echo " A[ssh conn] --> B[plugin manager]" >> apex.md
958echo " end" >> apex.md
959echo " subgraph Runtime" >> apex.md
960echo " C[runtime] --> D[wasm]" >> apex.md
961echo " end" >> apex.md
962echo " subgraph Plugin" >> apex.md
963echo " E[guest] --> F[host]" >> apex.md
964echo " end" >> apex.md
965echo " B --> C" >> apex.md
966echo " D --> E" >> apex.md
967echo "" >> apex.md
968echo "\`\`\`" >> apex.md
969echo "## Mermaid pie" >> apex.md
970echo "\`\`\`mermaid" >> apex.md
971echo "pie title Plugins sdk" >> apex.md
972echo " "Stable" : 20" >> apex.md
973echo " "Need work" : 80" >> apex.md
974echo "\`\`\`" >> apex.md
975echo "## Mermaid sequence" >> apex.md
976echo "\`\`\`mermaid" >> apex.md
977echo "sequenceDiagram" >> apex.md
978echo " Alice ->> Bob: Hello Bob, how are you?" >> apex.md
979echo " Bob-->>John: How about you John?" >> apex.md
980echo " Bob--x Alice: I am good thanks!" >> apex.md
981echo " Bob-x John: I am good thanks!" >> apex.md
982echo " Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row." >> apex.md
983echo " Bob-->Alice: Checking with John..." >> apex.md
984echo " Alice->John: Yes... John, how are you?" >> apex.md
985echo "\`\`\`" >> apex.md
986
987quiet_git add .
988quiet_git commit -m "perso style"
989quiet_git push origin main
990
991##### User2 can create repo3
992report "🏁 User2 can create repo3 with master branch"
993
994cd /tmp/${ROOT_REPO_NAME}
995sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
996report "🟢 ${ROOT_REPO_NAME} plugins will activate"
997quiet_git add .
998quiet_git commit -m "active all plugins"
999
1000push_and_wait origin main
1001
1002quiet_git pull origin main
1003report "🟢 ${ROOT_REPO_NAME} plugins activated"
1004
1005cd /tmp
1006GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${ROOT_REPO_URL}" ${ROOT_REPO_NAME}_2
1007cd ${ROOT_REPO_NAME}_2
1008quiet_git checkout -b create_repo3
1009init_local_git user2root@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
1010PUB=$(cat ${SSH_KEY2}.pub)
1011printf "\n${REPO3_NAME}:\n defaultbranch: master\n owners:\n - ${PUB}" >> .gitroot/repositories.yml
1012quiet_git add .
1013quiet_git commit -m "create repo3"
1014push_and_wait origin create_repo3
1015report "🟢 ${ROOT_REPO_NAME}_2 push create_repo3 repo"
1016
1017cd /tmp/${ROOT_REPO_NAME}
1018quiet_git pull --rebase origin main
1019quiet_git fetch origin create_repo3
1020quiet_git checkout create_repo3
1021sed -i -e 's/status: draft/status: merge/g' grafts/create_repo3.md
1022quiet_git add .
1023quiet_git commit -m "merge create_repo3 graft"
1024
1025push_and_wait origin create_repo3
1026
1027cd /tmp
1028GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet "${REPO3_URL}"
1029
1030cd ${REPO3_NAME}
1031init_local_git user2repo3@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
1032echo "works" > README.md
1033quiet_git add .
1034quiet_git commit -m "mine readme"
1035quiet_git push origin master
1036
1037##### Shallow
1038report "🏁 Shallow"
1039
1040cd /tmp
1041rm -rf repo1_shallow
1042GIT_SSH_COMMAND="ssh -i ${SSH_KEY2} -o IdentitiesOnly=yes" quiet_git clone --quiet --depth 1 ssh://git@127.0.0.1:$SERVER_PORT/repo1 repo1_shallow
1043cd repo1_shallow
1044init_local_git user2repo1Shallow@gitroot.dev user2 ${SSH_KEY2}.pub ${SSH_KEY2}
1045
1046NB_COMMIT=$(git rev-list HEAD --count)
1047if [[ $NB_COMMIT -eq 1 ]]; then
1048 report "🟢 repo1_shallow has 1 commit"
1049else
1050 report "🛑 repo1_shallow has $NB_COMMIT commits"
1051 EXIT_CODE=1
1052fi
1053
1054# TODO reactive after go-git v6
1055# quiet_git fetch --deepen 1 origin main
1056# NB_COMMIT=$(git rev-list HEAD --count)
1057# if [[ $NB_COMMIT -eq 2 ]]; then
1058# report "🟢 repo1_shallow has 2 commits"
1059# else
1060# report "🛑 repo1_shallow has $NB_COMMIT commits"
1061# EXIT_CODE=1
1062# fi
1063
1064# TODO reactive after go-git v6
1065# quiet_git fetch --shallow-exclude=graft_something origin main
1066# NB_COMMIT=$(git rev-list HEAD --count)
1067# if [[ $NB_COMMIT -eq 11 ]]; then
1068# report "🟢 repo1_shallow has 11 commits"
1069# else
1070# report "🛑 repo1_shallow has $NB_COMMIT commits"
1071# EXIT_CODE=1
1072# fi
1073
1074##### User2 hack repo1
1075report "🏁 User2 hack repo1"
1076
1077cd /tmp/${REPO1_NAME}_2
1078quiet_git checkout main
1079quiet_git pull --rebase origin main
1080
1081NB_NOT_FOUND=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/index2.html -O - | grep "Not found" | wc -l)
1082if [[ $NB_NOT_FOUND -eq 1 ]]; then
1083 report "🟢 index2.html is not found"
1084else
1085 report "🛑 index2.html exist"
1086 EXIT_CODE=1
1087fi
1088
1089quiet_git checkout -b hack
1090
1091#sed -i -e 's/path: branches\/\*\*\/\*/path: "\*\*\/\*"/g' .gitroot/plugins.yml
1092sed -i -e 's/- main/- hack/g' .gitroot/plugins.yml
1093sed -i -e 's/- "!main"/- "!hack"/g' .gitroot/plugins.yml
1094
1095echo "powned!" > index2.md
1096quiet_git add .
1097quiet_git commit -m "hack"
1098push_and_wait origin hack
1099
1100NB_NOT_FOUND=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/index2.html -O - | grep "Not found" | wc -l)
1101if [[ $NB_NOT_FOUND -eq 1 ]]; then
1102 report "🟢 index2.html is not found"
1103else
1104 report "🛑 index2.html exist"
1105 EXIT_CODE=1
1106fi
1107
1108HACK_LINK=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/branches/ -O - | grep "branches/hack.html" | wc -l)
1109if [[ $HACK_LINK -eq 1 ]]; then
1110 report "🟢 hack branch is referenced"
1111else
1112 report "🛑 hack branch is not referenced"
1113 EXIT_CODE=1
1114fi
1115
1116HACK_LINK=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/branches/hack/grafts/hack.html -O - | grep "Not found" | wc -l)
1117if [[ $HACK_LINK -eq 1 ]]; then
1118 report "🛑 hack branch has no graft"
1119 EXIT_CODE=1
1120else
1121 report "🟢 hack branch has graft"
1122fi
1123
1124##### install pollen plugin
1125report "🏁 pollen plugin"
1126
1127cd /tmp/${ROOT_REPO_NAME}
1128quiet_git checkout main
1129quiet_git pull origin main
1130echo "- purl: ${POLLEN_WASM}" >> .gitroot/plugins.yml
1131quiet_git add .
1132quiet_git commit -m "init pollen plugin"
1133push_and_wait origin main
1134wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-pollen"
1135mySleep 0.1
1136quiet_git pull origin main
1137report "🟢 ${ROOT_REPO_NAME} pollen plugin installed"
1138
1139cd /tmp/${REPO1_NAME}
1140push_and_wait origin main
1141quiet_git pull origin main
1142sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1143quiet_git add .
1144quiet_git commit -m "active pollen plugin"
1145quiet_git push origin main
1146
1147echo "With rss" > README.md
1148quiet_git add .
1149quiet_git commit -m "with rss"
1150quiet_git push origin main
1151
1152mySleep 4
1153
1154RSS_CONTENT=$(wget -q http://127.0.0.1:$SERVER_PORT_HTTP/repo1/rss/all.xml -O - | grep "with rss" | wc -l)
1155if [[ $RSS_CONTENT -eq 2 ]]; then
1156 report "🟢 rss ok"
1157else
1158 report "🛑 rss ko with $RSS_CONTENT commits"
1159 EXIT_CODE=1
1160fi
1161
1162##### install hop plugin
1163report "🏁 hop plugin"
1164
1165cd /tmp/${ROOT_REPO_NAME}
1166echo "- purl: ${HOP_WASM}" >> .gitroot/plugins.yml
1167quiet_git add .
1168quiet_git commit -m "init hop plugin"
1169push_and_wait origin main
1170wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-hop"
1171mySleep 0.1
1172quiet_git pull origin main
1173report "🟢 ${ROOT_REPO_NAME} hop plugin installed"
1174
1175cd /tmp/${REPO1_NAME}
1176push_and_wait origin main
1177quiet_git pull origin main
1178sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1179quiet_git add .
1180quiet_git commit -m "active hop plugin"
1181quiet_git push origin main
1182
1183mySleep 4
1184
1185quiet_git checkout -b testHop
1186echo "Hello from hop" >> README.md
1187quiet_git add .
1188quiet_git commit -m "test hop plugin"
1189push_and_wait origin testHop
1190
1191quiet_git pull origin testHop
1192NB_REPORT=$(grep "❌ No commands executed." grafts/testHop.md | wc -l)
1193if [[ $NB_REPORT -eq 1 ]]; then
1194 report "🟢 report ok"
1195else
1196 report "🛑 report ko with $NB_REPORT reports"
1197 EXIT_CODE=1
1198fi
1199
1200quiet_git checkout main
1201
1202##### verify commit
1203report "🏁 verify commits"
1204
1205cd /tmp/${ROOT_REPO_NAME}
1206quiet_git checkout main
1207quiet_git pull origin main
1208echo "- purl: ${STIGMA_WASM}" >> .gitroot/plugins.yml
1209echo " active: true" >> .gitroot/plugins.yml
1210quiet_git add .
1211quiet_git commit -m "init stigma plugin"
1212push_and_wait origin main
1213wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-stigma"
1214push_and_wait origin main
1215quiet_git pull origin main
1216report "🟢 ${ROOT_REPO_NAME} stigma plugin installed"
1217
1218cd /tmp/${ROOT_REPO_NAME}
1219cat .gitroot/allowed_signers >> $MY_LOG
1220git reflog show main | awk '{ print $1 }' | xargs git verify-commit &>> $MY_LOG
1221report "🟢 ${ROOT_REPO_NAME}"
1222
1223cd /tmp/${REPO1_NAME}
1224push_and_wait origin main
1225quiet_git pull origin main
1226sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1227quiet_git add .
1228quiet_git commit -m "active stigma plugin"
1229push_and_wait origin main
1230
1231quiet_git pull origin main
1232cat .gitroot/allowed_signers >> $MY_LOG
1233git reflog show main | awk '{ print $1 }' | xargs git verify-commit &>> $MY_LOG
1234report "🟢 ${REPO1_NAME}"
1235
1236cd /tmp/${REPO2_NAME}
1237push_and_wait origin main
1238quiet_git pull origin main
1239sed -i -e 's/active: false/active: true/g' .gitroot/plugins.yml
1240quiet_git add .
1241quiet_git commit -m "active stigma plugin"
1242quiet_git push origin main
1243mySleep 1
1244quiet_git pull origin main
1245cat .gitroot/allowed_signers >> $MY_LOG
1246# TODO reactive when stigma plugin can add old user
1247# git reflog show main | awk '{ print $1 }' | xargs git verify-commit &>> $MY_LOG
1248# report "🟢 ${REPO2_NAME}"
1249
1250##### verify schedule
1251report "🏁 verify schedule"
1252
1253cd /tmp/${ROOT_REPO_NAME}
1254quiet_git checkout main
1255quiet_git pull origin main
1256echo "- purl: ${FIREFLY_WASM}" >> .gitroot/plugins.yml
1257echo " active: true" >> .gitroot/plugins.yml
1258quiet_git add .
1259quiet_git commit -m "init firefly plugin"
1260push_and_wait origin main
1261wait_ls "${SERVER_DATA_DIR}/data/plugins/gitroot-firefly"
1262push_and_wait origin main
1263quiet_git pull origin main
1264report "🟢 ${ROOT_REPO_NAME} firefly plugin installed"
1265
1266##### Finish
1267report "🏁 Finish"
1268if grep -q -i "level=ERROR" $MY_LOG
1269then
1270 report "🛑 Logs contains error"
1271 EXIT_CODE=1
1272else
1273 report "🟢 Logs no error"
1274fi
1275
1276if grep -q -i "WARNING: DATA RACE" $MY_LOG
1277then
1278 report "🛑 Logs contains data race"
1279 EXIT_CODE=1
1280else
1281 report "🟢 Logs no data race"
1282fi
1283
1284report ""
1285report "✎ Find all logs in $MY_LOG"
1286exit $EXIT_CODE