Skip to content

Commit d6101d4

Browse files
Copilotxperiandri
andauthored
ci: publish test results to pull request discussions
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/ae314b8b-9c8a-4f87-a8b0-b77c4bfa2cef Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent 94567b4 commit d6101d4

3 files changed

Lines changed: 69 additions & 3 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish Test Results
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build and Test"]
6+
types:
7+
- completed
8+
9+
permissions: {}
10+
11+
jobs:
12+
test-results:
13+
if: github.event.workflow_run.conclusion != 'skipped' && github.event.workflow_run.event == 'pull_request'
14+
name: Test Results
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
actions: read
19+
checks: write
20+
pull-requests: write
21+
22+
steps:
23+
- name: Download event file
24+
uses: dawidd6/action-download-artifact@v4
25+
with:
26+
run_id: ${{ github.event.workflow_run.id }}
27+
path: artifacts
28+
name: EventFile
29+
30+
- name: Download test results
31+
uses: dawidd6/action-download-artifact@v4
32+
with:
33+
run_id: ${{ github.event.workflow_run.id }}
34+
path: test-results
35+
pattern: test-results-*
36+
37+
- name: Publish test results
38+
uses: EnricoMi/publish-unit-test-result-action@v2
39+
with:
40+
commit: ${{ github.event.workflow_run.head_sha }}
41+
event_file: artifacts/event.json
42+
event_name: ${{ github.event.workflow_run.event }}
43+
files: "test-results/**/*.trx"

.github/workflows/pull-request.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ env:
1515
DOTNET_NOLOGO: true
1616

1717
jobs:
18+
event_file:
19+
if: github.event_name == 'pull_request'
20+
name: Publish event file
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Upload event file
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: EventFile
27+
path: ${{ github.event_path }}
28+
1829
build:
1930

2031
strategy:
@@ -50,3 +61,10 @@ jobs:
5061

5162
- name: Build and run integration tests
5263
run: dotnet run --project build/Build.fsproj --launch-profile BuildAndTest
64+
65+
- name: Upload test results
66+
if: always()
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: test-results-${{ matrix.os }}
70+
path: test-results

build/Program.fs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,17 @@ let startGraphQLServer (project : string) port (streamRef : DataRef<Stream>) =
100100

101101
System.Threading.Thread.Sleep (2000)
102102

103-
let runTests (project : string) (args : string) =
103+
let runTests (project : string) =
104+
let projectName = Path.GetFileNameWithoutExtension project
105+
let resultsFileName = $"{projectName}.trx"
106+
104107
DotNet.test
105108
(fun options ->
106109
{
107110
options with
108111
NoBuild = true
112+
Logger = Some $"trx;LogFileName={resultsFileName}"
113+
ResultsDirectory = Some "test-results"
109114
Framework = Some DotNetMoniker
110115
Configuration = configuration
111116
MSBuildParams = {
@@ -225,11 +230,11 @@ Target.create BuildIntegrationTestsTarget <| fun _ ->
225230

226231
let [<Literal>] RunUnitTestsTarget = "RunUnitTests"
227232
Target.create RunUnitTestsTarget <| fun _ ->
228-
runTests unitTestsProjectPath ""
233+
runTests unitTestsProjectPath
229234

230235
let [<Literal>] RunIntegrationTestsTarget = "RunIntegrationTests"
231236
Target.create RunIntegrationTestsTarget <| fun _ ->
232-
runTests integrationTestsProjectPath "" //"--filter Execution=Sync"
237+
runTests integrationTestsProjectPath //"--filter Execution=Sync"
233238

234239
let prepareDocGen () =
235240
Shell.rm "docs/release-notes.md"

0 commit comments

Comments
 (0)