Skip to content

Commit a096b47

Browse files
authored
Merge PR #73 from realmarv/addIsExecutableFunctionToFileConventions
New executableConvention fsx script that flags when an .fsx file doesn't have the executable +x flag.
2 parents b2965b5 + fdd0255 commit a096b47

22 files changed

+95
-1
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ jobs:
169169
run: dotnet fsi scripts/eofConvention.fsx
170170
- name: Check all .fsx scripts have shebang
171171
run: dotnet fsi scripts/shebangConvention.fsx
172+
- name: Check all F# scripts have execute permission
173+
run: dotnet fsi scripts/executableConvention.fsx
172174
- name: Check there are no mixed line-endings in any files
173175
run: dotnet fsi scripts/mixedLineEndings.fsx
174176
- name: Check there are no unpinned GitHubActions image versions

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This is a repository that contains several useful things that other `nblockchain
66
- [Workflow guidelines](docs/WorkflowGuidelines.md).
77
- Scripts that aid maintainability:
88
* [Detection of .fsx scripts without shebang](scripts/shebangConvention.fsx).
9+
* [Detection of .fsx files without +x attrib](scripts/executableConvention.fsx).
910
* [F# scripts compilation](scripts/compileFSharpScripts.fsx).
1011
* [EOF without EOL detection](scripts/eofConvention.fsx).
1112
* [Mixed line-endings detection](scripts/mixedLineEndings.fsx).
@@ -23,6 +24,5 @@ This is a repository that contains several useful things that other `nblockchain
2324
All in all, this is mainly documentation, and some tooling to detect bad practices.
2425

2526
More things to come:
26-
- Detect .fsx files without +x attrib.
2727
- Detect old versions of FSharpLint and fantomas/fantomless being used.
2828
- Detect old versions of .editorconfig or Directory.Build.props being used.

scripts/checkCommits1by1.fsx

100644100755
File mode changed.

scripts/compileFSharpScripts.fsx

100644100755
File mode changed.

scripts/eofConvention.fsx

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
open System.IO
44
open System
55

6+
#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
7+
68
#load "../src/FileConventions/Helpers.fs"
79
#load "../src/FileConventions/Library.fs"
810

scripts/executableConvention.fsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env -S dotnet fsi
2+
3+
open System
4+
open System.IO
5+
6+
#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
7+
#load "../src/FileConventions/Library.fs"
8+
#load "../src/FileConventions/Helpers.fs"
9+
10+
let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo
11+
12+
let invalidFiles =
13+
Helpers.GetInvalidFiles
14+
rootDir
15+
"*.fsx"
16+
(fun fileInfo -> not(FileConventions.IsExecutable fileInfo))
17+
18+
Helpers.AssertNoInvalidFiles
19+
invalidFiles
20+
"The following files don't have execute permission:"

scripts/inconsistentVersionsInFSharpScripts.fsx

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
open System.IO
44
open System.Linq
55

6+
#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
7+
68
#load "../src/FileConventions/Library.fs"
79
#load "../src/FileConventions/Helpers.fs"
810

scripts/inconsistentVersionsInGitHubCI.fsx

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
open System.IO
44

5+
#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
6+
57
#load "../src/FileConventions/Library.fs"
68
#load "../src/FileConventions/Helpers.fs"
79

scripts/mixedLineEndings.fsx

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
open System
44
open System.IO
55

6+
#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
7+
68
#load "../src/FileConventions/Library.fs"
79
#load "../src/FileConventions/Helpers.fs"
810

scripts/nonVerboseFlagsInGitHubCIAndScripts.fsx

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
open System
44
open System.IO
55

6+
#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
7+
68
#load "../src/FileConventions/Library.fs"
79
#load "../src/FileConventions/Helpers.fs"
810

0 commit comments

Comments
 (0)