Skip to content

Update Spin and Go versions for actions #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- uses: azure/setup-kubectl@v4
- uses: fermyon/actions/spin/setup@v1
with:
version: "v2.4.2"
version: "v2.7.0"

- name: Setup build env
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ target/

.tmp

test/*
test/*

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we keep IDE specific settings to local computer, not upstream.

.vscode/*
6 changes: 3 additions & 3 deletions images/spin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM --platform=${BUILDPLATFORM} rust:1.71 AS build
FROM --platform=${BUILDPLATFORM} rust:1.79 AS build
WORKDIR /opt/build
COPY . .
RUN rustup target add wasm32-wasi && cargo build --target wasm32-wasi --release

FROM --platform=linux/amd64 golang:1.21.3-bullseye AS build-go
FROM --platform=linux/amd64 golang:1.23.2-bullseye AS build-go
WORKDIR /opt/build
COPY . .
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
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
RUN cd go-hello && tinygo build -target=wasi -o spin_go_hello.wasm main.go

FROM scratch
Expand Down
16 changes: 2 additions & 14 deletions scripts/deploy-workloads.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,16 @@ if ! command -v kubectl &> /dev/null; then
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl;
fi

update_mqtt_workload_with_broker_cluster_ip() {
local dir=$1
echo "Waiting for emqx pod to be ready"
kubectl wait --for=condition=ready --timeout=20s pod/emqx
# The MQTT trigger cannot do DNS resolution, so we need to use the IP address of the MQTT broker
# Replace "EMQX_CLUSTER_IP" with the actual ClusterIP of the EMQX service
local cluster_ip=$(kubectl get svc emqx -o jsonpath='{.spec.clusterIP}')
sed -i "s/EMQX_CLUSTER_IP/$cluster_ip/g" $dir/workloads.yaml
echo "Updated workloads.yaml with ClusterIP: $cluster_ip"
}


# apply the workloads
echo ">>> apply workloads"
kubectl apply -f tests/workloads-common
# wait for all the pods to be ready
kubectl wait --for=condition=ready --timeout=120s pod --all

if [ "$1" == "workloads-pushed-using-spin-registry-push" ]; then
update_mqtt_workload_with_broker_cluster_ip "tests/workloads-pushed-using-spin-registry-push"
echo "deploying spin apps pushed to registry using 'spin registry push' command"
kubectl apply -f tests/workloads-pushed-using-spin-registry-push
else
update_mqtt_workload_with_broker_cluster_ip "tests/workloads-pushed-using-docker-build-push"
echo "deploying spin apps pushed to registry using 'docker build && k3d image import' command"
kubectl apply -f tests/workloads-pushed-using-docker-build-push
fi
Expand Down
6 changes: 3 additions & 3 deletions scripts/setup-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ sudo rustup target add wasm32-wasi && sudo rustup target add wasm32-unknown-unkn

## setup tinygo. required for building test spin app
echo "setting up tinygo"
wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb
sudo dpkg -i tinygo_0.30.0_amd64.deb
rm tinygo_0.30.0_amd64.deb
wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb
sudo dpkg -i tinygo_0.34.0_amd64.deb
rm tinygo_0.34.0_amd64.deb
28 changes: 7 additions & 21 deletions tests/src/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ mod test {
anyhow::bail!("kubectl is not installed");
}

// Port forward the emqx mqtt broker
let forward_port = port_forward_emqx(mqtt_port).await?;

// Publish a message to the emqx broker
let mut mqttoptions = rumqttc::MqttOptions::new("123", "127.0.0.1", forward_port);
// Publish a message to the MQTT broker
let mut mqttoptions = rumqttc::MqttOptions::new("123", "test.mosquitto.org", mqtt_port);
mqttoptions.set_keep_alive(std::time::Duration::from_secs(1));

let (client, mut eventloop) = rumqttc::AsyncClient::new(mqttoptions, 10);
client
.subscribe("hello", rumqttc::QoS::AtMostOnce)
.subscribe(
"containerd-shim-spin/mqtt-test-17h24d",
rumqttc::QoS::AtMostOnce,
)
.await
.unwrap();

Expand All @@ -153,7 +153,7 @@ mod test {
for _i in 0..iterations {
client
.publish(
"hello",
"containerd-shim-spin/mqtt-test-17h24d",
rumqttc::QoS::AtLeastOnce,
false,
message.as_bytes(),
Expand Down Expand Up @@ -227,20 +227,6 @@ mod test {
Ok(port)
}

async fn port_forward_emqx(emqx_port: u16) -> Result<u16> {
let port = get_random_port()?;

println!(" >>> kubectl portforward emqx {}:{} ", port, emqx_port);

Command::new("kubectl")
.arg("port-forward")
.arg("emqx")
.arg(format!("{}:{}", port, emqx_port))
.spawn()?;
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
Ok(port)
}

async fn get_logs_by_label(label: &str) -> Result<String> {
let output = Command::new("kubectl")
.arg("logs")
Expand Down
25 changes: 0 additions & 25 deletions tests/workloads-common/mqtt-broker.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,10 @@ spec:
- containerPort: 80
env:
- name: SPIN_VARIABLE_MQTT_TOPIC
value: hello
value: containerd-shim-spin/mqtt-test-17h24d
# The MQTT trigger cannot do DNS resolution, so we need to use the IP address of the MQTT broker
# Substitute `EMQX_CLUSTER_IP` with the result of `kubectl get svc emqx -n default -o jsonpath='{.spec.clusterIP}'`
- name: SPIN_VARIABLE_MQTT_BROKER_URI
value: "mqtt://EMQX_CLUSTER_IP:1883"
value: "mqtt://test.mosquitto.org"
---
apiVersion: v1
kind: Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,10 @@ spec:
- containerPort: 80
env:
- name: SPIN_VARIABLE_MQTT_TOPIC
value: hello
value: containerd-shim-spin/mqtt-test-17h24d
# The MQTT trigger cannot do DNS resolution, so we need to use the IP address of the MQTT broker
# Substitute `EMQX_CLUSTER_IP` with the result of `kubectl get svc emqx -n default -o jsonpath='{.spec.clusterIP}'`
- name: SPIN_VARIABLE_MQTT_BROKER_URI
value: "mqtt://EMQX_CLUSTER_IP:1883"
value: "mqtt://test.mosquitto.org"
---
apiVersion: v1
kind: Service
Expand Down
Loading