Skip to content

Commit d05fed0

Browse files
committed
double-check images that fail
1 parent dff6773 commit d05fed0

File tree

1 file changed

+50
-20
lines changed

1 file changed

+50
-20
lines changed

.circleci/orca-build-verify.sh

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ BASELINES=$ROOT/test/image/baselines
77
TEST_IMAGES=$ROOT/build/test_images
88
DIFF_IMAGES=$ROOT/build/test_images_diff
99

10+
get_mock_path()
11+
{
12+
echo "$MOCKS/$1.json"
13+
}
14+
export -f get_mock_path
15+
16+
get_image_path()
17+
{
18+
echo "$TEST_IMAGES/$1.png"
19+
}
20+
1021
# Deterministic shuffling (https://www.gnu.org/software/coreutils/manual/html_node/Random-sources.html)
1122
get_seeded_random()
1223
{
@@ -31,39 +42,58 @@ else
3142
CIRCLE_NODE_INDEX=0
3243
fi
3344

45+
rm -f /tmp/all
3446
if [[ $# -eq 0 ]]; then
35-
echo "No arguments provided"
36-
FIGURE=$(ls $MOCKS/*.json)
47+
ls $MOCKS/*.json | xargs -I{} -n1 basename {} .json > /tmp/all
3748
else
3849
for var in "$@"
3950
do
40-
FIGURE="$FIGURE $MOCKS/$var.json "
51+
echo "$var" >> /tmp/all
4152
done
4253
fi
4354

44-
echo $FIGURE | tr " " "\n" | deterministic_shuffle > /tmp/all
45-
split -d -a3 -n l/$CIRCLE_NODE_TOTAL /tmp/all /tmp/queue
55+
cat /tmp/all | \
56+
# Shuffle to distribute randomly slow and fast mocks
57+
deterministic_shuffle > /tmp/shuffled_all
4658

59+
# Split on each node
60+
split -d -a3 -n l/$CIRCLE_NODE_TOTAL /tmp/shuffled_all /tmp/queue
4761
NODE_QUEUE="/tmp/queue$(printf "%03d" $CIRCLE_NODE_INDEX)"
4862

4963
echo ""
50-
echo "Generating test images"
51-
cat $NODE_QUEUE | awk '!/mapbox/' | \
52-
# Shuffle to distribute randomly slow and fast mocks
53-
deterministic_shuffle | \
54-
# head -n 10 | \
55-
# Split in chunks of 20
56-
xargs -P1 -n20 xvfb-run -a orca graph --verbose --output-dir $TEST_IMAGES
64+
function generate()
65+
{
66+
echo "Generating test images"
67+
cat $1 | awk '!/mapbox/' | \
68+
xargs -n1 -I{} echo "$MOCKS/{}.json" | \
69+
# Split in chunks of 20
70+
xargs -P1 -n20 xvfb-run -a orca graph --verbose --output-dir $TEST_IMAGES
71+
}
72+
generate $NODE_QUEUE
5773

58-
echo "Comparing with baselines"
59-
find $TEST_IMAGES -type f -name "*.png" -printf "%f\n" | \
60-
# shuf | \
61-
# sort | \
62-
# head -n 20 | \
63-
# xargs -n1 -P16 -I {} bash -c "echo {} && ./node_modules/.bin/pixelmatch $1/{} $2/{} diff/{} 0 true" | tee results.txt
64-
xargs -n1 -P`nproc` -I {} bash -c "compare -verbose -metric AE $TEST_IMAGES/{} $BASELINES/{} $DIFF_IMAGES/{} 2> $DIFF_IMAGES/{}.txt"
74+
function compare()
75+
{
76+
echo "Comparing with baselines"
77+
cat $1 | awk '!/mapbox/' | \
78+
#find $TEST_IMAGES -type f -name "*.png" -printf "%f\n" | \
79+
# shuf | \
80+
# sort | \
81+
# head -n 20 | \
82+
# xargs -n1 -P16 -I {} bash -c "echo {} && ./node_modules/.bin/pixelmatch $1/{} $2/{} diff/{} 0 true" | tee results.txt
83+
xargs -n1 -P`nproc` -I {} bash -c "compare -verbose -metric AE $TEST_IMAGES/{} $BASELINES/{} $DIFF_IMAGES/{} 2> $DIFF_IMAGES/{}.txt"
84+
}
85+
compare $NODE_QUEUE
6586

6687
CODE=$(grep -R "all: [^0]" $DIFF_IMAGES/ | wc -l)
67-
grep -l -R "all: [^0]" $DIFF_IMAGES/ | gawk '{match($0, /diff\/([^.]*)/, arr); print arr[1]}'
88+
89+
# If there are different images, retry
90+
if [ "$CODE" -ne "0" ]; then
91+
grep -l -R "all: [^0]" $DIFF_IMAGES/ | gawk '{match($0, /diff\/([^.]*)/, arr); print arr[1]}' > /tmp/failed
92+
echo "Retrying the following $CODE images"
93+
cat /tmp/failed
94+
generate /tmp/failed
95+
compare /tmp/failed
96+
CODE=$(grep -R "all: [^0]" $DIFF_IMAGES/ | wc -l)
97+
fi
6898
echo "$CODE different images"
6999
exit $CODE

0 commit comments

Comments
 (0)