Skip to content

Commit

Permalink
fix: count of scanned files when running on push event
Browse files Browse the repository at this point in the history
When running on push we scan all shell scripts.
  • Loading branch information
jamacku committed Aug 17, 2023
1 parent 1785b3b commit e17e5e4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Added defect statistics based on severity levels. They are available in the console output and in the job Summary page.
* New option `scan-directory`. Allows to specify directories that will be scanned. By default Differential ShellCheck scans the whole repository.
* Fix detection of changed files that might cause failure on paths with special characters.
* Fix count of scanned files in job Summary when running on push event.
* Drop support for `shell-scripts` input
* Drop support for `ignored-codes` input
* Update `csutils` (`csdiff`) to 3.0.3
Expand Down
9 changes: 8 additions & 1 deletion src/summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ diff_scan_summary () {
local added_issues
added_issues=$(get_number_of defects)

local list_of_changed_scripts
if [[ "${#all_scripts[@]}" -le 0 ]] && [[ "${#only_changed_scripts[@]}" -le 0 ]]; then
list_of_changed_scripts=()
else
list_of_changed_scripts=("${all_scripts[@]:-${only_changed_scripts[@]}}")
fi

echo -e "\
Changed scripts: \`${#only_changed_scripts[@]}\`
Scanned/Changed scripts: \`${#list_of_changed_scripts[@]}\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand Down
10 changes: 6 additions & 4 deletions test/diff_scan_summary.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setup () {
load 'test_helper/bats-support/load'
}

@test "diff_scan_summary()" {
@test "diff_scan_summary() - general" {
source "${PROJECT_ROOT}/src/summary.sh"

export only_changed_scripts=("1.sh" "\$2.sh" "3 .sh")
Expand All @@ -35,7 +35,7 @@ src/index.sh:7:3: note[SC1091]: Not following: functions.sh: openBinaryFile: doe
run diff_scan_summary
assert_success
assert_output \
"Changed scripts: \`3\`
"Scanned/Changed scripts: \`3\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand All @@ -53,7 +53,7 @@ src/index.sh:7:3: note[SC1091]: Not following: functions.sh: openBinaryFile: doe
run diff_scan_summary
assert_success
assert_output \
"Changed scripts: \`3\`
"Scanned/Changed scripts: \`3\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand All @@ -64,14 +64,15 @@ src/index.sh:7:3: note[SC1091]: Not following: functions.sh: openBinaryFile: doe
source "${PROJECT_ROOT}/src/summary.sh"

export only_changed_scripts=()
export all_scripts=()
INPUT_TRIGGERING_EVENT=""

touch ../defects.log ../fixes.log

run diff_scan_summary
assert_success
assert_output \
"Changed scripts: \`0\`
"Scanned/Changed scripts: \`0\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand All @@ -83,5 +84,6 @@ teardown () {

export \
only_changed_scripts="" \
all_scripts="" \
INPUT_TRIGGERING_EVENT=""
}
14 changes: 8 additions & 6 deletions test/summary.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ src/index.sh:7:3: note[SC1091]: Not following: functions.sh: openBinaryFile: doe
assert_output \
"### Differential ShellCheck 🐚
Changed scripts: \`3\`
Scanned/Changed scripts: \`3\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand Down Expand Up @@ -93,7 +93,7 @@ src/index.sh:7:3: note[SC1091]: Not following: functions.sh: openBinaryFile: doe
assert_output \
"### Differential ShellCheck 🐚
Changed scripts: \`3\`
Scanned/Changed scripts: \`3\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand Down Expand Up @@ -147,7 +147,7 @@ src/index.sh:7:3: note[SC1091]: Not following: functions.sh: openBinaryFile: doe
assert_output \
"### Differential ShellCheck 🐚
Changed scripts: \`3\`
Scanned/Changed scripts: \`3\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand Down Expand Up @@ -183,7 +183,7 @@ _ℹ️ If you have an issue with this GitHub action, please try to run it in th
assert_output \
"### Differential ShellCheck 🐚
Changed scripts: \`3\`
Scanned/Changed scripts: \`3\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand All @@ -209,6 +209,7 @@ _ℹ️ If you have an issue with this GitHub action, please try to run it in th
source "${PROJECT_ROOT}/src/summary.sh"

export only_changed_scripts=()
export all_scripts=()
INPUT_TRIGGERING_EVENT=""
INPUT_SEVERITY="style"

Expand All @@ -219,7 +220,7 @@ _ℹ️ If you have an issue with this GitHub action, please try to run it in th
assert_output \
"### Differential ShellCheck 🐚
Changed scripts: \`0\`
Scanned/Changed scripts: \`0\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand Down Expand Up @@ -270,7 +271,7 @@ src/index.sh:7:3: note[SC1091]: Not following: functions.sh: openBinaryFile: doe
assert_output \
"### Differential ShellCheck 🐚
Changed scripts: \`0\`
Scanned/Changed scripts: \`3\`
| | ❌ Added | ✅ Fixed |
|:------------------:|:------------------------:|:------------------------:|
Expand Down Expand Up @@ -350,6 +351,7 @@ teardown () {

export \
only_changed_scripts="" \
all_scripts="" \
INPUT_TRIGGERING_EVENT="" \
INPUT_SEVERITY="" \
GITHUB_REPOSITORY="" \
Expand Down

0 comments on commit e17e5e4

Please sign in to comment.