Skip to content

Commit f89dbd4

Browse files
random commit
1 parent a7344b3 commit f89dbd4

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

tests/on_target/scripts/update_memory_badges.sh

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,38 @@ handle_error() {
2929
exit 0
3030
}
3131

32-
# Generate badge files using Python script
33-
echo "Generating badge files..."
34-
./tests/on_target/scripts/parse_memory_stats.py "$BUILD_LOG" "tests/on_target" || handle_error "Failed to generate badge files"
35-
36-
3732
# Configure Git
3833
git config --global --add safe.directory "$(pwd)"
3934
git config --global user.email "github-actions@github.com"
4035
git config --global user.name "GitHub Actions"
4136

42-
# Ensure the gh-pages branch exists and switch to it
37+
# Create a temporary directory for gh-pages content
38+
TEMP_DIR=$(mktemp -d)
39+
40+
# Fetch existing CSV files from gh-pages branch
4341
git fetch origin gh-pages
42+
git show origin/gh-pages:docs/ram_history.csv > "$TEMP_DIR/ram_history.csv" || touch "$TEMP_DIR/ram_history.csv"
43+
git show origin/gh-pages:docs/flash_history.csv > "$TEMP_DIR/flash_history.csv" || touch "$TEMP_DIR/flash_history.csv"
44+
45+
# Generate badge files and append to existing CSV files
46+
echo "Generating badge files..."
47+
./tests/on_target/scripts/parse_memory_stats.py "$BUILD_LOG" "$TEMP_DIR" || handle_error "Failed to generate badge files"
48+
49+
# Switch to gh-pages branch and update files
4450
git checkout gh-pages || handle_error "Not able to checkout gh-pages"
4551
git pull origin gh-pages || handle_error "Failed to pull latest gh-pages"
4652

47-
# Stage, commit, and push changes to the branch
48-
cp $FLASH_BADGE_FILE $FLASH_BADGE_FILE_DEST
49-
cp $RAM_BADGE_FILE $RAM_BADGE_FILE_DEST
50-
cp $FLASH_HISTORY_CSV $FLASH_HISTORY_CSV_DEST
51-
cp $RAM_HISTORY_CSV $RAM_HISTORY_CSV_DEST
52-
cp $FLASH_PLOT_HTML $FLASH_PLOT_HTML_DEST
53-
cp $RAM_PLOT_HTML $RAM_PLOT_HTML_DEST
53+
# Copy all files to docs/
54+
mkdir -p docs
55+
cp "$TEMP_DIR"/*.json docs/
56+
cp "$TEMP_DIR"/*.csv docs/
57+
cp "$TEMP_DIR"/*.html docs/
5458

5559
git add $FLASH_BADGE_FILE_DEST $RAM_BADGE_FILE_DEST \
5660
$FLASH_HISTORY_CSV_DEST $RAM_HISTORY_CSV_DEST \
5761
$FLASH_PLOT_HTML_DEST $RAM_PLOT_HTML_DEST
5862
git commit -m "Update memory usage badges"
5963
git push origin gh-pages
64+
65+
# Clean up
66+
rm -rf "$TEMP_DIR"

0 commit comments

Comments
 (0)