Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions .github/workflows/flowstate-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
description: 'Version of Intrinsic tools to use'
required: false
default: 'latest'
INTRINSIC_VM_DURATION:
description: 'Duration time (hours) for request the VM'
required: false
default: '1'
type: string

jobs:
ci:
Expand All @@ -24,6 +29,7 @@ jobs:
INTRINSIC_SOLUTION: ${{ github.event.inputs.INTRINSIC_SOLUTION }}
INTRINSIC_API_KEY: ${{ secrets.INTRINSIC_API_KEY }}
INTRINSIC_TOOL_VERSION: ${{ github.event.inputs.INTRINSIC_TOOL_VERSION }}
INTRINSIC_VM_DURATION: ${{ github.event.inputs.INTRINSIC_VM_DURATION }}
SKILLS_UNDER_TEST: |
//skills/start_stopwatch:start_stopwatch_skill
//skills/stop_stopwatch:stop_stopwatch_py_skill
Expand Down Expand Up @@ -101,10 +107,9 @@ jobs:

- name: Run CI Bash Script
shell: bash
env:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${{ github.workspace }}/bin
run: |
. ./tests/run_ci.sh --skill=${{ steps.prep_targets.outputs.skill_list }} \
--org=${INTRINSIC_ORGANIZATION} \
--solution=${INTRINSIC_SOLUTION} \
--vm-duration="${INTRINSIC_VM_DURATION}" \
--service=${{ steps.prep_targets.outputs.service_list }}\
19 changes: 11 additions & 8 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ In that way it will use the following skills: `//skills/start_stopwatch:start_st
The worklow contains one main bash script which is an end-to-end journey for performing continuous integration.
This bash goes through the following steps:

1. Check Intrinsic Organization.
2. Deploy an existing solution.
3. Build the skill(s).
4. Install the skill(s).
5. Build the service(s).
6. Install the service(s).
7. Add the service(s).
8. Add a process that uses the skill and service.
1. Check Intrinsic organization.
2. Build the skill(s).
3. Build the service(s).
4. Lease a virtual machine (vm).
5. Deploy an existing solution.
6. Install the skill(s).
7. Install the service(s).
8. Add the service(s).
9. Add a process that uses the skill and service.
10. Stop your solution.
11. Return your vm.

For running the github action:

Expand Down
212 changes: 152 additions & 60 deletions tests/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ echo "---This bash will go through all the CI journey ---"
# Variables setup

INTRINSIC_ORGANIZATION=""
INTRINSIC_VM_DURATION=""
SKILL_BAZEL=""
INTRINSIC_SOLUTION=""
SERVICE_BAZEL=""
Expand All @@ -18,6 +19,10 @@ while [[ "$#" -gt 0 ]]; do
INTRINSIC_ORGANIZATION="${1#*=}"
echo "Argument --org received: $INTRINSIC_ORGANIZATION"
;;
--vm-duration=*)
INTRINSIC_VM_DURATION="${1#*=}"
echo "Argument --vm-duration received: $INTRINSIC_VM_DURATION"
;;
--skill=*)
SKILL_BAZEL="${1#*=}"
echo "Argument --skill received: $SKILL_BAZEL (comma-separated if multiple)"
Expand Down Expand Up @@ -58,62 +63,130 @@ export INTRINSIC_ORGANIZATION ORG

echo ""

echo "2. Deploy an existing solution."
echo "2. Build the skill(s)."
echo "NOTE: You should have a skill created in order to build it in this step."

echo "NOTE: You should have your solution running with the corresponding id."
SKILL_BAZEL=$(echo "$SKILL_BAZEL" | xargs)

echo "2.1. Checking the solution id."
if [ -n "$SKILL_BAZEL" ]; then
SKILL_TARGETS=$(echo "$SKILL_BAZEL" | tr ',' ' ')

echo "Building all skills with the targets: $SKILL_TARGETS"

if [ -z "$INTRINSIC_SOLUTION" ]; then
inctl solution list --filter running_in_sim,running_on_hw --org "$INTRINSIC_ORGANIZATION"
echo ""
read -p "Please, copy the solution id: " INTRINSIC_SOLUTION
if [ -z "$INTRINSIC_SOLUTION" ]; then
echo "Error! Solution id wasn't set."
bazel build $SKILL_TARGETS

if [ $? -ne 0 ]; then
echo "Error: Bazel build for skills failed. Exiting."
exit 1
else
export INTRINSIC_SOLUTION="$INTRINSIC_SOLUTION"
echo "Done! The INTRINSIC_SOLUTION has been set to: $INTRINSIC_SOLUTION"
fi
echo "Successfully built all skills."
else
export INTRINSIC_SOLUTION="$INTRINSIC_SOLUTION"
echo "Done! The INTRINSIC_SOLUTION has been set to: $INTRINSIC_SOLUTION"
echo "No skill targets were provided. Skipping build step."
fi

echo ""

echo "2.2. Get the solution from the id."
echo "3. Build the service(s)"
echo "NOTE: You should have a service created in order to build it in this step."

SERVICE_BAZEL=$(echo "$SERVICE_BAZEL" | xargs)

if [ -n "$SERVICE_BAZEL" ]; then
SERVICE_TARGETS=$(echo "$SERVICE_BAZEL" | tr ',' ' ')

echo "Building all services with the targets: $SERVICE_TARGETS"

bazel build $SERVICE_TARGETS

inctl solution get $INTRINSIC_SOLUTION --org "$INTRINSIC_ORGANIZATION"
if [ $? -ne 0 ]; then
echo "Error: Bazel build for service failed. Exiting."
exit 1
fi
echo "Successfully built all services."
else
echo "No services targets were provided. Skipping build step."
fi

echo ""

echo "3. Build the skill(s)."
echo "NOTE: You should have a skill created in order to build it in this step."
echo "4.Lease a VM"

if [ -n "$INTRINSIC_VM_DURATION" ]; then
echo "Requesting VM for $INTRINSIC_VM_DURATION hours..."
lease_output=$(inctl vm lease --silent -d "${INTRINSIC_VM_DURATION}h" --org "$INTRINSIC_ORGANIZATION")
lease_status=$?
if [ $lease_status -eq 0 ]; then
echo ""
echo "VM lease request successful!"
extracted_vm_instance=$lease_output

if [ -n "$extracted_vm_instance" ]; then
VM_INSTANCE="$extracted_vm_instance"
echo "Auto-captured VM instance ID: $VM_INSTANCE"
export VM_INSTANCE
else
echo "Warning: Could not auto-capture VM instance ID from command output."
echo "Output was: $lease_output"
read -p "Please, copy and paste the VM instance ID to return it later: " VM_INSTANCE < /dev/tty
if [ -z "$VM_INSTANCE" ]; then
echo "Warning: VM instance ID was not provided. You will need to return it manually."
fi
fi
else
echo "There was an error leasing the VM."
echo "Command output: $lease_output"
echo "Please, verify the command and its output."
fi
else
echo "VM lease skipped due to missing time duration."
fi

SKILL_BAZEL=$(echo "$SKILL_BAZEL" | xargs)
echo ""

if [ -n "$SKILL_BAZEL" ]; then
SKILL_TARGETS=$(echo "$SKILL_BAZEL" | tr ',' ' ')
echo "5. Deploy an existing solution."

echo "Building all skills with the targets: $SKILL_TARGETS"
echo "5.1. Starting the solution."

bazel build $SKILL_TARGETS
if [ -n "$INTRINSIC_SOLUTION" ]; then
echo "Starting solution '$INTRINSIC_SOLUTION'..."
(INTRINSIC_SOLUTION="" inctl solution start "$INTRINSIC_SOLUTION" --org "$INTRINSIC_ORGANIZATION" --cluster "$lease_output")

if [ $? -ne 0 ]; then
echo "Error: Bazel build for skills failed. Exiting."
exit 1
fi
echo "Successfully built all skills."
timeout_seconds=300 # 5 minutes
check_interval_seconds=10
elapsed_seconds=0

while true; do
status_output=$(inctl solution get "$INTRINSIC_SOLUTION" --org "$INTRINSIC_ORGANIZATION")

if echo "$status_output" | grep -q "is running"; then
echo "Solution '$INTRINSIC_SOLUTION' is now running."
break
fi

# Check for timeout
if [ "$elapsed_seconds" -ge "$timeout_seconds" ]; then
echo "Error: Timed out after $timeout_seconds seconds."
echo "Last status check output:"
echo "$status_output"
exit 1
fi

echo "Not ready yet. Retrying in $check_interval_seconds seconds."
sleep "$check_interval_seconds"
elapsed_seconds=$((elapsed_seconds + check_interval_seconds))
done
echo "Waiting 3 minutes for the propagation of the solution..."
sleep 180
else
echo "No skill targets were provided. Skipping build step."
echo "Warning: '$INTRINSIC_SOLUTION' is not set. Skipping start and wait logic."
exit 1
fi

echo ""

echo "4. Install the skill(s)."
echo "6. Install the skill(s)."

INSTALLED_SKILLS=$(inctl skill list --org "$INTRINSIC_ORGANIZATION" --solution "$INTRINSIC_SOLUTION")
INSTALLED_SKILLS=$(inctl skill list --org "$INTRINSIC_ORGANIZATION" --solution "$INTRINSIC_SOLUTION" --filter "sideloaded" 2>&1)

IFS=',' read -ra SKILL_ARRAY <<< "$SKILL_BAZEL"

Expand All @@ -138,36 +211,14 @@ for SKILL in "${SKILL_ARRAY[@]}"; do
inctl skill install bazel-bin/"$skill_package"/"$skill_target".bundle.tar --solution "$INTRINSIC_SOLUTION" --org "$INTRINSIC_ORGANIZATION"
if [ $? -ne 0 ]; then
echo "Error: Skill installation for '$SKILL' failed. Exiting."
exit 1
fi
fi
done

echo ""

echo "5. Build the service(s)"
echo "NOTE: You should have a service created in order to build it in this step."

SERVICE_BAZEL=$(echo "$SERVICE_BAZEL" | xargs)

if [ -n "$SERVICE_BAZEL" ]; then
SERVICE_TARGETS=$(echo "$SERVICE_BAZEL" | tr ',' ' ')

echo "Building all services with the targets: $SERVICE_TARGETS"

bazel build $SERVICE_TARGETS

if [ $? -ne 0 ]; then
echo "Error: Bazel build for service failed. Exiting."
exit 1
fi
echo "Successfully built all services."
else
echo "No services targets were provided. Skipping build step."
fi

echo ""

echo "6. Install the service(s)."
echo "7. Install the service(s)."

INSTALLED_SERVICES=$(inctl asset list --asset_types="service" --org "$INTRINSIC_ORGANIZATION" --solution "$INTRINSIC_SOLUTION")

Expand All @@ -182,7 +233,7 @@ for SERVICE in "${SERVICE_ARRAY[@]}"; do
else
echo "Warning: No colon found in SERVICE ('$SERVICE'). Assuming it's a target within the current package."
service_package=""
service_target="$SERVICE"
service_target="$SERVICE"
fi

SERVICES_TARGET+=("$service_target")
Expand All @@ -197,6 +248,7 @@ for SERVICE in "${SERVICE_ARRAY[@]}"; do
echo "Installing service: $SERVICE"
inctl service install bazel-bin/"$service_package"/"$service_target".bundle.tar --solution "$INTRINSIC_SOLUTION" --org "$INTRINSIC_ORGANIZATION"


if [ $? -ne 0 ]; then
echo "Error: Service installation for '$SERVICE' failed. Exiting."
fi
Expand All @@ -205,9 +257,9 @@ done

echo ""

echo "7. Add the service(s)."
echo "8. Add the service(s)."

echo "7.1 Listing your installed assets for services"
echo "8.1 Listing your installed assets for services"

INSTALLED_SERVICES=()

Expand All @@ -231,7 +283,7 @@ while IFS= read -r full_service_name; do
done
done < <(inctl asset list --org "$INTRINSIC_ORGANIZATION" --solution "$INTRINSIC_SOLUTION")

echo "7.2 Add the service(s)"
echo "8.2 Add the service(s)"

if [ ${#INSTALLED_SERVICES[@]} -eq 0 ]; then
echo "No matching installed services found to add. Skipping this step."
Expand Down Expand Up @@ -260,7 +312,7 @@ else
fi

echo ""
echo "8. Add a process that uses the skill and service."
echo "9. Add a process that uses the skill and service."

PYTHON_SCRIPT_PATH="./tests/sbl_ci.py"

Expand All @@ -283,6 +335,46 @@ fi

echo ""

echo "10. Stopping your solution"

echo "Stopping the solution '$INTRINSIC_SOLUTION' started in the first steps."
(INTRINSIC_SOLUTION="" inctl solution stop "$INTRINSIC_SOLUTION" --org "$INTRINSIC_ORGANIZATION" --cluster "$lease_output")

echo "Waiting for solution to enter a not running state."

timeout_seconds=300 # 5 minutes
check_interval_seconds=10
elapsed_seconds=0

while true; do
status_output=$(inctl solution get "$INTRINSIC_SOLUTION" --org "$INTRINSIC_ORGANIZATION")

if echo "$status_output" | grep -q "not running"; then
echo "Solution '$INTRINSIC_SOLUTION' is not running."
break
fi

# Check for timeout
if [ "$elapsed_seconds" -ge "$timeout_seconds" ]; then
echo "Error: Timed out after $timeout_seconds seconds."
echo "Last status check output:"
echo "$status_output"
exit 1
fi

echo "Not stopped yet. Retrying in $check_interval_seconds seconds."
sleep "$check_interval_seconds"
elapsed_seconds=$((elapsed_seconds + check_interval_seconds))
done

echo ""

echo "11. Return your VM"

echo "Returning your VM requested in the first steps."

inctl vm return "$lease_output" --org "$INTRINSIC_ORGANIZATION"

echo "---------------------------"
echo "CI Journey finished"
echo "---------------------------"