forked from wasmCloud/wasmCloud
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (157 loc) · 5.96 KB
/
examples-providers.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
name: example-providers
on:
merge_group:
push:
branches:
- main
pull_request:
branches: [main]
paths:
- .github/workflows/examples-providers.yml
- crates/wash-lib/**
- crates/wash-cli/**
- examples/rust/providers/**
- examples/golang/providers/**
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build-wash-cli:
name: build wash-cli
runs-on: ubuntu-22.04
strategy:
matrix:
wash-version:
- 0.37.0
- current
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
if: ${{ matrix.wash-version == 'current' }}
- run: rustup show
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
with:
shared-key: "ubuntu-22.04-shared-cache"
- name: install wash (previous version)
if: ${{ matrix.wash-version != 'current' }}
uses: taiki-e/install-action@2c3c8dfabf5933531aca0613c6b0c173fa51745e
with:
tool: wash-cli@${{ matrix.wash-version }}
- name: build wash (current)
if: ${{ matrix.wash-version == 'current' }}
run: cargo build -p wash-cli --release
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
if: ${{ matrix.wash-version == 'current' }}
with:
name: wash-${{ matrix.wash-version }}
path: ./target/release/wash
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
if: ${{ matrix.wash-version != 'current' }}
with:
name: wash-${{ matrix.wash-version }}
path: ~/.cargo/bin/wash
# Ensure that `wash build` and `wash app validate` works for all example projects below
wash-build:
name: example-provider-build
runs-on: ubuntu-22.04
needs: [build-wash-cli]
strategy:
fail-fast: false
matrix:
wash-version:
- 0.37.0
- current
project:
# Golang example providers
- name: "custom-template"
lang: "golang"
lang_version: "1.23"
tinygo_version: "0.33.0"
test_deploy: wadm.yaml
# Rust example providers
- name: "custom-template"
lang: "rust"
test_deploy: wadm.yaml
- name: "messaging-nats"
lang: "rust"
test_deploy: local.wadm.yaml
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
# Download wash binary & install to path
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: wash-${{ matrix.wash-version }}
path: artifacts
- name: install wash binary to PATH # Some build tools expect wash to be on the PATH
shell: bash
run: |
chmod +x ./artifacts/wash;
echo "$(realpath ./artifacts)" >> "$GITHUB_PATH";
# Language specific setup
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
if: ${{ matrix.project.lang == 'golang' }}
with:
go-version: ${{ matrix.project.lang_version }}
- uses: acifani/setup-tinygo@b2ba42b249c7d3efdfe94166ec0f48b3191404f7
if: ${{ matrix.project.lang == 'golang' }}
with:
tinygo-version: ${{ matrix.project.tinygo_version }}
install-binaryen: "false"
- name: install wit-bindgen-wrpc
shell: bash
run: |
curl -LO https://github.com/bytecodealliance/wrpc/releases/download/v0.11.1/wit-bindgen-wrpc-x86_64-unknown-linux-musl;
echo "7ae7607987a208eda2a44a0dfc376ebf681321443151589a0f0004f53da43258 wit-bindgen-wrpc-x86_64-unknown-linux-musl" | sha256sum -c -;
mv wit-bindgen-wrpc-x86_64-unknown-linux-musl wit-bindgen-wrpc
chmod +x wit-bindgen-wrpc
install -m 755 wit-bindgen-wrpc /usr/local/bin/
# Validate example [local.]wadm.yaml if present
- name: validate wadm.yaml
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
shell: bash
run: |
[[ ! -f wadm.yaml ]] || wash app validate wadm.yaml
[[ ! -f local.wadm.yaml ]] || wash app validate local.wadm.yaml
# Build example project(s)
- name: build project
run: wash build
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
# Install wit-bindgen
- uses: taiki-e/install-action@2c3c8dfabf5933531aca0613c6b0c173fa51745e
with:
tool: wit-bindgen-cli
# Build required project if necessary
- name: Build dependent component if present
shell: bash
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
run: |
if [[ -f component/wasmcloud.toml ]]; then
wash build -p component/wasmcloud.toml;
fi
# Run the local.wadm that comes with the example
- name: test provider load
if: ${{ matrix.project.test_deploy && matrix.wash-version == 'current' }}
shell: bash
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
run: |
set -xe
wash up &
WASH_PID=$!
sleep 4;
wash app deploy ${{ matrix.project.test_deploy }};
TRIES=0
while [[ $(wash get inventory --output=json | jq '.inventories[0].providers | length') -eq 0 ]] ; do
if [[ $TRIES -gt 10 ]]; then
echo "❌ failed to find provider in inventory output after deploying example manifest";
exit -1;
fi
TRIES=$((TRIES+1));
sleep 1;
done;
echo "✅ successfully started at least one provider";
wash app delete ${{ matrix.project.test_deploy }};
kill $WASH_PID;
exit 0;