Skip to content

Commit 62f6197

Browse files
Merge pull request #217 from kate-goldenring/update-tinygo-and-spin
Update Spin and Go versions for actions
2 parents 71c8351 + 3e53c6e commit 62f6197

File tree

11 files changed

+43
-77
lines changed

11 files changed

+43
-77
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- uses: azure/setup-kubectl@v4
4747
- uses: fermyon/actions/spin/setup@v1
4848
with:
49-
version: "v2.4.2"
49+
version: "v2.7.0"
5050

5151
- name: Setup build env
5252
run: |
@@ -63,7 +63,7 @@ jobs:
6363
run: make install-k3d
6464

6565
- name: run integration tests
66-
run: BIN_DIR="./bin" make integration-tests
66+
run: BIN_DIR="./bin" IS_CI=true make integration-tests
6767

6868
- name: run collect debug logs
6969
if: failure()
@@ -76,7 +76,9 @@ jobs:
7676
name: debug-logs
7777
path: debug-logs/
7878
retention-days: 5
79-
79+
- name: Output runner storage on failure
80+
if: failure()
81+
run: df -h
8082
- name: clean up k3d
8183
if: always()
8284
run: make tests/clean

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ else
1212
VERBOSE_FLAG := -vvv
1313
endif
1414

15+
IS_CI ?= false
1516
BIN_DIR ?=
1617

1718
UNAME_S := $(shell uname -s)
@@ -52,6 +53,9 @@ unit-tests: build
5253
integration-tests: prepare-cluster-and-images integration-docker-build-push-tests integration-spin-registry-push-tests
5354
echo "Integration tests complete. You may run 'make tests/clean' to clean up the test environment."
5455

56+
free-disk:
57+
./scripts/free-disk.sh
58+
5559
# integration-tests for workloads pushed using docker build push
5660
integration-docker-build-push-tests:
5761
./scripts/run-integration-tests.sh "workloads-pushed-using-docker-build-push"
@@ -126,7 +130,7 @@ deploy-workloads-pushed-using-spin-registry-push:
126130
pod-terminates-test:
127131
./scripts/pod-terminates-test.sh
128132

129-
prepare-cluster-and-images: check-bins move-bins up pod-status-check
133+
prepare-cluster-and-images: check-bins move-bins up free-disk pod-status-check
130134

131135
# clean
132136

images/spin/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM --platform=${BUILDPLATFORM} rust:1.71 AS build
1+
FROM --platform=${BUILDPLATFORM} rust:1.79 AS build
22
WORKDIR /opt/build
33
COPY . .
44
RUN rustup target add wasm32-wasi && cargo build --target wasm32-wasi --release
55

6-
FROM --platform=linux/amd64 golang:1.21.3-bullseye AS build-go
6+
FROM --platform=linux/amd64 golang:1.23.2-bullseye AS build-go
77
WORKDIR /opt/build
88
COPY . .
9-
RUN curl -LO https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb && dpkg -i tinygo_0.30.0_amd64.deb
9+
RUN curl -LO https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb && dpkg -i tinygo_0.34.0_amd64.deb
1010
RUN cd go-hello && tinygo build -target=wasi -o spin_go_hello.wasm main.go
1111

1212
FROM scratch

scripts/deploy-workloads.sh

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,16 @@ if ! command -v kubectl &> /dev/null; then
99
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl;
1010
fi
1111

12-
update_mqtt_workload_with_broker_cluster_ip() {
13-
local dir=$1
14-
echo "Waiting for emqx pod to be ready"
15-
kubectl wait --for=condition=ready --timeout=20s pod/emqx
16-
# The MQTT trigger cannot do DNS resolution, so we need to use the IP address of the MQTT broker
17-
# Replace "EMQX_CLUSTER_IP" with the actual ClusterIP of the EMQX service
18-
local cluster_ip=$(kubectl get svc emqx -o jsonpath='{.spec.clusterIP}')
19-
sed -i "s/EMQX_CLUSTER_IP/$cluster_ip/g" $dir/workloads.yaml
20-
echo "Updated workloads.yaml with ClusterIP: $cluster_ip"
21-
}
22-
23-
2412
# apply the workloads
2513
echo ">>> apply workloads"
2614
kubectl apply -f tests/workloads-common
15+
# wait for all the pods to be ready
16+
kubectl wait --for=condition=ready --timeout=120s pod --all
2717

2818
if [ "$1" == "workloads-pushed-using-spin-registry-push" ]; then
29-
update_mqtt_workload_with_broker_cluster_ip "tests/workloads-pushed-using-spin-registry-push"
3019
echo "deploying spin apps pushed to registry using 'spin registry push' command"
3120
kubectl apply -f tests/workloads-pushed-using-spin-registry-push
3221
else
33-
update_mqtt_workload_with_broker_cluster_ip "tests/workloads-pushed-using-docker-build-push"
3422
echo "deploying spin apps pushed to registry using 'docker build && k3d image import' command"
3523
kubectl apply -f tests/workloads-pushed-using-docker-build-push
3624
fi

scripts/free-disk.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
IS_CI=${IS_CI:-false}
4+
5+
# clean up Rust builds to free space
6+
cargo install cargo-clean-all
7+
cargo clean-all -y
8+
if [ "$IS_CI" = true ]; then
9+
# remove all docker images
10+
docker system prune -af
11+
fi

scripts/setup-linux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ sudo rustup target add wasm32-wasi && sudo rustup target add wasm32-unknown-unkn
88

99
## setup tinygo. required for building test spin app
1010
echo "setting up tinygo"
11-
wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb
12-
sudo dpkg -i tinygo_0.30.0_amd64.deb
13-
rm tinygo_0.30.0_amd64.deb
11+
wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb
12+
sudo dpkg -i tinygo_0.34.0_amd64.deb
13+
rm tinygo_0.34.0_amd64.deb

scripts/up.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ docker build -t k3d-shim-test "$dockerfile_path"
1414

1515
k3d cluster create "$cluster_name" \
1616
--image k3d-shim-test --api-port 6551 -p '8082:80@loadbalancer' --agents 2 \
17-
--registry-create test-registry:0.0.0.0:5000
17+
--registry-create test-registry:0.0.0.0:5000 \
18+
--k3s-arg '--kubelet-arg=eviction-hard=imagefs.available<1%,nodefs.available<1%@agent:*' \
19+
--k3s-arg '--kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%@agent:*'
1820

1921
kubectl wait --for=condition=ready node --all --timeout=120s
2022

tests/src/integration_test.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ mod test {
135135
anyhow::bail!("kubectl is not installed");
136136
}
137137

138-
// Port forward the emqx mqtt broker
139-
let forward_port = port_forward_emqx(mqtt_port).await?;
140-
141-
// Publish a message to the emqx broker
142-
let mut mqttoptions = rumqttc::MqttOptions::new("123", "127.0.0.1", forward_port);
138+
// Publish a message to the MQTT broker
139+
let mut mqttoptions = rumqttc::MqttOptions::new("123", "test.mosquitto.org", mqtt_port);
143140
mqttoptions.set_keep_alive(std::time::Duration::from_secs(1));
144141

145142
let (client, mut eventloop) = rumqttc::AsyncClient::new(mqttoptions, 10);
146143
client
147-
.subscribe("hello", rumqttc::QoS::AtMostOnce)
144+
.subscribe(
145+
"containerd-shim-spin/mqtt-test-17h24d",
146+
rumqttc::QoS::AtMostOnce,
147+
)
148148
.await
149149
.unwrap();
150150

@@ -153,7 +153,7 @@ mod test {
153153
for _i in 0..iterations {
154154
client
155155
.publish(
156-
"hello",
156+
"containerd-shim-spin/mqtt-test-17h24d",
157157
rumqttc::QoS::AtLeastOnce,
158158
false,
159159
message.as_bytes(),
@@ -227,20 +227,6 @@ mod test {
227227
Ok(port)
228228
}
229229

230-
async fn port_forward_emqx(emqx_port: u16) -> Result<u16> {
231-
let port = get_random_port()?;
232-
233-
println!(" >>> kubectl portforward emqx {}:{} ", port, emqx_port);
234-
235-
Command::new("kubectl")
236-
.arg("port-forward")
237-
.arg("emqx")
238-
.arg(format!("{}:{}", port, emqx_port))
239-
.spawn()?;
240-
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
241-
Ok(port)
242-
}
243-
244230
async fn get_logs_by_label(label: &str) -> Result<String> {
245231
let output = Command::new("kubectl")
246232
.arg("logs")

tests/workloads-common/mqtt-broker.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/workloads-pushed-using-docker-build-push/workloads.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,10 @@ spec:
284284
- containerPort: 80
285285
env:
286286
- name: SPIN_VARIABLE_MQTT_TOPIC
287-
value: hello
287+
value: containerd-shim-spin/mqtt-test-17h24d
288288
# The MQTT trigger cannot do DNS resolution, so we need to use the IP address of the MQTT broker
289-
# Substitute `EMQX_CLUSTER_IP` with the result of `kubectl get svc emqx -n default -o jsonpath='{.spec.clusterIP}'`
290289
- name: SPIN_VARIABLE_MQTT_BROKER_URI
291-
value: "mqtt://EMQX_CLUSTER_IP:1883"
290+
value: "mqtt://test.mosquitto.org"
292291
---
293292
apiVersion: v1
294293
kind: Service

0 commit comments

Comments
 (0)