Skip to content

Commit 40691f8

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 9eb406d commit 40691f8

12 files changed

+54
-11
lines changed

.github/workflows/CI.yml

Lines changed: 12 additions & 10 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
@@ -150,22 +150,24 @@ jobs:
150150
apt install --yes --no-install-recommends dotnet6
151151
152152
- name: Check all files end with EOL
153-
run: dotnet fsi scripts/eofConvention.fsx
153+
run: dotnet fsi scripts/eof_convention.fsx
154154
- name: Check all .fsx scripts have shebang
155-
run: dotnet fsi scripts/shebangConvention.fsx
155+
run: dotnet fsi scripts/shebang_convention.fsx
156156
- name: Check there are no mixed line-endings in any files
157-
run: dotnet fsi scripts/mixedLineEndings.fsx
157+
run: dotnet fsi scripts/mixed_line_endings.fsx
158158
- name: Check there are no unpinned GitHubActions image versions
159-
run: dotnet fsi scripts/unpinnedGitHubActionsImageVersions.fsx
159+
run: dotnet fsi scripts/unpinned_github_actions_image_versions.fsx
160160
- name: Check there are no unpinned dotnet package versions
161-
run: dotnet fsi scripts/unpinnedDotnetPackageVersions.fsx
161+
run: dotnet fsi scripts/unpinned_dotnet_package_versions.fsx
162162
- name: Check there are no unpinned nuget package reference versions in F# scripts
163-
run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersions.fsx
163+
run: dotnet fsi scripts/unpinned_nuget_package_reference_versions.fsx
164164
- name: Check there are no unpinned versions in `dotnet tool install` commands
165-
run: dotnet fsi scripts/unpinnedDotnetToolInstallVersions.fsx
166-
- name: Check if gitPush1by1 was used
165+
run: dotnet fsi scripts/unpinned_dotnet_tool_install_versions.fsx
166+
- name: Check if script names (.fsx, .bat, and .sh files) are snake_case and CI job names are kebab-case.
167+
run: dotnet fsi scripts/not_respecting_some_naming_conventions.fsx
168+
- name: Check if git_push_1by1 was used
167169
if: github.event_name == 'pull_request'
168-
run: dotnet fsi scripts/detectNotUsingGitPush1by1.fsx
170+
run: dotnet fsi scripts/detect_not_using_git_push_1by1.fsx
169171
- name: Install prettier
170172
run: npm install [email protected]
171173
- name: Change file permissions
File renamed without changes.

scripts/detectNotUsingGitPush1by1.fsx renamed to scripts/detect_not_using_git_push_1by1.fsx

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

843843
Console.Error.WriteLine errMsg
844844
Environment.Exit 2
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.

0 commit comments

Comments
 (0)