Skip to content

Commit

Permalink
docs: Document cache folder (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfyda authored May 11, 2020
1 parent 6d29565 commit 2552c69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Or use the flag: `--codacy-api-base-url <Codacy_instance_URL>:16006`.

## Running Codacy Coverage Reporter

### Requirements
### Requirements

- `bash` or `sh` (Use `bash` on Ubuntu)
- `curl` or `wget`
Expand Down Expand Up @@ -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`
Expand Down
14 changes: 8 additions & 6 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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\""
}
Expand All @@ -140,7 +142,7 @@ else
fi

if [ -z "$run_command" ]
then
then
fatal "Codacy coverage reporter command could not be found."
fi

Expand Down

0 comments on commit 2552c69

Please sign in to comment.