forked from microsoft/scitt-ccf-ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci-checks.sh
executable file
·55 lines (44 loc) · 1.25 KB
/
ci-checks.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
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
set -e
if [ "$1" == "-f" ]; then
FIX=1
else
FIX=0
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$( dirname "$SCRIPT_DIR" )
pushd "$ROOT_DIR" > /dev/null
echo "-- C/C++ format"
if [ $FIX -ne 0 ]; then
"$SCRIPT_DIR"/check-format.sh -f app
else
"$SCRIPT_DIR"/check-format.sh app
fi
echo "-- Python dependencies"
# Virtual Environment w/ dependencies for Python steps
if [ ! -f "scripts/venv/bin/activate" ]
then
python3.8 -m venv scripts/venv
fi
source scripts/venv/bin/activate
pip install --disable-pip-version-check -q -U black isort mypy wheel
pip install --disable-pip-version-check -q -e ./pyscitt
pip install --disable-pip-version-check -q -r test/requirements.txt
echo "-- Python types"
git ls-files | grep -e '\.py$' | xargs mypy
echo "-- Python imports"
if [ $FIX -ne 0 ]; then
git ls-files | grep -e '\.py$' | xargs isort
else
git ls-files | grep -e '\.py$' | xargs isort --check
fi
echo "-- Python format"
if [ $FIX -ne 0 ]; then
git ls-files | grep -e '\.py$' | xargs black
else
git ls-files | grep -e '\.py$' | xargs black --check
fi
echo "-- Copyright notices headers"
python3.8 "$SCRIPT_DIR"/notice-check.py