-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcheck.sh
More file actions
executable file
·105 lines (92 loc) · 2.4 KB
/
check.sh
File metadata and controls
executable file
·105 lines (92 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh -e
if [ -n "$VERBOSE" ] || [ "$GITHUB_RUN_ATTEMPT" != 1 ]; then
set -x
fi
dhall_json="$(eval echo "$DHALL_JSON_BINARY")"
dhall_haskell="$(eval echo "$DHALL_HASKELL_BINARY")"
dhall_json_archive=$(mktemp)
curl -Lsf "$dhall_json" -o "$dhall_json_archive"
dhall_json_extracted=$(mktemp -d)
tar -xjf "$dhall_json_archive" -C "$dhall_json_extracted"
PATH="$dhall_json_extracted/bin:$PATH"
dhall_haskell_archive=$(mktemp)
curl -Lsf "$dhall_haskell" -o "$dhall_haskell_archive"
dhall_haskell_extracted=$(mktemp -d)
tar -xjf "$dhall_haskell_archive" -C "$dhall_haskell_extracted"
PATH="$dhall_haskell_extracted/bin:$PATH"
echo "::add-matcher::$GITHUB_ACTION_PATH/dhall-checker.json"
if [ -z "$XDG_CACHE_HOME" ]; then
export XDG_CACHE_HOME=/tmp/dhall-cache
mkdir -p "$XDG_CACHE_HOME"
echo "XDG_CACHE_HOME=$XDG_CACHE_HOME" >> "$GITHUB_ENV"
fi
if [ -n "$DHALL_CACHE_URL" ]; then
dhall_cache=$(mktemp)
curl -sSL "$DHALL_CACHE_URL" -o "$dhall_cache"
(
cd "$XDG_CACHE_HOME"
tar xf "$dhall_cache"
root_items="$(
tar tf "$dhall_cache" |
perl -pe 's!/.*!!' |
uniq
)"
if [ $(echo "$root_items" | wc -l) = 1 ] ; then
mv "$root_items"/* .
rmdir "$root_items"
fi
)
fi
export DHALL_FAILURES=$(mktemp -d)
if [ -z "$LIST" ]; then
export LIST=$(mktemp)
fi
if [ -n "$FILES" ]; then
echo "$FILES" | grep . | tr "\n" "\0" >> "$LIST"
fi
if ! grep -q . "$LIST"; then
echo "::notice::No Dhall files to check."
exit 0
fi
if [ -z "$PARALLEL_JOBS" ]; then
PARALLEL_JOBS=2
fi
if [ -n "$LINT" ]; then
echo "::group::lint"
if ! cat "$LIST" | xargs -0 "$GITHUB_ACTION_PATH/dhall-linter"; then
echo '::error::Linting failed. Use `dhall lint` locally to fix the errors.'
exit 1
fi
echo '::notice::Linting passed.'
echo "::endgroup::"
fi
cat "$LIST" |
xargs -0 "-P$PARALLEL_JOBS" -r -n1 $GITHUB_ACTION_PATH/dhall-checker 2>/dev/null
if [ -n "$RETRY_FAILED_FILES" ]; then
files="$(cd $DHALL_FAILURES; find . -type f)"
if [ -z "$files" ]; then
exit 0
fi
old_failures=$DHALL_FAILURES
DHALL_FAILURES=$(mktemp -d)
echo
echo "Rechecking serially..."
echo
for file in $files; do
dhall_file=$(cat "$old_failures/$file")
(
$GITHUB_ACTION_PATH/dhall-checker $dhall_file
)
done
fi
cd $DHALL_FAILURES
files="$(find . -type f)"
if [ -z "$files" ]; then
exit 0
fi
echo
echo "Errors detected in:"
for file in $files; do
cat $file
done
exit 1