-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·47 lines (41 loc) · 1.41 KB
/
run.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
#!/usr/bin/env bash
set -e
# Login into Docker and pull analyzer images
function setup_docker {
echo "Logging in to Docker with GH_PAT_DEEPSOURCE.."
docker login ghcr.io -u USERNAME --password "$GH_PAT_DEEPSOURCE"
# Pull the latest images for various languages
local languages=("go" "java" "javascript" "python" "docker" "ruby" "csharp")
for lang in "${languages[@]}"; do
echo "Pulling image for $lang.."
docker pull "ghcr.io/quackatronhq/$lang:latest"
done
}
case "$1" in
cleanup)
# Removes local files generated by the script
rm -f analysis_config.json analysis_results* configgen* run.sh
;;
setup)
if [[ -z "$GH_PAT_DEEPSOURCE" ]]; then
echo "Error: GH_PAT_DEEPSOURCE environment variable is not set."
exit 1
fi
setup_docker
echo "Downloading config generator script.."
wget -q https://github.com/QuackatronHQ/analyze/raw/master/configgen -O configgen
chmod +x configgen
;;
analyze)
# This will convert .deepsource.toml config file to analysis_config.json (an intermediate format that the analyzer understands)
echo "Running config generator and analysis.."
./configgen -code "$2" -language "$3"
docker run -v "$2":/code "ghcr.io/quackatronhq/$3"
echo "Prettifying analysis results.."
jq . "analysis_results_$3.json" > "analysis_results_$3_pretty.json"
;;
*)
echo "Usage: $0 {cleanup|setup|analyze}"
exit 1
;;
esac