-
Notifications
You must be signed in to change notification settings - Fork 66
309 lines (272 loc) · 10.6 KB
/
validate-examples.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: validate-examples
on:
schedule:
- cron: '8 8 * * *'
push:
branches:
- main
- release-*
tags:
- v*
pull_request:
branches:
- main
- release-*
workflow_dispatch:
inputs:
dapr_commit:
description: "Dapr/Dapr commit to build custom daprd from"
required: false
default: ""
daprcli_commit:
description: "Dapr/CLI commit to build custom dapr CLI from"
required: false
default: ""
dapr_version:
description: "Dapr/Dapr version to use"
required: false
default: ""
daprcli_version:
description: "Dapr/CLI version to use"
required: false
default: ""
repository_dispatch:
types: [ validate-examples ]
merge_group:
jobs:
setup:
permissions:
packages: read
runs-on: ubuntu-latest
env:
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
DAPR_CLI_REF: ${{ github.event.inputs_daprcli_commit }}
DAPR_CLI_VERSION: ${{ github.event.inputs_daprcli_version }}
DAPR_REF: ${{ github.event.inputs.dapr_commit }}
DAPR_RUNTIME_VERSION: ${{ github.event.inputs.dapr_version }}
CHECKOUT_REPO: ${{ github.repository }}
CHECKOUT_REF: ${{ github.ref }}
outputs:
DAPR_INSTALL_URL: ${{ env.DAPR_INSTALL_URL }}
DAPR_CLI_VERSION: ${{ steps.outputs.outputs.DAPR_CLI_VERSION }}
DAPR_RUNTIME_VERSION: ${{ steps.outputs.outputs.DAPR_RUNTIME_VERSION }}
CHECKOUT_REPO: ${{ steps.outputs.outputs.CHECKOUT_REPO }}
CHECKOUT_REF: ${{ steps.outputs.outputs.CHECKOUT_REF }}
GITHUB_SHA: ${{ steps.outputs.outputs.GITHUB_SHA }}
steps:
- name: Parse repository_dispatch payload
if: github.event_name == 'repository_dispatch'
run: |
if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then
echo "CHECKOUT_REPO=${{ github.event.client_payload.pull_head_repo }}" >> $GITHUB_ENV
echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV
echo "DAPR_REF=master" >> $GITHUB_ENV
fi
- name: Check out code
uses: actions/checkout@v4
with:
repository: ${{ env.CHECKOUT_REPO }}
ref: ${{ env.CHECKOUT_REF }}
- name: Determine latest Dapr Runtime version
if: env.DAPR_RUNTIME_VERSION == ''
run: |
RUNTIME_VERSION=$(curl -s "https://api.github.com/repos/dapr/dapr/releases/latest" | grep '"tag_name"' | cut -d ':' -f2 | tr -d '",v')
echo "DAPR_RUNTIME_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
echo "Found $RUNTIME_VERSION"
- name: Determine latest Dapr Cli version
if: env.DAPR_CLI_VERSION == ''
run: |
CLI_VERSION=$(curl -s "https://api.github.com/repos/dapr/cli/releases/latest" | grep '"tag_name"' | cut -d ':' -f2 | tr -d '",v')
echo "DAPR_CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV
echo "Found $CLI_VERSION"
- name: Checkout Dapr CLI repo to override dapr command.
uses: actions/checkout@v4
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@v4
if: env.DAPR_REF != ''
with:
repository: dapr/dapr
ref: ${{ env.DAPR_REF }}
path: dapr_runtime
- name: Set up Go
uses: actions/setup-go@v5
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
with:
cache: false
go-version: "stable"
- name: Build dapr cli with referenced commit and override version
if: env.DAPR_CLI_REF != ''
run: |
cd cli
make
echo "artifactPath=~/artifacts/$GITHUB_SHA/" >> $GITHUB_ENV
mkdir -p $HOME/artifacts/$GITHUB_SHA/
cp dist/linux_amd64/release/dapr $HOME/artifacts/$GITHUB_SHA/dapr
CLI_VERSION=edge
echo "DAPR_CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV
- name: Build daprd and placement with referenced commit and override version
if: env.DAPR_REF != ''
run: |
cd dapr_runtime
make
echo "artifactPath=~/artifacts/$GITHUB_SHA/" >> $GITHUB_ENV
RUNTIME_VERSION=edge
echo "DAPR_RUNTIME_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
- name: Build Docker Image
if: env.DAPR_REF != ''
run: |
mkdir ~/dapr_docker
cd dapr_runtime
docker build --build-arg "PKG_FILES=*" -f ./docker/Dockerfile ./dist/linux_amd64/release -t daprio/dapr:0.0.0-dev
- name: Download Install Bundle CLI
if: env.DAPR_REF != '' && env.DAPR_CLI_REF == ''
run: |
mkdir -p cli/dist/linux_amd64/release
cd cli/dist/linux_amd64/release/
curl -L --remote-name https://github.com/dapr/cli/releases/download/v$DAPR_CLI_VERSION/dapr_linux_amd64.tar.gz
tar xvzf dapr_linux_amd64.tar.gz
ls -la
- name: Build Custom Install Bundle
if: env.DAPR_REF != '' && env.DAPR_CLI_REF != ''
run: |
: # Create daprbundle directory
mkdir ~/daprbundle
cp .github/workflows/validate-examples/details.json ~/daprbundle/
: # Add cli
cp ~/artifacts/$GITHUB_SHA/dapr ~/daprbundle/dapr
: # Compress executables to /dist/ appending _linux_amd64 to the name
mkdir ~/daprbundle/dist
cd dapr_runtime/dist/linux_amd64/release/
for file in $(ls -1)
do
echo "packing $file"
tar czvf ~/daprbundle/dist/${file}_linux_amd64.tar.gz ${file}
done
cd ~/daprbundle/dist/
curl -L --remote-name https://github.com/dapr/dashboard/releases/download/v0.14.0/dashboard_linux_amd64.tar.gz
: # Add docker image
mkdir ~/daprbundle/docker
docker save daprio/dapr:0.0.0-dev | gzip > ~/daprbundle/docker/daprio-dapr-0.0.0-dev.tar.gz
: # Bundle
cd ~/daprbundle
tar czvf $HOME/artifacts/$GITHUB_SHA/daprbundle.tar.gz .
- name: List artifacts
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
run: |
ls -la $HOME/artifacts/$GITHUB_SHA/
- name: Upload dapr-artifacts
uses: actions/upload-artifact@v4
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
with:
name: dapr-artifacts
path: ${{ env.artifactPath }}
if-no-files-found: error
retention-days: 1
compression-level: 0
- name: Outputs
id: outputs
run: |
echo "DAPR_INSTALL_URL=$DAPR_INSTALL_URL"
echo "DAPR_CLI_VERSION=$DAPR_CLI_VERSION" >> "$GITHUB_OUTPUT"
echo "DAPR_RUNTIME_VERSION=$DAPR_RUNTIME_VERSION" >> "$GITHUB_OUTPUT"
echo "CHECKOUT_REPO=$CHECKOUT_REPO" >> "$GITHUB_OUTPUT"
echo "CHECKOUT_REF=$CHECKOUT_REF" >> "$GITHUB_OUTPUT"
echo "GITHUB_SHA=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
validate-example:
permissions:
packages: read
needs: setup
runs-on: ubuntu-latest
env:
PYTHON_VER: 3.12
DAPR_INSTALL_URL: ${{ needs.setup.outputs.DAPR_INSTALL_URL }}
DAPR_CLI_VERSION: ${{ needs.setup.outputs.DAPR_CLI_VERSION }}
DAPR_RUNTIME_VERSION: ${{ needs.setup.outputs.DAPR_RUNTIME_VERSION }}
CHECKOUT_REPO: ${{ needs.setup.outputs.CHECKOUT_REPO }}
CHECKOUT_REF: ${{ needs.setup.outputs.CHECKOUT_REF }}
GITHUB_SHA: ${{ needs.setup.outputs.GITHUB_SHA }}
RUST_BACKTRACE: full
strategy:
fail-fast: false
matrix:
examples:
[ "actors", "bindings", "client", "configuration", "crypto", "invoke/grpc", "invoke/grpc-proxying", "jobs", "pubsub", "query_state", "secrets-bulk" ]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
repository: ${{ env.CHECKOUT_REPO }}
ref: ${{ env.CHECKOUT_REF }}
- name: Make Artifacts destination folder
if: env.DAPR_CLI_VERSION == 'edge' || env.DAPR_RUNTIME_VERSION == 'edge'
run: |
mkdir -p $HOME/artifacts/$GITHUB_SHA/
- name: Retrieve dapr-artifacts
if: env.DAPR_CLI_VERSION == 'edge' || env.DAPR_RUNTIME_VERSION == 'edge'
uses: actions/download-artifact@v4
with:
name: dapr-artifacts
path: ~/artifacts/${{ env.GITHUB_SHA }}
- name: Display downloaded artifacts
if: env.DAPR_CLI_VERSION == 'edge' || env.DAPR_RUNTIME_VERSION == 'edge'
run: |
ls -la $HOME/artifacts/$GITHUB_SHA/
- name: Rust setup
run: rustup toolchain install stable --profile minimal
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "24.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Dapr CLI ${{ env.DAPR_CLI_VERSION }}
if: env.DAPR_CLI_VERSION != 'edge'
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VERSION }}
- name: Set up Dapr CLI (edge)
if: env.DAPR_CLI_VERSION == 'edge'
run: |
sudo cp $HOME/artifacts/$GITHUB_SHA/dapr /usr/local/bin/dapr
sudo chmod +x /usr/local/bin/dapr
- name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VERSION }}
if: env.DAPR_RUNTIME_VERSION != 'edge'
run: |
dapr uninstall --all
dapr init --runtime-version ${{ env.DAPR_RUNTIME_VERSION }}
- name: Initialize Dapr runtime with installer bundle - EDGE
if: env.DAPR_RUNTIME_VERSION == 'edge'
run: |
: # Unpack Bundle
mkdir ~/daprbundle
tar xvzf $HOME/artifacts/$GITHUB_SHA/daprbundle.tar.gz -C ~/daprbundle
: # Run installer
dapr uninstall --all
dapr init --from-dir ~/daprbundle/
: # Initialize redis and zipkin
docker run --name "dapr_redis" --restart always -d -p 6379:6379 redislabs/rejson
docker run --name "dapr_zipkin" --restart always -d -p 9411:9411 openzipkin/zipkin
- name: List running containers
run: |
docker ps -a
- name: Set up Python ${{ env.PYTHON_VER }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VER }}
- name: Install Mechanical Markdown
run: |
python -m pip install --upgrade pip
pip install mechanical-markdown
- name: Dapr version
run: |
dapr version
docker ps -a
- name: Check Example
run: |
cd examples
./validate.sh ${{ matrix.examples }}