Skip to content

Commit 5fe6d23

Browse files
committed
scripts: add new script
Add not_respecting_some_naming_conventions.fsx script to detect if some naming conventions are respected. Fixes #93
1 parent c1901e1 commit 5fe6d23

17 files changed

+57
-14
lines changed

.github/workflows/CI.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Compile the conventions solution
3333
run: dotnet build --configuration Release conventions.sln
3434
- name: Compile F# scripts
35-
run: dotnet fsi scripts/compileFSharpScripts.fsx
35+
run: dotnet fsi scripts/compile_fsharp_scripts.fsx
3636

3737
file-conventions-tests:
3838
name: Run FileConventions-lib unit tests
@@ -166,30 +166,32 @@ jobs:
166166
apt install --yes --no-install-recommends dotnet6
167167
168168
- name: Check all files end with EOL
169-
run: dotnet fsi scripts/eofConvention.fsx
169+
run: dotnet fsi scripts/eof_convention.fsx
170170
- name: Check all .fsx scripts have shebang
171-
run: dotnet fsi scripts/shebangConvention.fsx
171+
run: dotnet fsi scripts/shebang_convention.fsx
172172
- name: Check all F# scripts have execute permission
173-
run: dotnet fsi scripts/executableConvention.fsx
173+
run: dotnet fsi scripts/executable_convention.fsx
174174
- name: Check there are no mixed line-endings in any files
175-
run: dotnet fsi scripts/mixedLineEndings.fsx
175+
run: dotnet fsi scripts/mixed_line_endings.fsx
176176
- name: Check there are no unpinned GitHubActions image versions
177-
run: dotnet fsi scripts/unpinnedGitHubActionsImageVersions.fsx
177+
run: dotnet fsi scripts/unpinned_github_actions_image_versions.fsx
178178
- name: Check there are no unpinned dotnet package versions
179-
run: dotnet fsi scripts/unpinnedDotnetPackageVersions.fsx
179+
run: dotnet fsi scripts/unpinned_dotnet_package_versions.fsx
180180
- name: Check there are no unpinned nuget package reference versions in F# scripts
181-
run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersions.fsx
181+
run: dotnet fsi scripts/unpinned_nuget_package_reference_versions.fsx
182182
- name: Check there are no unpinned versions in `dotnet tool install` commands
183-
run: dotnet fsi scripts/unpinnedDotnetToolInstallVersions.fsx
183+
run: dotnet fsi scripts/unpinned_dotnet_tool_install_versions.fsx
184+
- name: Check if script names (.fsx, .bat, and .sh files) are snake_case and CI job names are kebab-case.
185+
run: dotnet fsi scripts/not_respecting_some_naming_conventions.fsx
184186
- name: Check commits 1 by 1
185187
if: github.event_name == 'pull_request'
186-
run: dotnet fsi scripts/checkCommits1by1.fsx
188+
run: dotnet fsi scripts/check_commits_1by1.fsx
187189
- name: Check there are no inconsistent versions GitHubCI files
188-
run: dotnet fsi scripts/inconsistentVersionsInGitHubCI.fsx
190+
run: dotnet fsi scripts/inconsistent_versions_in_githubci.fsx
189191
- name: Check there are no inconsistent versions in nuget package references of F# scripts
190-
run: dotnet fsi scripts/inconsistentVersionsInFSharpScripts.fsx
192+
run: dotnet fsi scripts/inconsistent_versions_in_fsharp_scripts.fsx
191193
- name: Check there are no non-verbose flags in scripts and CI YML files
192-
run: dotnet fsi scripts/nonVerboseFlagsInGitHubCIAndScripts.fsx
194+
run: dotnet fsi scripts/non_verbose_flags_in_githubci_and_scripts.fsx
193195
- name: Install prettier
194196
run: npm install [email protected]
195197
- name: Change file permissions

scripts/checkCommits1by1.fsx renamed to scripts/check_commits_1by1.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ if notUsedGitPush1by1 then
920920
sprintf
921921
"Please push the commits one by one to make sure every commit has a CI status; using this script is recommended:%s%s"
922922
Environment.NewLine
923-
"https://github.com/nblockchain/conventions/blob/master/scripts/gitPush1by1.fsx"
923+
"https://github.com/nblockchain/conventions/blob/master/scripts/git_push_1by1.fsx"
924924

925925
Console.Error.WriteLine errMsg
926926
Environment.Exit 2
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env -S dotnet fsi
2+
3+
open System
4+
open System.IO
5+
6+
#r "nuget: YamlDotNet, Version=13.0.2"
7+
#load "../src/FileConventions/Library.fs"
8+
#load "../src/FileConventions/Helpers.fs"
9+
10+
let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo
11+
12+
let invalidYmlFiles =
13+
Helpers.GetInvalidFiles
14+
rootDir
15+
"*.yml"
16+
FileConventions.DetectNotUsingKebabCaseInGitHubCIJobs
17+
18+
Helpers.AssertNoInvalidFiles
19+
invalidYmlFiles
20+
"Please use kebab-case for CI job names in the following files:"
21+
22+
let scriptExtensions =
23+
seq {
24+
".fsx"
25+
".bat"
26+
".sh"
27+
}
28+
29+
let scriptsWithInvalidNames =
30+
scriptExtensions
31+
|> Seq.map(fun extension ->
32+
Helpers.GetInvalidFiles
33+
rootDir
34+
("*" + extension)
35+
FileConventions.DetectNotUsingSnakeCaseInScriptName
36+
)
37+
|> Seq.concat
38+
39+
Helpers.AssertNoInvalidFiles
40+
scriptsWithInvalidNames
41+
"Please use snake_case for naming the following scripts:"
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)