Skip to content

Commit ba79b19

Browse files
authored
Merge pull request #41 from jkone27/add-docs
add docs and website publication #33
2 parents 6813bc0 + 31d6a35 commit ba79b19

File tree

17 files changed

+412
-303
lines changed

17 files changed

+412
-303
lines changed

.config/dotnet-tools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
"husky"
1616
],
1717
"rollForward": false
18+
},
19+
"fsdocs-tool": {
20+
"version": "20.0.1",
21+
"commands": [
22+
"fsdocs"
23+
],
24+
"rollForward": false
1825
}
1926
}
2027
}

.github/workflows/docs.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docs
2+
3+
# Trigger this Action when new code is pushed to the main branch
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
# We need some permissions to publish to Github Pages
10+
permissions:
11+
contents: write
12+
pages: write
13+
id-token: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
# Checkout the source code
20+
- uses: actions/checkout@v4
21+
# Setup dotnet, please use a global.json to ensure the right SDK is used!
22+
- name: Setup .NET
23+
uses: actions/setup-dotnet@v3
24+
# Restore the local tools
25+
- name: Restore tools
26+
run: dotnet tool restore
27+
# Build the code for the API documentation
28+
- name: Build code
29+
run: dotnet build -c Release ApiStub.FSharp.sln
30+
# Generate the documentation files
31+
- name: Generate the documentation'
32+
run: dotnet fsdocs build --properties Configuration=Release
33+
# Upload the static files
34+
- name: Upload documentation
35+
uses: actions/upload-pages-artifact@v2
36+
with:
37+
path: ./output
38+
39+
# GitHub Actions recommends deploying in a separate job.
40+
deploy:
41+
runs-on: ubuntu-latest
42+
needs: build
43+
steps:
44+
- name: Deploy to GitHub Pages
45+
id: deployment
46+
uses: actions/deploy-pages@v2

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
# Main branch only
3232
if: github.ref == 'refs/heads/main'
3333
run: |
34-
dotnet nuget push **/*.nupkg --api-key ${{secrets.NUGET_KEY}} --skip-duplicate
34+
dotnet nuget push **/*.nupkg --api-key ${{secrets.NUGET_KEY}} --skip-duplicates

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,10 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
352+
# FSharp.Formatting
353+
.fsdocs/
354+
output/
355+
tmp/
356+
357+
.DS_Store

ApiStub.FSharp/ApiStub.FSharp.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>net6.0</TargetFramework>
44
<GenerateDocumentationFile>true</GenerateDocumentationFile>
55
<PackageId>ApiStub.FSharp</PackageId>
6-
<Version>1.1.0</Version>
6+
<Version>1.2.0</Version>
77
<Authors>jkone27</Authors>
88
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
99
<PackageLicenseExpression>MIT</PackageLicenseExpression>

ApiStub.FSharp/BDD.fs

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,29 @@ open ApiStub.FSharp.HttpResponseHelpers
1010
module BDD =
1111

1212

13+
/// Defines a BDD scenario
1314
type Scenario<'TStartup when 'TStartup: not struct> =
1415
{ UseCase: string
1516
TestClient: TestClient<'TStartup> }
1617

18+
/// Defines the context propagated through the test
1719
type Environment<'TStartup, 'FeatureStubData when 'TStartup: not struct> =
1820
{ Scenario: Scenario<'TStartup>
1921
FeatureStubData: 'FeatureStubData
2022
Factory: 'TStartup WebApplicationFactory
2123
Client: HttpClient }
2224

25+
/// Result of a Given gherkin clause
2326
type GivenResult<'ArrangeData, 'FeatureStubData, 'TStartup when 'TStartup: not struct> =
2427
{ Environment: Environment<'TStartup, 'FeatureStubData>
2528
ArrangeData: 'ArrangeData } // once preconditions are set
2629

30+
/// Result of a When gherkin clause
2731
type WhenResult<'ArrangeData, 'FeatureStubData, 'AssertData, 'TStartup when 'TStartup: not struct> =
2832
{ Given: GivenResult<'ArrangeData, 'FeatureStubData, 'TStartup>
2933
AssertData: 'AssertData }
3034

31-
35+
/// Generic step type for the BDD steps
3236
type Step<'TStartup, 'FeatureStubData, 'ArrangeData, 'AssertData when 'TStartup: not struct> =
3337
| Scenario of Scenario<'TStartup>
3438
| Environment of Environment<'TStartup, 'FeatureStubData>
@@ -37,11 +41,13 @@ module BDD =
3741
| Invalid of error: string
3842

3943

44+
/// Scenario builder
4045
let SCENARIO useCase testClient =
4146
{ UseCase = useCase
4247
TestClient = testClient }
4348
|> Step.Scenario
4449

50+
/// Setup the Environment for the given scenario
4551
let SETUP arrangeTestEnvironment customizeClient step =
4652
task {
4753

@@ -58,6 +64,7 @@ module BDD =
5864
| _ -> return Step.Invalid("only environment is supported for ENVIRONMENT_SETUP")
5965
}
6066

67+
/// specify a GIVEN gherkin clause
6168
let GIVEN setPreconditions stepTask =
6269
task {
6370

@@ -88,6 +95,7 @@ module BDD =
8895
| Result.Error(e) -> Step.Invalid(e)
8996
}
9097

98+
/// specify a WHEN gherkin clause
9199
let WHEN action stepTask =
92100
task {
93101

@@ -114,6 +122,7 @@ module BDD =
114122
return r
115123
}
116124

125+
/// Specify an assert in THEN gherkin format
117126
let THEN assertAction stepTask =
118127
task {
119128

@@ -126,6 +135,7 @@ module BDD =
126135
| _ -> return Step.Invalid($"{step} is not supported in WHEN clause")
127136
}
128137

138+
/// Conclude the pipeline of steps
129139
let END stepTask =
130140
task {
131141

@@ -141,35 +151,35 @@ module BDD =
141151
}
142152

143153

144-
// [<Fact>] sample
145-
let ``when i call /hello i get 'world' back with 200 ok`` (testClient: TestClient<_>) =
146-
147-
let stubData = [ 1, 2, 3 ]
148-
149-
testClient { GET "/hello" (fun _ _ -> $"hello world {stubData}" |> R_TEXT) }
150-
|> SCENARIO "when i call /hello i get 'world' back with 200 ok"
151-
|> SETUP
152-
(fun s ->
153-
task {
154-
155-
let test = s.TestClient
156-
157-
let f = test.GetFactory()
158-
159-
return
160-
{ Client = f.CreateClient()
161-
Factory = f
162-
Scenario = s
163-
FeatureStubData = stubData }
164-
})
165-
(fun c -> c)
166-
|> GIVEN(fun g -> "hello" |> Task.FromResult)
167-
|> WHEN(fun g ->
168-
task {
169-
let! (r: HttpResponseMessage) = g.Environment.Client.GetAsync("/Hello")
170-
return! r.Content.ReadAsStringAsync()
171-
})
172-
|> THEN(fun w ->
173-
let _ = ("hello world 1,2,3" = w.AssertData)
174-
())
175-
|> END
154+
// [<Fact>] sample
155+
// let ``when i call /hello i get 'world' back with 200 ok`` (testClient: TestClient<_>) =
156+
157+
// let stubData = [ 1, 2, 3 ]
158+
159+
// testClient { GET "/hello" (fun _ _ -> $"hello world {stubData}" |> R_TEXT) }
160+
// |> SCENARIO "when i call /hello i get 'world' back with 200 ok"
161+
// |> SETUP
162+
// (fun s ->
163+
// task {
164+
165+
// let test = s.TestClient
166+
167+
// let f = test.GetFactory()
168+
169+
// return
170+
// { Client = f.CreateClient()
171+
// Factory = f
172+
// Scenario = s
173+
// FeatureStubData = stubData }
174+
// })
175+
// (fun c -> c)
176+
// |> GIVEN(fun g -> "hello" |> Task.FromResult)
177+
// |> WHEN(fun g ->
178+
// task {
179+
// let! (r: HttpResponseMessage) = g.Environment.Client.GetAsync("/Hello")
180+
// return! r.Content.ReadAsStringAsync()
181+
// })
182+
// |> THEN(fun w ->
183+
// let _ = ("hello world 1,2,3" = w.AssertData)
184+
// ())
185+
// |> END

ApiStub.FSharp/BuilderExtensions.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ open System.Threading.Tasks
77
open System
88
open Microsoft.AspNetCore.TestHost
99

10+
/// Utility methods for aspnetcore configuration
1011
module BuilderExtensions =
1112

1213
let configure_services (configure: IServiceCollection -> 'a) (builder: IWebHostBuilder) : IWebHostBuilder =

ApiStub.FSharp/CE.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ open Microsoft.Extensions.Http
99
open Microsoft.AspNetCore.Routing.Template
1010
open Microsoft.AspNetCore.Routing
1111

12+
/// computation expression module (builder CE), contains `TestClient<T>` that wraps `WebApplicationFactory<T>`
1213
module CE =
1314
open BuilderExtensions
1415
open HttpResponseHelpers
@@ -17,6 +18,7 @@ module CE =
1718
let private toAsync stub =
1819
fun req args -> task { return stub req args }
1920

21+
/// `TestClient<T>` wraps `WebApplicationFactory<T>` and exposes a builder CE with utility to define api client stubs and other features
2022
type TestClient<'T when 'T: not struct>() =
2123

2224
let factory = new WebApplicationFactory<'T>()

ApiStub.FSharp/Csharp.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ApiStub.Fsharp
1+
namespace ApiStub.Fsharp.CSharp
22

33
open System.Runtime.CompilerServices
44
open ApiStub.FSharp.CE

Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup>
3+
<RepositoryUrl>https://github.com/jkone27/fsharp-integration-tests</RepositoryUrl>
4+
<FsDocsLicenseLink>https://raw.githubusercontent.com/jkone27/fsharp-integration-tests/refs/heads/main/LICENSE</FsDocsLicenseLink>
5+
<FsDocsReleaseNotesLink>https://github.com/jkone27/fsharp-integration-tests/blob/master/RELEASE_NOTES.md</FsDocsReleaseNotesLink>
6+
<PackageProjectUrl>https://github.com/jkone27/fsharp-integration-tests</PackageProjectUrl>
7+
</PropertyGroup>
8+
</Project>

0 commit comments

Comments
 (0)