Skip to content

Commit f0252f2

Browse files
authored
move ci checks to scripts (#7766)
* move ci checks to scripts * no sh * bash
1 parent 623faa3 commit f0252f2

File tree

3 files changed

+47
-42
lines changed

3 files changed

+47
-42
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -259,51 +259,11 @@ jobs:
259259
- name: Check exception tracking
260260
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
261261
run: |
262-
problematic_files=()
263-
while read -r file; do
264-
if ! grep -qE '^{\.push raises: \[\](, gcsafe)?\.}$' "$file"; then
265-
problematic_files+=("$file")
266-
fi
267-
done < <(git diff --name-only --diff-filter=AM --ignore-submodules HEAD^ HEAD | grep -E '\.nim$' || true)
268-
269-
if (( ${#problematic_files[@]} )); then
270-
echo "The following files do not have '{.push raises: [], gcsafe.}' (gcsafe optional):"
271-
for file in "${problematic_files[@]}"; do
272-
echo "- $file"
273-
done
274-
echo "See https://status-im.github.io/nim-style-guide/errors.exceptions.html"
275-
exit 2
276-
fi
277-
262+
scripts/check_exception_headers.sh
278263
- name: Check submodules
279264
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
280265
run: |
281-
while read -r file; do
282-
commit="$(git -C "$file" rev-parse HEAD)"
283-
commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local HEAD)
284-
if ! branch="$(git config -f .gitmodules --get "submodule.$file.branch")"; then
285-
echo "Submodule '$file': '.gitmodules' lacks 'branch' entry"
286-
exit 2
287-
fi
288-
# Without the `--depth=1` fetch, may run into 'error processing shallow info: 4'
289-
if ! error="$(git -C "$file" fetch -q --depth=1 origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then
290-
echo "Submodule '$file': Failed to fetch '$branch': $error (1)"
291-
exit 2
292-
fi
293-
branch_commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local "refs/remotes/origin/${branch}")
294-
if [[ "${commit_date}" > "${branch_commit_date}" ]]; then
295-
echo "Submodule '$file': '$commit' ($commit_date) is more recent than latest '$branch' ($branch_commit_date) (branch config: '.gitmodules')"
296-
exit 2
297-
fi
298-
if ! error="$(git -C "$file" fetch -q --shallow-since="$commit_date" origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then
299-
echo "Submodule '$file': Failed to fetch '$branch': $error (2)"
300-
exit 2
301-
fi
302-
if ! git -C "$file" merge-base --is-ancestor "$commit" "refs/remotes/origin/$branch"; then
303-
echo "Submodule '$file': '$commit' is not on '$branch' as of $commit_date (branch config: '.gitmodules')"
304-
exit 2
305-
fi
306-
done < <(git diff --name-only --diff-filter=AM HEAD^ HEAD | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true)
266+
scripts/check_submodule_branches.sh
307267
308268
# https://github.com/EnricoMi/publish-unit-test-result-action
309269
event_file:

scripts/check_exception_headers.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
problematic_files=()
4+
while read -r file; do
5+
if ! grep -qE '^{\.push raises: \[\](, gcsafe)?\.}$' "$file"; then
6+
problematic_files+=("$file")
7+
fi
8+
done < <(git diff --name-only --diff-filter=AM --ignore-submodules HEAD^ | grep -E '\.nim$' || true)
9+
10+
if (( ${#problematic_files[@]} )); then
11+
echo "The following files do not have '{.push raises: [], gcsafe.}' (gcsafe optional):"
12+
for file in "${problematic_files[@]}"; do
13+
echo "- $file"
14+
done
15+
echo "See https://status-im.github.io/nim-style-guide/errors.exceptions.html"
16+
exit 2
17+
fi
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
while read -r file; do
4+
commit="$(git -C "$file" rev-parse HEAD)"
5+
commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local HEAD)
6+
if ! branch="$(git config -f .gitmodules --get "submodule.$file.branch")"; then
7+
echo "Submodule '$file': '.gitmodules' lacks 'branch' entry"
8+
exit 2
9+
fi
10+
# Without the `--depth=1` fetch, may run into 'error processing shallow info: 4'
11+
if ! error="$(git -C "$file" fetch -q --depth=1 origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then
12+
echo "Submodule '$file': Failed to fetch '$branch': $error (1)"
13+
exit 2
14+
fi
15+
branch_commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local "refs/remotes/origin/${branch}")
16+
if [[ "${commit_date}" > "${branch_commit_date}" ]]; then
17+
echo "Submodule '$file': '$commit' ($commit_date) is more recent than latest '$branch' ($branch_commit_date) (branch config: '.gitmodules')"
18+
exit 2
19+
fi
20+
if ! error="$(git -C "$file" fetch -q --shallow-since="$commit_date" origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then
21+
echo "Submodule '$file': Failed to fetch '$branch': $error (2)"
22+
exit 2
23+
fi
24+
if ! git -C "$file" merge-base --is-ancestor "$commit" "refs/remotes/origin/$branch"; then
25+
echo "Submodule '$file': '$commit' is not on '$branch' as of $commit_date (branch config: '.gitmodules')"
26+
exit 2
27+
fi
28+
done < <(git diff --name-only --diff-filter=AM HEAD^ | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true)

0 commit comments

Comments
 (0)