-
Notifications
You must be signed in to change notification settings - Fork 345
171 lines (159 loc) · 6.44 KB
/
example-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: example-integration-test
on:
push:
branches:
- master
- release-*
tags:
- v*
pull_request:
branches:
- master
- release-*
jobs:
build-and-test:
name: run example-based integration tests
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
dotnet-version: ['8.0'] #, '9.0']
include:
- dotnet-version: '8.0'
display-name: '.NET 8.0'
framework: 'net8.0'
install-version: '8.0.x'
- dotnet-version: '9.0'
display-name: '.NET 9.0'
framework: 'net9.0'
install-version: '9.0.x'
runs-on: 'ubuntu-latest'
env:
NUPKG_OUTDIR: bin/Release/nugets
GOVER: 1.20.0
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
DAPR_CLI_VER: 1.14.0
DAPR_RUNTIME_VER: 1.14.0
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/release-1.14/install/install.sh
DAPR_CLI_REF: ''
steps:
- name: Set up Dapr CLI
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}
- name: Checkout Dapr CLI repo to override dapr command.
uses: actions/checkout@v2
if: env.DAPR_CLI_REF != ''
with:
repository: dapr/cli
ref: ${{ env.DAPR_CLI_REF }}
path: cli
- name: Checkout Dapr repo to override daprd.
uses: actions/checkout@v2
if: env.DAPR_REF != ''
with:
repository: dapr/dapr
ref: ${{ env.DAPR_REF }}
path: dapr
- name: Set up Go from dapr/go.mod
if: env.DAPR_REF != ''
uses: actions/setup-go@v3
with:
go-version-file: "dapr/go.mod"
- name: Set up Go from cli/go.mod
if: env.DAPR_REF == '' && env.DAPR_CLI_REF != ''
uses: actions/setup-go@v3
with:
go-version-file: "cli/go.mod"
- name: Build and override dapr cli with referenced commit.
if: env.DAPR_CLI_REF != ''
run: |
cd cli
make
sudo cp dist/linux_amd64/release/dapr /usr/local/bin/dapr
cd ..
- name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }}
run: |
dapr uninstall --all
dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }}
- name: Build and override daprd with referenced commit.
if: env.DAPR_REF != ''
run: |
cd dapr
make
mkdir -p $HOME/.dapr/bin/
cp dist/linux_amd64/release/daprd $HOME/.dapr/bin/daprd
cd ..
- name: Override placement service.
if: env.DAPR_REF != ''
run: |
docker stop dapr_placement
cd dapr
./dist/linux_amd64/release/placement &
- uses: actions/checkout@v1
- name: Parse release version
run: python ./.github/scripts/get_release_version.py
- name: Setup ${{ matrix.display-name }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.install-version }}
dotnet-quality: 'ga' # Prefer a GA release, but use the RC if not available
- name: Check test coverage
run: |
sudo apt-get install jq
# Find all .csproj files in the ./examples directory
all_projects=$(find ./examples -name '*.csproj' -exec basename {} \; | sed 's/.csproj//')
# Get the list of projects from example-e2e-tests.json
tested_projects=$(jq -r '.projects[].project' ./.github/workflows/example-e2e-tests.json | sed 's/.csproj//')
# Compare the lists and find projects without tests
for project in $all_projects; do
if ! echo "$tested_projects" | grep -q "$project"; then
echo "Project $project does not have any tests in example-e2e-tests.json"
fi
done
- name: Build & test projects
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
run: |
# Parse the projects
projects=$(jq -c '.projects[]' ./.github/workflows/example-e2e-tests.json)
echo "Parsed project names:"
echo "$projects" | jq -r '.project'
# Iterate over the projects
echo "$projects" | while read project; do
project_name=$(echo $project | jq -r '.project')
echo "Project name: $project_name"
# Find the .csproj file in the ./examples directory
csproj_path=$(find ./examples/ -name $project_name)
echo "csproj path: $csproj_path"
tests=$(echo $project | jq -c '.tests[]')
echo "$tests" | while read test; do
test_name=$(echo $test | jq -r '.name')
echo "test name: $test_name"
test_arguments=$(echo $test | jq -r '.arguments')
echo "args: $test_arguments"
expectedOutputs=$(echo $test | jq -r '.expected_stdout_output[]')
expectation_type=$(echo $test | jq -r '.expectation_type')
echo "expectation_type: $expectation_type"
echo "Building and testing $project_name with .NET ${{ matrix.dotnet-version }}"
dotnet build $csproj_path --framework ${{ matrix.framework }} --configuration Release /p:GITHUB_ACTIONS=false
output=$(dotnet run --project $csproj_path --framework ${{ matrix.framework }} -- $test_arguments)
for expected in $expectedOutputs; do
if [[ "$expectation_type" == "startswith" ]]; then
if [[ "$output" != "$expected"* ]]; then
echo "Test failed for $csproj_path with .NET ${{ matrix.dotnet-version }}: Expected '$expected' not found in output"
exit 1
fi
elif [[ "$expectation_type" == "equals" ]]; then
if [[ "$output" != "$expected" ]]; then
echo "Test failed for $csproj_path with .NET ${{matrix.dotnet-version }}: Expected '$expected' not found in output"
exit 1
fi
else
if [[ "$output" != *"$expected"* ]]; then
echo "Test failed for $csproj_path with .NET ${{ matrix.dotnet-version }}: Expected '$expected' not found in output"
exit 1
fi
fi
done
done
done