-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: "Run Salesforce Code Scanner" | ||
description: "Run Prettier on the code" | ||
inputs: | ||
pathToValidate: | ||
description: "The path to the files we want to validate" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Print inputs | ||
shell: bash | ||
run: | | ||
echo "Path to validate: ${{ inputs.pathToValidate }}" | ||
- name: Check if sf cli and code analyzer is installed | ||
id: checkInstallationStatus | ||
shell: bash | ||
run: | | ||
needToInstallSfCli=false | ||
needToInstallSfCodeAnalyzer=false | ||
package='@salesforce/cli' | ||
plugin='@salesforce/sfdx-scanner' | ||
if [ `npm list -g | grep -c $package` -eq 0 ]; then | ||
echo $package is not installed | ||
needToInstallSfCli=true | ||
elif [ `sf plugins | grep -c $plugin` -eq 0 ]; then | ||
echo $package is installed, need to install $plugin. | ||
needToInstallSfCodeAnalyzer=true | ||
else | ||
echo $package and $plugin is installed. | ||
fi | ||
echo "needToInstallSfCli=$needToInstallSfCli" >> $GITHUB_OUTPUT | ||
echo "needToInstallSfCodeAnalyzer=$needToInstallSfCodeAnalyzer" >> $GITHUB_OUTPUT | ||
- id: installSfCli | ||
if: ${{ steps.checkInstallationStatus.outputs.needToInstallSfCli }} | ||
uses: navikt/crm-workflows-base/.github/actions/installSF@master | ||
|
||
- id: installSfCodeAnalyzer | ||
if: ${{ steps.checkInstallationStatus.outputs.needToInstallSfCodeAnalyzer }} | ||
shell: bash | ||
run: | | ||
sf plugins install @salesforce/sfdx-scanner | ||
- name: Run Salesforce Code Analyzer | ||
id: run-code-analyzer | ||
uses: forcedotcom/run-code-analyzer@v1 | ||
with: | ||
run-command: run | ||
run-arguments: --normalize-severity --outfile results.html --target ${{ inputs.pathToValidate }} | ||
results-artifact-name: salesforce-code-analyzer-results | ||
|
||
- name: Check the Salesforce Code Analyzer outputs to determine whether to fail | ||
shell: bash | ||
if: | | ||
steps.run-code-analyzer.outputs.exit-code > 0 || | ||
steps.run-code-analyzer.outputs.num-sev1-violations > 0 || | ||
steps.run-code-analyzer.outputs.num-violations > 10 | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters