Skip to content

Commit 1b0a190

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 4322aac commit 1b0a190

11 files changed

+53
-10
lines changed

.github/workflows/CI.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Compile the conventions solution
2424
run: dotnet build --configuration Release conventions.sln
2525
- name: Compile F# scripts
26-
run: dotnet fsi scripts/compileFSharpScripts.fsx
26+
run: dotnet fsi scripts/compile_fsharp_scripts.fsx
2727

2828
file-conventions-tests:
2929
name: Run FileConventions-lib unit tests
@@ -130,20 +130,22 @@ jobs:
130130
- name: Install dotnet sdk
131131
run: sudo apt install --yes dotnet6
132132
- name: Check all files end with EOL
133-
run: dotnet fsi scripts/eofConvention.fsx
133+
run: dotnet fsi scripts/eof_convention.fsx
134134
- name: Check all .fsx scripts have shebang
135-
run: dotnet fsi scripts/shebangConvention.fsx
135+
run: dotnet fsi scripts/shebang_convention.fsx
136136
- name: Check there are no mixed line-endings in any files
137-
run: dotnet fsi scripts/mixedLineEndings.fsx
137+
run: dotnet fsi scripts/mixed_line_endings.fsx
138138
- name: Check there are no unpinned GitHubActions image versions
139-
run: dotnet fsi scripts/unpinnedGitHubActionsImageVersions.fsx
139+
run: dotnet fsi scripts/unpinned_github_actions_image_versions.fsx
140140
- name: Check there are no unpinned dotnet package versions
141-
run: dotnet fsi scripts/unpinnedDotnetPackageVersions.fsx
141+
run: dotnet fsi scripts/unpinned_dotnet_package_versions.fsx
142142
- name: Check there are no unpinned nuget package reference versions in F# scripts
143-
run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersions.fsx
144-
- name: Check if gitPush1by1 was used
143+
run: dotnet fsi scripts/unpinned_nuget_package_reference_versions.fsx
144+
- name: Check if script names (.fsx, .bat, and .sh files) are snake_case and CI job names are kebab-case.
145+
run: dotnet fsi scripts/not_respecting_some_naming_conventions.fsx
146+
- name: Check if git_push_1by1 was used
145147
if: github.event_name == 'pull_request'
146-
run: dotnet fsi scripts/detectNotUsingGitPush1by1.fsx
148+
run: dotnet fsi scripts/detect_not_using_git_push_1by1.fsx
147149
- name: Install prettier
148150
run: npm install [email protected]
149151
- 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
@@ -593,7 +593,7 @@ if notUsingGitPush1by1 then
593593
sprintf
594594
"Please push the commits one by one; using this script is recommended:%s%s"
595595
Environment.NewLine
596-
"https://github.com/nblockchain/conventions/blob/master/scripts/gitPush1by1.fsx"
596+
"https://github.com/nblockchain/conventions/blob/master/scripts/git_push_1by1.fsx"
597597

598598
Console.Error.WriteLine errMsg
599599
Environment.Exit 1
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)