@@ -71,15 +71,81 @@ jobs:
7171 with :
7272 files : .coverage/GraphQL.Server.Transports.AspNetCore.Tests/coverage.net7.0.opencover.xml,.coverage/GraphQL.Server.Transports.AspNetCore.Tests/coverage.netcoreapp2.1.opencover.xml,.coverage/GraphQL.Server.Samples.Server.Tests/coverage.net7.0.opencover.xml
7373
74+ nativeaot :
75+ strategy :
76+ matrix :
77+ os : [ubuntu-latest, windows-latest]
78+ name : NativeAOT Sample on ${{ matrix.os }}
79+ runs-on : ${{ matrix.os }}
80+ steps :
81+ - name : Checkout source
82+ uses : actions/checkout@v4
83+ - name : Setup .NET SDK for NativeAOT
84+ uses : actions/setup-dotnet@v4
85+ with :
86+ dotnet-version : 8.0.x
87+ source-url : https://nuget.pkg.github.com/graphql-dotnet/index.json
88+ env :
89+ NUGET_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
90+ - name : Publish NativeAOT sample
91+ working-directory : samples/Samples.NativeAot
92+ run : dotnet publish -c Release -o published
93+ - name : Start NativeAOT sample in background
94+ working-directory : samples/Samples.NativeAot/published
95+ shell : bash
96+ run : |
97+ if [ "$RUNNER_OS" == "Windows" ]; then
98+ ./GraphQL.Server.Samples.NativeAot.exe &
99+ else
100+ ./GraphQL.Server.Samples.NativeAot &
101+ fi
102+ - name : Wait for NativeAOT sample to spin up
103+ shell : bash
104+ run : |
105+ # Disable exit-on-error to allow retries
106+ set +e
107+ for i in {1..60}; do
108+ echo "Request $i to the GraphQL endpoint..."
109+ response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/ || true)
110+ if [ "$response" -eq 200 ]; then
111+ echo "Received 200 response, NativeAOT sample is ready."
112+ exit 0
113+ fi
114+ echo "Did not receive a 200 response, sleeping for 0.5 second..."
115+ sleep 0.5
116+ done
117+ echo "NativeAOT sample did not spin up in time."
118+ exit 1
119+ - name : Run GraphQL query against NativeAOT sample
120+ working-directory : samples/Samples.NativeAot
121+ shell : bash
122+ run : |
123+ # Run a simple GraphQL query. Adjust the request as needed for your sample.
124+ curl -X POST -H "Content-Type: application/json" \
125+ -d @sample-request.json \
126+ http://localhost:5000/graphql > nativeaot_response.json
127+ - name : Print query result
128+ working-directory : samples/Samples.NativeAot
129+ shell : bash
130+ run : cat nativeaot_response.json
131+ - name : Compare query result to expected response
132+ working-directory : samples/Samples.NativeAot
133+ shell : bash
134+ run : |
135+ jq . nativeaot_response.json > actual-response.json
136+ jq . sample-response.json > expected-response.json
137+ diff -b actual-response.json expected-response.json
138+
74139 buildcheck :
75140 needs :
76141 - test
142+ - nativeaot
77143 runs-on : ubuntu-latest
78144 if : always()
79145 steps :
80146 - name : Pass build check
81- if : ${{ needs.test.result == 'success' }}
147+ if : ${{ needs.test.result == 'success' && needs.nativeaot.result == 'success' }}
82148 run : exit 0
83149 - name : Fail build check
84- if : ${{ needs.test.result != 'success' }}
150+ if : ${{ needs.test.result != 'success' || needs.nativeaot.result != 'success' }}
85151 run : exit 1
0 commit comments