-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI task to validate file extension (#3196)
The dotnet squad would like to improve the rule specification sprint process requiring some UTs to be temporarily added under the rule folder on RSPEC repository. These test case files (`.cs` and `.vb`) will be copied to the sonar-dotnet repository during the initial phases of implementation and will serve as an initial test bed. However, before merging the PR on the RSPEC side we need to make sure that these test case files are deleted and they don't end up on master. The goal of this PR would be to add a check on the pipeline that will fail if `.cs` or `.vb` files are detected (it's acceptable if it's red until the implementation is done).
- Loading branch information
1 parent
7c129a0
commit ea83931
Showing
2 changed files
with
35 additions
and
0 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
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,25 @@ | ||
#!/bin/bash | ||
# | ||
# Validates that there are no files with .cs, .vb, .razor or .cshtml extensions present inside rules folder. | ||
# | ||
# As part of the new DotNet squad rule specification sprint guidelines, test case files similar to the ones | ||
# used for unit tests in sonar-dotnet should be temporarely added under the rule folder on RSPEC repository. | ||
# Those files can be of any number for both C# (*.cs, *.razor, *.cshtml) and VB.NET (.*vb). | ||
# The test case files will be copied to the sonar-dotnet repository during the initial phases of implementation | ||
# and will serve as an initial test bed. | ||
# Before merging the PR on the RSPEC side, it is important to ensure that these test case files are deleted. | ||
# The script make sure to fail the CI if any of those previously mentioned files are present inside the rules folder. | ||
set -euxo pipefail | ||
|
||
TOPLEVEL="$(realpath .)" | ||
RULES_DIR="${TOPLEVEL}/rules" | ||
CSVB_FILES=($(find "${RULES_DIR}" -type f -name "*.cs" -o -name "*.vb" -o -name "*.razor" -o -name "*.cshtml")) | ||
|
||
if [ ${#CSVB_FILES[@]} -gt 0 ]; then | ||
echo "ERROR: '.cs','.vb','.razor' or '.cshtml' files are detected." | ||
printf '%s\n' "${CSVB_FILES[@]}" | ||
exit 1 | ||
else | ||
echo "SUCCESS: no '.cs' or '.vb' files detected." | ||
exit 0 | ||
fi |