-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·69 lines (61 loc) · 1.96 KB
/
test.sh
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
#!/bin/bash
# Tests for the ruff snap.
set -e
cleanup(){
rm -rf ruff-snap-test-*
}
trap cleanup EXIT
summary_file="${GITHUB_STEP_SUMMARY:-/dev/stderr}"
repositories(){
echo https://github.com/canonical/snapcraft
echo https://github.com/canonical/charmcraft
echo https://github.com/canonical/rockcraft
echo https://github.com/jupyter-server/jupyter_server
echo https://github.com/pydantic/pydantic
echo https://github.com/pypa/pip
echo https://github.com/pytest-dev/pytest
echo https://github.com/python/mypy
echo https://github.com/tiangolo/fastapi
}
test_repo(){
echo "::group::Repository: ${repo}"
local repo_dir=$(mktemp --directory ruff-snap-test-XXXXXXXX)
git clone --depth=1 $1 $repo_dir
echo -n "| ${repo} | $(cd $repo_dir; git rev-parse --short HEAD) | " >> $summary_file
if (cd "${repo_dir}"; ruff check); then
echo -n "✅ | " >> $summary_file
else
echo -n "❌ | " >> $summary_file
fi
if (cd "${repo_dir}"; ruff check --preview --fix --unsafe-fixes); then
echo -n "✅ | " >> $summary_file
else
echo -n "❌ | " >> $summary_file
fi
if (cd "${repo_dir}"; ruff format); then
echo -n "✅ | " >> $summary_file
else
echo -n "❌ | " >> $summary_file
fi
if (cd "${repo_dir}"; ruff format --preview); then
echo "✅ | " >> $summary_file
else
echo "❌ | " >> $summary_file
fi
echo "::endgroup::"
echo "$check_result"
}
echo -n "ruff version: " >> $summary_file
ruff version | tee -a $summary_file
echo "::endgroup::"
echo "::group::Help"
ruff help
echo "::endgroup::"
echo "::group::Rules:"
ruff rule --all
echo "::endgroup::"
echo "| Repository | Commit | Standard check | Check + preview + fix | Format | Format + preview |" >> $summary_file
echo "|------------|--------|----------------|-----------------------|--------|------------------|" >> $summary_file
for repo in $(repositories); do
test_repo "${repo}"
done