mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-09 15:57:56 -05:00
56 lines
2.0 KiB
YAML
56 lines
2.0 KiB
YAML
name: Publish Plots
|
|
description: "Publish plots in performance_plots branch and add to the workflow summary"
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Clone the performance_plots branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ github.repository }}
|
|
ref: ${{ env.PUBLISH_BRANCH_NAME }}
|
|
path: ${{ env.CHECKOUT_SUBFOLDER_SUBPLOTS }}
|
|
fetch-depth: 0
|
|
|
|
- name: Commit & push plots
|
|
shell: bash
|
|
run: |
|
|
cd $CHECKOUT_SUBFOLDER_SUBPLOTS
|
|
git fetch origin "$PUBLISH_BRANCH_NAME"
|
|
git reset --hard "origin/$PUBLISH_BRANCH_NAME"
|
|
|
|
# Remove any branch folder older than 7 days
|
|
DAYS=7
|
|
cutoff=$(( $(date +%s) - DAYS*24*3600 ))
|
|
scan_dir="${PUBLISH_DIR_PLOTS%/}"
|
|
find "$scan_dir" -mindepth 1 -maxdepth 1 -type d -print0 \
|
|
| while IFS= read -r -d $'\0' d; do \
|
|
ts=$(git log -1 --format=%ct -- "$d" 2>/dev/null || true); \
|
|
if [ -n "$ts" ] && [ "$ts" -le "$cutoff" ]; then \
|
|
echo "[cleanup] Deleting: $d"; \
|
|
rm -rf -- "$d"; \
|
|
fi; \
|
|
done
|
|
|
|
rm -rf $PUBLISH_DIR_PLOTS/$BRANCH_NAME
|
|
mkdir -p $PUBLISH_DIR_PLOTS/$BRANCH_NAME
|
|
|
|
cp ../$SHARED_VOLUME_PATH/*.png $PUBLISH_DIR_PLOTS/$BRANCH_NAME/ 2>/dev/null || true
|
|
cp ../$LATENCY_HISTORY_PATH/*.png $PUBLISH_DIR_PLOTS/ 2>/dev/null || true
|
|
git add -A "$PUBLISH_DIR_PLOTS/"
|
|
|
|
git status
|
|
|
|
if git diff-index --quiet HEAD --; then
|
|
echo "No changes to commit"
|
|
else
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git config user.name "github-actions[bot]"
|
|
git commit -m "Update performance plots for $BRANCH_NAME"
|
|
git push origin $PUBLISH_BRANCH_NAME
|
|
fi
|
|
|
|
- name: Add plots to GitHub Actions summary
|
|
shell: bash
|
|
run: |
|
|
nim c -r -d:release -o:/tmp/add_plots_to_summary ./performance/scripts/add_plots_to_summary.nim |