Skip to content

Commit 58aad13

Browse files
committed
Merge remote-tracking branch 'origin/rc/barnard' into update-vm-barnard
2 parents cbc0d69 + 675a2b7 commit 58aad13

File tree

4 files changed

+142
-27
lines changed

4 files changed

+142
-27
lines changed

.github/workflows/build_and_run_chain_simulator_and_execute_system_test.yml

Lines changed: 135 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ jobs:
117117
uses: actions/setup-go@v5
118118
with:
119119
go-version: 1.23.6
120+
cache: false
120121
id: go
121122

122123
- name: Checkout mx-chain-go
@@ -142,7 +143,17 @@ jobs:
142143
TS=$(date +'%Y_%^B_%d__%H_%M_%S');
143144
echo "TS=$TS" >> "$GITHUB_ENV"
144145
echo "TIMESTAMP=$TS" >> "$GITHUB_ENV"
146+
147+
# Fix any interrupted dpkg operations first
148+
sudo dpkg --configure -a || true
149+
150+
# Clean up any partial packages
151+
sudo apt-get clean
152+
sudo apt-get autoclean
153+
154+
# Update package lists and install rclone
145155
sudo apt-get update -y && sudo apt-get install -y rclone
156+
146157
mkdir -p ~/.config/rclone
147158
cat > ~/.config/rclone/rclone.conf <<EOF
148159
[r2]
@@ -276,17 +287,55 @@ jobs:
276287
run: |
277288
set +e
278289
pytest mx-chain-testing-suite/scenarios/ --html=report.html --self-contained-html --continue-on-collection-errors
279-
PYTEST_EXIT_CODE=$?
290+
INITIAL_PYTEST_EXIT_CODE=$?
280291
set -e
281-
echo "PYTEST_EXIT_CODE=$PYTEST_EXIT_CODE" >> $GITHUB_ENV
282-
echo "Pytest exit code: $PYTEST_EXIT_CODE"
292+
293+
echo "Initial pytest exit code: $INITIAL_PYTEST_EXIT_CODE"
294+
295+
# Parse the HTML report to determine actual test status
296+
FINAL_PYTEST_EXIT_CODE=$INITIAL_PYTEST_EXIT_CODE
297+
283298
if [ -f "report.html" ]; then
284299
echo "Report generated successfully."
300+
301+
# Extract test summary from HTML report using multiple parsing approaches
302+
FAILED_TESTS=$(grep -E '[0-9]+ Failed|Failed.*[0-9]+' report.html | head -1 | grep -o '[0-9]\+' | head -1 || echo "0")
303+
ERROR_TESTS=$(grep -E '[0-9]+ Errors|Errors.*[0-9]+' report.html | head -1 | grep -o '[0-9]\+' | head -1 || echo "0")
304+
RERUN_TESTS=$(grep -E '[0-9]+ Reruns|Reruns.*[0-9]+' report.html | head -1 | grep -o '[0-9]\+' | head -1 || echo "0")
305+
306+
# Fallback: check for "0 Failed" pattern directly
307+
if grep -q "0 Failed" report.html && [ "$INITIAL_PYTEST_EXIT_CODE" -ne 0 ]; then
308+
echo "Detected '0 Failed' pattern in report despite non-zero exit code - likely successful reruns"
309+
FAILED_TESTS=0
310+
fi
311+
312+
echo "Failed tests: $FAILED_TESTS"
313+
echo "Error tests: $ERROR_TESTS"
314+
echo "Rerun tests: $RERUN_TESTS"
315+
316+
# Determine final status based on actual test results
317+
if [ "$FAILED_TESTS" -eq 0 ] && [ "$ERROR_TESTS" -eq 0 ]; then
318+
if [ "$RERUN_TESTS" -gt 0 ]; then
319+
echo "✅ All tests passed after $RERUN_TESTS reruns - considering as SUCCESS"
320+
else
321+
echo "✅ All tests passed on first attempt"
322+
fi
323+
FINAL_PYTEST_EXIT_CODE=0
324+
else
325+
echo "❌ Tests have genuine failures: $FAILED_TESTS failed, $ERROR_TESTS errors"
326+
FINAL_PYTEST_EXIT_CODE=1
327+
fi
328+
329+
# Move report to reports directory
285330
mkdir -p ./reports
286331
mv report.html ./reports/
287332
else
288-
echo "Report not found."
333+
echo "❌ Report not found - using original exit code"
334+
FINAL_PYTEST_EXIT_CODE=$INITIAL_PYTEST_EXIT_CODE
289335
fi
336+
337+
echo "PYTEST_EXIT_CODE=$FINAL_PYTEST_EXIT_CODE" >> $GITHUB_ENV
338+
echo "Final pytest exit code: $FINAL_PYTEST_EXIT_CODE"
290339
291340
- name: Stage report for R2
292341
run: |
@@ -362,8 +411,11 @@ jobs:
362411
done
363412
echo "</ul></body></html>" >> index.html
364413
git add index.html
365-
git commit -m "Update Index of Reports"
366-
git push origin gh-pages --force
414+
if git commit -m "Update Index of Reports"; then
415+
git push origin gh-pages --force
416+
else
417+
echo "No changes to commit. Nothing to push."
418+
fi
367419
else
368420
mkdir -p docs
369421
cd docs
@@ -479,4 +531,80 @@ jobs:
479531
exit 1
480532
else
481533
echo "Tests passed successfully."
482-
fi
534+
fi
535+
536+
537+
- name: Cleanup Workspace and Processes
538+
if: always()
539+
run: |
540+
echo "🧹 Starting SAFE cleanup for job ${{ github.run_id }}..."
541+
542+
# Get current working directory to limit cleanup scope
543+
WORKSPACE_DIR=$(pwd)
544+
echo "Workspace directory: $WORKSPACE_DIR"
545+
546+
# 1. Kill only OUR ChainSimulator processes (by checking working directory)
547+
echo "Killing ChainSimulator processes from this workspace..."
548+
for pid in $(pgrep -f "chainsimulator"); do
549+
if [ -n "$pid" ]; then
550+
CWD=$(pwdx $pid 2>/dev/null | awk '{print $2}' || echo "")
551+
if [[ "$CWD" == *"$WORKSPACE_DIR"* ]]; then
552+
echo "Killing chainsimulator process $pid from our workspace"
553+
kill -TERM $pid 2>/dev/null || true
554+
sleep 2
555+
kill -9 $pid 2>/dev/null || true
556+
fi
557+
fi
558+
done
559+
560+
# 2. Kill only OUR pytest processes (by checking if they're in our workspace)
561+
echo "Killing pytest processes from this workspace..."
562+
for pid in $(pgrep -f "pytest.*scenarios"); do
563+
if [ -n "$pid" ]; then
564+
CWD=$(pwdx $pid 2>/dev/null | awk '{print $2}' || echo "")
565+
if [[ "$CWD" == *"$WORKSPACE_DIR"* ]]; then
566+
echo "Killing pytest process $pid from our workspace"
567+
kill -TERM $pid 2>/dev/null || true
568+
fi
569+
fi
570+
done
571+
572+
# 3. Remove only OUR temporary files (with unique identifiers)
573+
echo "Removing temporary files from this job..."
574+
rm -f /tmp/chainsim_init_${{ github.run_id }}.log || true
575+
rm -f /tmp/chain_simulator_initialized_${{ github.run_id }}.lock || true
576+
# Only remove temp files that might be from this job (be very specific)
577+
rm -f /tmp/chainsim_init.log || true # Only if we created it without job ID
578+
rm -f /tmp/chain_simulator_initialized.lock || true # Only if we created it without job ID
579+
580+
# 4. Clean up ONLY our workspace directories
581+
echo "Cleaning up workspace directories..."
582+
rm -rf "$WORKSPACE_DIR/mx-chain-go" || true
583+
rm -rf "$WORKSPACE_DIR/mx-chain-simulator-go" || true
584+
rm -rf "$WORKSPACE_DIR/mx-chain-testing-suite" || true
585+
rm -rf "$WORKSPACE_DIR/reports" || true
586+
rm -rf "$WORKSPACE_DIR/r2_upload" || true
587+
rm -f "$WORKSPACE_DIR/report.html" || true
588+
589+
# 5. Clean up Python cache ONLY in our workspace
590+
echo "Cleaning Python cache in workspace..."
591+
find "$WORKSPACE_DIR" -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
592+
find "$WORKSPACE_DIR" -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
593+
find "$WORKSPACE_DIR" -type f -name "*.pyc" -delete 2>/dev/null || true
594+
595+
# 6. Check disk space (informational only)
596+
echo "Checking remaining disk space..."
597+
df -h "$WORKSPACE_DIR" || true
598+
599+
# 7. Show what processes are still running FROM OUR WORKSPACE (for debugging)
600+
echo "Checking for remaining processes from our workspace:"
601+
for pid in $(pgrep -f "chainsimulator\|pytest.*scenarios"); do
602+
if [ -n "$pid" ]; then
603+
CWD=$(pwdx $pid 2>/dev/null | awk '{print $2}' || echo "unknown")
604+
if [[ "$CWD" == *"$WORKSPACE_DIR"* ]]; then
605+
echo "⚠️ Process $pid still running from our workspace: $CWD"
606+
fi
607+
fi
608+
done
609+
610+
echo "✅ Safe cleanup completed for job ${{ github.run_id }}!"

.github/workflows/build_and_test_on_macos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
uses: actions/setup-go@v5
1818
with:
1919
go-version: 1.23.6
20+
cache: false
2021
id: go
2122

2223
- name: Check out code into the Go module directory

.github/workflows/code-coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
uses: actions/setup-go@v5
2121
with:
2222
go-version: 1.23.6
23+
cache: false
2324
id: go
2425

2526
- name: Check out code into the Go module directory

testscommon/dataRetriever/poolFactory.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package dataRetriever
22

33
import (
44
"fmt"
5-
"os"
65
"time"
76

87
"github.com/multiversx/mx-chain-core-go/marshal"
@@ -15,8 +14,8 @@ import (
1514
"github.com/multiversx/mx-chain-go/dataRetriever/shardedData"
1615
"github.com/multiversx/mx-chain-go/dataRetriever/txpool"
1716
"github.com/multiversx/mx-chain-go/storage/cache"
18-
storageFactory "github.com/multiversx/mx-chain-go/storage/factory"
1917
"github.com/multiversx/mx-chain-go/storage/storageunit"
18+
"github.com/multiversx/mx-chain-go/testscommon"
2019
"github.com/multiversx/mx-chain-go/testscommon/txcachemocks"
2120
"github.com/multiversx/mx-chain-go/trie/factory"
2221
)
@@ -84,32 +83,18 @@ func createPoolHolderArgs(numShards uint32, selfShard uint32) dataPool.DataPoolA
8483

8584
cacherConfig = storageunit.CacheConfig{Capacity: 50000, Type: storageunit.LRUCache}
8685
cacher, err := cache.NewCapacityLRU(10, 10000)
87-
panicIfError("Create trieSync cacher", err)
88-
89-
tempDir, _ := os.MkdirTemp("", "integrationTests")
90-
91-
dbConfig := config.DBConfig{
92-
FilePath: tempDir,
93-
Type: string(storageunit.LvlDBSerial),
94-
BatchDelaySeconds: 4,
95-
MaxBatchSize: 10000,
96-
MaxOpenFiles: 10,
97-
}
98-
99-
persisterFactory, err := storageFactory.NewPersisterFactory(dbConfig)
100-
panicIfError("Create persister factory", err)
86+
panicIfError("CreatePoolsHolder", err)
10187

102-
persister, err := persisterFactory.CreateWithRetries(tempDir)
103-
panicIfError("Create trieSync DB", err)
88+
db := testscommon.NewMemDbMock()
10489
tnf := factory.NewTrieNodeFactory()
10590

10691
adaptedTrieNodesStorage, err := storageunit.NewStorageCacherAdapter(
10792
cacher,
108-
persister,
93+
db,
10994
tnf,
11095
&marshal.GogoProtoMarshalizer{},
11196
)
112-
panicIfError("Create AdaptedTrieNodesStorage", err)
97+
panicIfError("CreatePoolsHolder", err)
11398

11499
trieNodesChunks, err := storageunit.NewCache(cacherConfig)
115100
panicIfError("CreatePoolsHolder", err)

0 commit comments

Comments
 (0)