Skip to content

Commit 172cbf4

Browse files
ci: introduce new test workflow for testing all things
1 parent e9d353c commit 172cbf4

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

.github/workflows/test-all.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Run all tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "main"
8+
- "rc"
9+
- "hotfix-rc"
10+
workflow_dispatch:
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
test:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
settings:
28+
- os: macos-15
29+
- os: windows-2025
30+
- os: ubuntu-24.04
31+
32+
runs-on: ${{ matrix.settings.os }}
33+
name: Run all tests - ${{ matrix.settings.os }}
34+
steps:
35+
- name: Checkout repo
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
- name: Run tests
38+
working-directory: ${{ github.workspace }}
39+
run: ./scripts/bootstrap.sh all csharp

languages/csharp/setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
#!/usr/bin/env bash
2+
export DOTNET_CLI_TELEMETRY_OPTOUT=true
3+
export DOTNET_NOLOGO=false
4+
25
dotnet build --verbosity quiet

scripts/bootstrap.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# shellcheck disable=SC3043,SC3044
2+
# shellcheck disable=SC3043,SC3044,SC2155,SC3020
33
set -euo pipefail
44

55
REPO_ROOT="$(git rev-parse --show-toplevel)"
@@ -32,6 +32,17 @@ common_setup() {
3232
cargo build --quiet >/dev/null
3333
}
3434

35+
start_fake_server() {
36+
# Start the fake server in background for testing
37+
cargo run --bin fake-server &> /dev/null &
38+
echo $! > "${TMP_DIR}"/fake_server.pid
39+
# Wait for server to start
40+
until curl -s "$SERVER_URL/health" >/dev/null 2>&1; do
41+
echo "Waiting for fake server to start..."
42+
sleep 1
43+
done
44+
}
45+
3546
main() {
3647
local action="$1"
3748
local language="$2"
@@ -41,6 +52,7 @@ main() {
4152
case "$action" in
4253
all)
4354
common_setup
55+
start_fake_server
4456
pushd "$dir" >/dev/null || {
4557
echo "Failed to change directory to $dir"
4658
exit 1
@@ -71,10 +83,13 @@ main() {
7183
# Find setup.sh in $dir, if it doesn't exist fail
7284
# Start running fake_server, set common environment for tests
7385
# Run it
86+
start_fake_server
87+
7488
pushd "$dir" >/dev/null || {
7589
echo "Failed to change directory to $dir"
7690
exit 1
7791
}
92+
7893
. "$dir/test.sh"
7994
popd >/dev/null || {
8095
echo "Failed to return to previous directory"
@@ -88,4 +103,19 @@ main() {
88103
esac
89104
}
90105

106+
cleanup() {
107+
# Stop the fake server if it was started
108+
if [ -f "${TMP_DIR}/fake_server.pid" ]; then
109+
local pid="$(cat "${TMP_DIR}/fake_server.pid")"
110+
echo "Stopping fake server..."
111+
kill "$pid"
112+
wait "$pid" || true
113+
rm -f "${TMP_DIR}/fake_server.pid"
114+
fi
115+
116+
# Remove temporary directory
117+
rm -rf "${TMP_DIR}"
118+
}
119+
120+
trap 'cleanup' EXIT
91121
main "$@"

0 commit comments

Comments
 (0)