@@ -5,6 +5,10 @@ branding:
5
5
color : gray-dark
6
6
icon : chevrons-up
7
7
inputs :
8
+ path :
9
+ description : " Relative path from your project root to the codebase to scanned"
10
+ required : false
11
+ default : " "
8
12
config_file :
9
13
description : " Optionally provide a path to your codeclimate.yml relative to your project"
10
14
required : false
57
61
shell : bash
58
62
id : cc
59
63
env :
64
+ CC_CODE : ${{ github.workspace }}/${{ inputs.path }}
60
65
CC_CONF : ${{ inputs.config_file }}
61
66
CC_BLOCKERS_ALLOWED : ${{ inputs.blocker_threshold }}
62
67
CC_CRITICAL_ALLOWED : ${{ inputs.critical_threshold }}
69
74
# and accuracy
70
75
71
76
echo "#### CONFIG ####"
72
- if [ -f .codeclimate.yml ] || cp "$CC_CONF" .codeclimate.yml; then
77
+ if [ cp "$CC_CONF" "$CC_CODE/ .codeclimate.yml" ; then
73
78
echo "Found codeclimate config, using that"
74
79
else
75
80
echo "::warning::No configuration found, using Code Climate's default configuration"
@@ -78,14 +83,14 @@ runs:
78
83
# Run once for JSON output
79
84
echo "#### INITIAL RUN ####"
80
85
docker run \
81
- --env CODECLIMATE_CODE="$PWD " \
82
- --volume "$PWD ":/code \
86
+ --env CODECLIMATE_CODE="$CC_CODE " \
87
+ --volume "$CC_CODE ":/code \
83
88
--volume /var/run/docker.sock:/var/run/docker.sock \
84
89
--volume /tmp/cc:/tmp/cc \
85
90
codeclimate/codeclimate analyze -f json > raw.json
86
91
87
92
# Strip the json to only issues
88
- jq -c 'map(select(.type | test("issue"; "i")))' raw.json > codeclimate-report.json
93
+ jq -c 'map(select(.type | test("issue"; "i")))' "$CC_CODE/ raw.json" > codeclimate-report.json
89
94
90
95
# Parse to provide simple job output
91
96
TOTAL_ISSUES=$(jq '. | length' codeclimate-report.json)
@@ -108,6 +113,7 @@ runs:
108
113
- name : Generate HTML Report
109
114
shell : bash
110
115
env :
116
+ CC_CODE : ${{ github.workspace }}/${{ inputs.path }}
111
117
CC_CONF : ${{ inputs.config_file }}
112
118
HTML_REPORT : ${{ inputs.html_report }}
113
119
run : |
@@ -117,20 +123,21 @@ runs:
117
123
# and accuracy
118
124
119
125
echo "#### CONFIG ####"
120
- if [ -f .codeclimate.yml ] || cp "$CC_CONF" .codeclimate.yml; then
121
- echo "Found codeclimate.yml at project root "
126
+ if [ cp "$CC_CONF" "$CC_CODE/ .codeclimate.yml" ; then
127
+ echo "Found codeclimate config, using that "
122
128
else
123
129
echo "::warning::No configuration found, using Code Climate's default configuration"
124
130
fi
125
131
126
132
# Run for HTML output
127
133
echo "#### GENERATING HTML VERSION ####"
128
134
docker run \
129
- --env CODECLIMATE_CODE="$PWD " \
130
- --volume "$PWD ":/code \
135
+ --env CODECLIMATE_CODE="$CC_CODE " \
136
+ --volume "$CC_CODE ":/code \
131
137
--volume /var/run/docker.sock:/var/run/docker.sock \
132
138
--volume /tmp/cc:/tmp/cc \
133
139
codeclimate/codeclimate analyze -f html > codeclimate-report.html
140
+ mv "$CC_CODE/codeclimate-report.html" codeclimate-report.html
134
141
else
135
142
echo "HTML REPORT not requested, skipping..."
136
143
fi
0 commit comments