Skip to content

Instantly share code, notes, and snippets.

@jwmatthews
Created April 16, 2024 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwmatthews/f54e8b5af304ce477418c9ed1b60e7ad to your computer and use it in GitHub Desktop.
Save jwmatthews/f54e8b5af304ce477418c9ed1b60e7ad to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
SOURCE_DIR="coolstore"
SOURCE_ONLY=""
# If you want to run with source only uncomment below
# SOURCE_ONLY="-m source-only"
# We are experimenting with modifying some of the default Kantra rules from:
# . https://github.com/konveyor/rulesets/tree/main/default/generated
DEFAULT_RULES_DIR="${PWD}/default_rules"
CUSTOM_RULES_DIR="${PWD}/../samples/custom_rules"
# Choose to either analyze the initial or solved branch
# Then comment out/in the appropriate below
BRANCH="main"
OUTDIR=${PWD}/analysis/${SOURCE_DIR}/
#BRANCH="quarkus"
#OUTDIR=${PWD}/tmp/${SOURCE_DIR}/solved
KANTRA_BIN="${PWD}/../samples/bin/kantra"
# CHECK that bin exits, exit if not
if [[ ! -f ${KANTRA_BIN} ]]; then
echo "Kantra binary not found at ${KANTRA_BIN}"
echo "Please look at '${CWD}/../samples/macos/get_latest_kantra_cli.sh' for example of how to get Kantra"
exit 1
fi
# Ensure that the source has been fetched
if [[ ! -d "${PWD}"/"${SOURCE_DIR}" ]]; then
echo "Source directory not found at ${PWD}/${SOURCE_DIR}"
echo "Please ensure you checkout the application source code to analyze"
echo "Run: ./fetch.sh"
exit 1
fi
# ####
# Ensure we are on the expected branch before analysis.
# We are typically working with 2 branches an initial/solved
# It's been a common problem to forget which and create invalid analysis runs
# ####
pushd .
cd "${PWD}"/"${SOURCE_DIR}" || exit
git checkout "${BRANCH}"
popd || exit
mkdir -p "${OUTDIR}"
time "${KANTRA_BIN}" analyze -i "${PWD}"/"${SOURCE_DIR}" "${SOURCE_ONLY}" --enable-default-rulesets=false -t "quarkus" -t "jakarta-ee" -t "jakarta-ee8+" -t "jakarta-ee9+" -t "cloud-readiness" --rules "${DEFAULT_RULES_DIR}" --rules "${CUSTOM_RULES_DIR}" -o "${OUTDIR}" --overwrite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment