generated from aboutcode-org/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_scancode_version_compare.sh
executable file
·129 lines (94 loc) · 4.33 KB
/
run_scancode_version_compare.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#! /bin/bash
# Halt script on error
set -e
# Set up a clean environment
./configure --clean
./configure --dev
# Activate the Virtual Environment
source venv/bin/activate
# Fail if New and Old version numbers don't exist
if [[ "$VERSION_OLD" == "" ]]; then
echo "VERSION_OLD must be provided as an environment variable"
exit 1
fi
if [[ "$VERSION_NEW" == "" ]]; then
echo "VERSION_NEW must be provided as an environment variable"
exit 1
fi
# Get the latest commit
COMMIT_LATEST="$(git log -1 --format=format:'%h' --abbrev-commit)"
echo "Installing and Running Scans for scancode-toolkit $VERSION_OLD"
echo "---------------------------------------------------------"
echo ""
# Install and run scans for the Old Scancode Version
pip install scancode-toolkit==$VERSION_OLD --force-reinstall
# Sample -clipeu
OLD_JSON_PATH="./docs/source/outputs/latest/json/scancode-$VERSION_OLD-clipeu-$COMMIT_LATEST.json"
OLD_YAML_PATH="./docs/source/outputs/latest/yaml/scancode-$VERSION_OLD-clipeu-$COMMIT_LATEST.yaml"
scancode -clipeu --json-pp $OLD_JSON_PATH --yaml $OLD_YAML_PATH ./scan-data/samples/
# Packages -p
PACKAGES_OLD_JSON_PATH="./docs/source/outputs/latest/json/scancode-$VERSION_OLD-packages-$COMMIT_LATEST.json"
PACKAGES_OLD_YAML_PATH="./docs/source/outputs/latest/yaml/scancode-$VERSION_OLD-packages-$COMMIT_LATEST.yaml"
scancode -p --json-pp $PACKAGES_OLD_JSON_PATH --yaml $PACKAGES_OLD_YAML_PATH ./scan-data/packages/python-sample/
echo "Installing and Running Scans for scancode-toolkit $VERSION_NEW"
echo "---------------------------------------------------------"
echo ""
# Force reinstall the New Scancode Version and run scans again
pip install scancode-toolkit==$VERSION_NEW --force-reinstall
# Sample -clipeu
NEW_JSON_PATH="./docs/source/outputs/latest/json/scancode-$VERSION_NEW-clipeu-$COMMIT_LATEST.json"
NEW_YAML_PATH="./docs/source/outputs/latest/yaml/scancode-$VERSION_NEW-clipeu-$COMMIT_LATEST.yaml"
scancode -clipeu --json-pp $NEW_JSON_PATH --yaml $NEW_YAML_PATH ./scan-data/samples/
# Packages -p
PACKAGES_NEW_JSON_PATH="./docs/source/outputs/latest/json/scancode-$VERSION_NEW-packages-$COMMIT_LATEST.json"
PACKAGES_NEW_YAML_PATH="./docs/source/outputs/latest/yaml/scancode-$VERSION_NEW-packages-$COMMIT_LATEST.yaml"
scancode -p --json-pp $PACKAGES_NEW_JSON_PATH --yaml $PACKAGES_NEW_YAML_PATH ./scan-data/packages/python-sample/
echo "Running Scans successful!"
echo "---------------------------------------------------------"
echo ""
# Clean up scan header files to generate cleaner diffs
python3 ./etc/scripts/clean_json_yaml_scan_headers.py \
--json "$OLD_JSON_PATH" \
--yaml "$OLD_YAML_PATH"
python3 ./etc/scripts/clean_json_yaml_scan_headers.py \
--json "$PACKAGES_OLD_JSON_PATH" \
--yaml "$PACKAGES_OLD_YAML_PATH"
python3 ./etc/scripts/clean_json_yaml_scan_headers.py \
--json "$NEW_JSON_PATH" \
--yaml "$NEW_YAML_PATH"
python3 ./etc/scripts/clean_json_yaml_scan_headers.py \
--json "$PACKAGES_NEW_JSON_PATH" \
--yaml "$PACKAGES_NEW_YAML_PATH"
# Set the values in cookiecutter.json
python3 ./etc/scripts/modify_cookiecutter_json.py \
--cookiecutter-location ./templates/cookiecutter.json \
--new-version "$VERSION_NEW" \
--old-version "$VERSION_OLD" \
--latest-commit "$COMMIT_LATEST"
# Create the .rst file with the cookiecutter template
pip install cookiecutter
cookiecutter templates --no-input
mv latest/* docs/source/outputs/latest/
rm -r latest/
echo "Generating Documentation successful! \n"
echo "---------------------------------------------------------"
echo ""
echo " outputs/latest/clipeu-v$VERSION_NEW-v$VERSION_OLD-$COMMIT_LATEST" >> ./docs/source/index.rst
echo " outputs/latest/packages-v$VERSION_NEW-v$VERSION_OLD-$COMMIT_LATEST" >> ./docs/source/index.rst
echo " latest/clipeu-v$VERSION_NEW-v$VERSION_OLD-$COMMIT_LATEST" >> ./docs/source/outputs/index.rst
echo " latest/packages-v$VERSION_NEW-v$VERSION_OLD-$COMMIT_LATEST" >> ./docs/source/outputs/index.rst
echo "Generated Documentation added to toctree!"
echo "---------------------------------------------------------"
echo ""
./configure --docs
cd docs
./scripts/sphinx_build_link_check.sh
./scripts/doc8_style_check.sh
make html
echo "Documentation build successful!"
echo "---------------------------------------------------------"
echo ""
if [[ "$SHOW_DOCS" == "TRUE" ]]; then
see build/html/index.html
exit 1
fi