diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index 78cded610..fdf6cdcad 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -36,6 +36,14 @@ jobs: echo "MAIN_STATS<> $GITHUB_ENV echo -e "$MAIN_STATS" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV + - name: Capture main branch sample clips + id: main-samples + run: | + npm start & command_pid=$! + sleep 5 + npm run generate_samples + kill $command_pid + mv samples samples-main - name: Checkout PR Branch 🛎️ uses: actions/checkout@v3 - name: Use Node.js 18.16.1 @@ -52,6 +60,14 @@ jobs: cp src/configs/config.aws.js src/config.js mkdir -p dist/shield-docs cp -r shieldlib/docs/* dist/shield-docs + - name: Capture PR branch sample clips + id: pr-samples + run: | + npm start & command_pid=$! + sleep 5 + npm run generate_samples + kill $command_pid + mv samples samples-pr - name: Upload Build artifact uses: actions/upload-artifact@v3 with: @@ -71,6 +87,11 @@ jobs: echo '${{ env.MAIN_STATS }}' echo '${{ env.PR_STATS }}' npm exec ts-node scripts/stats_compare '${{ env.MAIN_STATS }}' '${{ env.PR_STATS }}' > pr/stats-difference.md + - name: Generate map diff sample clips + id: map-diff-samples + run: | + mv sample_differences.md pr/ + mv samples-diff pr/ - name: Save PR artifacts env: PR_NUMBER: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/deploy-pr-checks.yml b/.github/workflows/deploy-pr-checks.yml index 19e11ef17..3c02cdbf5 100644 --- a/.github/workflows/deploy-pr-checks.yml +++ b/.github/workflows/deploy-pr-checks.yml @@ -109,7 +109,11 @@ jobs: + + ## Map sample differences + " > pr_preview.md + echo pr/sample_differences.md >> pr_preview.md - uses: tibdex/github-app-token@v1 id: checks_token with: diff --git a/scripts/folder_diff.sh b/scripts/folder_diff.sh new file mode 100755 index 000000000..178508e57 --- /dev/null +++ b/scripts/folder_diff.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Compare two folders of images and produce an .md file of differences + +# Check if the right number of arguments are passed +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +FOLDER1="$1" +FOLDER2="$2" +OUTPUT_FOLDER="samples-diff" + +# Create the output folder if it doesn't exist +mkdir -p "$OUTPUT_FOLDER" + +# Loop through files in FOLDER1 +for file in "$FOLDER1"/*.png; do + # Extract just the base filename without the path + basefile=$(basename "$file") + + # Check if file exists in FOLDER2 + if [ -e "$FOLDER2/$basefile" ]; then + # Compare the files + cmp -s "$FOLDER1/$basefile" "$FOLDER2/$basefile" + + # If files are different ($? is the exit status of last command, 1 means different for cmp) + if [ $? -eq 1 ]; then + # Copy the files to the output folder with the appropriate naming scheme + cp "$FOLDER1/$basefile" "$OUTPUT_FOLDER/${basefile%.*}_before.png" + cp "$FOLDER2/$basefile" "$OUTPUT_FOLDER/${basefile%.*}_after.png" + fi + fi +done + +OUTPUT_MD="sample_differences.md" + +# Start the table with headers +echo "| Sample Name | Before | After |" > $OUTPUT_MD +echo "|-------------|--------|-------|" >> $OUTPUT_MD + +# Loop through *_before.png files in the output folder +for before_file in "$OUTPUT_FOLDER"/*_before.png; do + # Extract just the base filename without the path and the '_before' suffix + basefile=$(basename "$before_file" _before.png) + + # Construct the path to the corresponding after file + after_file="$OUTPUT_FOLDER/${basefile}_after.png" + + # Check if the after file exists + if [ -e "$after_file" ]; then + # Add an entry to the markdown table + echo "| $basefile | ![before]($before_file) | ![after]($after_file) |" >> $OUTPUT_MD + fi +done diff --git a/src/js/shield_defs.js b/src/js/shield_defs.js index c1085579c..03358868f 100644 --- a/src/js/shield_defs.js +++ b/src/js/shield_defs.js @@ -509,7 +509,7 @@ export function loadShields() { textColor: Color.shields.brown, colorLighten: Color.shields.brown, }, - ["HIST"], + ["XYZA"], //Change to be removed before merging Color.shields.brown );