From 2552c69cc39b21c5a5561383ae52a20dcf85ff12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Mon, 11 May 2020 09:38:31 +0100 Subject: [PATCH] docs: Document cache folder (#206) --- README.md | 6 +++++- get.sh | 14 ++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3781d7ab..c9be34eb 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Or use the flag: `--codacy-api-base-url :16006`. ## Running Codacy Coverage Reporter -### Requirements +### Requirements - `bash` or `sh` (Use `bash` on Ubuntu) - `curl` or `wget` @@ -122,6 +122,10 @@ If you are sending reports with the partial flag for a certain language you shou It might also be possible to merge the reports before uploading them to Codacy, since most coverage tools support merge/aggregation, example: http://www.eclemma.org/jacoco/trunk/doc/merge-mojo.html. +## Caching + +The reporter downloads itself to a new folder named `.codacy-coverage` in the current working directory. To prevent downloading the reporter for every command, you can add this folder to your CI cache. You can specify your cache folder by setting the `CODACY_REPORTER_TMP_FOLDER` variable. For example: `CODACY_REPORTER_TMP_FOLDER=/tmp/.codacy-coverage`. + ## Other commands For a complete list of commands and options: `--help` diff --git a/get.sh b/get.sh index 348d38d1..2180962c 100755 --- a/get.sh +++ b/get.sh @@ -9,8 +9,6 @@ e="\033[0;31m" # error l="\033[0;90m" # log test r="\033[0m" # reset -# Temporary folder for downloaded files -codacy_temp_folder=".codacy-coverage" # Logger # This function log messages @@ -67,7 +65,11 @@ exit_trap() { trap exit_trap EXIT trap 'fatal Interrupted' INT -mkdir -p "$codacy_temp_folder" +# Temporary folder for downloaded files +if [ -z "$CODACY_REPORTER_TMP_FOLDER" ]; then + CODACY_REPORTER_TMP_FOLDER=".codacy-coverage" +fi +mkdir -p "$CODACY_REPORTER_TMP_FOLDER" if [ -z "$CODACY_REPORTER_VERSION" ]; then CODACY_REPORTER_VERSION="latest" @@ -117,14 +119,14 @@ run() { codacy_reporter_native_start_cmd() { local suffix=$1 - local codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter" + local codacy_reporter="$CODACY_REPORTER_TMP_FOLDER/codacy-coverage-reporter" download_coverage_reporter "codacy-coverage-reporter-$suffix" "$codacy_reporter" chmod +x $codacy_reporter run_command="$codacy_reporter" } codacy_reporter_jar_start_cmd() { - local codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter-assembly.jar" + local codacy_reporter="$CODACY_REPORTER_TMP_FOLDER/codacy-coverage-reporter-assembly.jar" download_coverage_reporter "codacy-coverage-reporter-assembly.jar" "$codacy_reporter" run_command="java -jar \"$codacy_reporter\"" } @@ -140,7 +142,7 @@ else fi if [ -z "$run_command" ] -then +then fatal "Codacy coverage reporter command could not be found." fi