Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ branding:
color: gray-dark
icon: chevrons-up
inputs:
working_directory:
description: "The directory to run Code Climate in"
required: false
config_file:
description: "Optionally provide a path to your codeclimate.yml relative to your project"
required: false
Expand Down Expand Up @@ -49,13 +52,21 @@ outputs:
blocker_findings:
description: "The number of findings of severity BLOCKER"
value: ${{ steps.cc.outputs.blocker }}
html_report:
description: "The HTML report generated by Code Climate (if requested)"
value: ${{ steps.html.outputs.html_report }}
json_report:
description: "The JSON report generated by Code Climate"
value: ${{ steps.cc.outputs.json_report }}

runs:
using: "composite"
steps:
# Initial Run is performed to get the results in a parseable format
- name: Code Climate
shell: bash
id: cc
working-directory: ${{ inputs.working_directory && format('{0}/{1}', github.workspace, inputs.working_directory) || github.workspace }}
env:
CC_CONF: ${{ inputs.config_file }}
CC_BLOCKERS_ALLOWED: ${{ inputs.blocker_threshold }}
Expand Down Expand Up @@ -102,11 +113,14 @@ runs:
echo "major=$TOTAL_MAJOR" >> $GITHUB_OUTPUT
echo "critical=$TOTAL_CRITICAL" >> $GITHUB_OUTPUT
echo "blocker=$TOTAL_BLOCKER" >> $GITHUB_OUTPUT
echo "json_report=$PWD/codeclimate-report.json" >> $GITHUB_OUTPUT

# Second run purely to get the readable HTML report. The second run is much faster than the first
# as it does not need to redownload the images already pulled by the first run
- name: Generate HTML Report
shell: bash
id: html
working-directory: ${{ inputs.working_directory && format('{0}/{1}', github.workspace, inputs.working_directory) || github.workspace }}
env:
CC_CONF: ${{ inputs.config_file }}
HTML_REPORT: ${{ inputs.html_report }}
Expand All @@ -131,13 +145,16 @@ runs:
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /tmp/cc:/tmp/cc \
codeclimate/codeclimate analyze -f html > codeclimate-report.html
echo "html_report=$PWD/codeclimate-report.html" >> $GITHUB_OUTPUT
else
echo "HTML REPORT not requested, skipping..."
echo "html_report=" >> $GITHUB_OUTPUT
fi

# Determine the result
- name: Parse Result
shell: bash
working-directory: ${{ inputs.working_directory && format('{0}/{1}', github.workspace, inputs.working_directory) || github.workspace }}
env:
CC_BLOCKERS_ALLOWED: ${{ inputs.blocker_threshold }}
CC_CRITICAL_ALLOWED: ${{ inputs.critical_threshold }}
Expand Down