Skip to content

Commit 6ea7aed

Browse files
authored
Refactor the existing Flowstate CI GitHub workflow (#26)
* Resolve merge conflict in CI workflow * Adding composite action: deploy-assets * Adding composite action: run-sbl-test * Adding javascript action: start-solution * Updating README file and images * Replacing warning * Fixing number of spaces * Replacing warning * Adressing comment
1 parent 9abfcd8 commit 6ea7aed

File tree

16 files changed

+55318
-67
lines changed

16 files changed

+55318
-67
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 'Build Bazel Targets'
2+
description: 'Builds a list of skill and service targets.'
3+
4+
inputs:
5+
skills:
6+
description: 'Comma-separated list of skill targets'
7+
required: false
8+
services:
9+
description: 'Comma-separated list of service targets'
10+
required: false
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Prepare Targets
16+
id: prep
17+
shell: bash
18+
run: |
19+
# Combine lists, being careful not to add extra commas
20+
ALL_TARGETS=""
21+
if [ -n "${{ inputs.skills }}" ]; then
22+
ALL_TARGETS="${{ inputs.skills }}"
23+
fi
24+
25+
if [ -n "${{ inputs.services }}" ]; then
26+
if [ -n "$ALL_TARGETS" ]; then
27+
ALL_TARGETS="${ALL_TARGETS},${{ inputs.services }}"
28+
else
29+
ALL_TARGETS="${{ inputs.services }}"
30+
fi
31+
fi
32+
33+
# Convert comma-separated list to a space-separated list for bazel
34+
if [ -n "$ALL_TARGETS" ]; then
35+
echo "build_list=$(echo "$ALL_TARGETS" | tr ',' ' ')" >> $GITHUB_OUTPUT
36+
else
37+
echo "build_list=" >> $GITHUB_OUTPUT
38+
fi
39+
40+
- name: Build All Targets
41+
shell: bash
42+
run: |
43+
TARGETS_TO_BUILD="${{ steps.prep.outputs.build_list }}"
44+
if [ -n "$TARGETS_TO_BUILD" ]; then
45+
echo "Building targets: $TARGETS_TO_BUILD"
46+
bazel build $TARGETS_TO_BUILD
47+
else
48+
echo "No skill or service targets were provided. Skipping build."
49+
fi
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: 'Deploy Intrinsic Assets'
2+
description: 'Installs and adds skills and services to a solution.'
3+
4+
inputs:
5+
organization:
6+
description: 'The Intrinsic organization'
7+
required: true
8+
solution-id:
9+
description: 'The Intrinsic solution ID'
10+
required: true
11+
skills:
12+
description: 'Comma-separated list of skill targets'
13+
required: false
14+
services:
15+
description: 'Comma-separated list of service targets'
16+
required: false
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Install Skills
22+
shell: bash
23+
run: |
24+
if [ -z "${{ inputs.skills }}" ]; then
25+
echo "No skills to install."
26+
exit 0
27+
fi
28+
29+
echo "Fetching list of currently installed sideloaded skills..."
30+
INSTALLED_SKILLS=$(inctl skill list --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}" --filter "sideloaded" 2>&1)
31+
32+
IFS=',' read -ra SKILL_ARRAY <<< "${{ inputs.skills }}"
33+
for SKILL in "${SKILL_ARRAY[@]}"; do
34+
SKILL=$(echo "$SKILL" | xargs) # trim whitespace
35+
if [ -z "$SKILL" ]; then continue; fi
36+
37+
echo "Processing skill: $SKILL"
38+
skill_package="${SKILL%:*}"
39+
skill_package_dir="${skill_package#//}" # Remove leading //
40+
skill_name=$(basename "$skill_package_dir")
41+
skill_target="${SKILL##*:}"
42+
43+
if echo "$INSTALLED_SKILLS" | grep -q "com.example.${skill_name}"; then
44+
echo "Skill 'com.example.${skill_name}' is already installed. Removing..."
45+
inctl asset uninstall "com.example.${skill_name}" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}"
46+
fi
47+
48+
BUNDLE_PATH="bazel-bin/${skill_package_dir}/${skill_target}.bundle.tar"
49+
echo "Installing skill from $BUNDLE_PATH"
50+
inctl skill install "$BUNDLE_PATH" --solution "${{ inputs.solution-id }}" --org "${{ inputs.organization }}"
51+
done
52+
53+
- name: Install and Add Services
54+
shell: bash
55+
run: |
56+
if [ -z "${{ inputs.services }}" ]; then
57+
echo "No services to install/add."
58+
exit 0
59+
fi
60+
61+
echo "Fetching list of currently installed services..."
62+
INSTALLED_SERVICES_LIST=$(inctl asset list --asset_types="service" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}")
63+
64+
declare -a SERVICES_TARGET_NAMES
65+
66+
echo "--- Installing Services ---"
67+
IFS=',' read -ra SERVICE_ARRAY <<< "${{ inputs.services }}"
68+
for SERVICE in "${SERVICE_ARRAY[@]}"; do
69+
SERVICE=$(echo "$SERVICE" | xargs) # trim whitespace
70+
if [ -z "$SERVICE" ]; then continue; fi
71+
72+
echo "Processing service: $SERVICE"
73+
service_package="${SERVICE%:*}"
74+
service_package_dir="${service_package#//}" # Strip //
75+
service_target="${SERVICE##*:}"
76+
77+
SERVICES_TARGET_NAMES+=("$service_target")
78+
79+
if echo "$INSTALLED_SERVICES_LIST" | grep -q "com.example.${service_target}"; then
80+
echo "Service 'com.example.${service_target}' is already installed. Deleting and uninstalling..."
81+
inctl service delete "${service_target}" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}"
82+
inctl asset uninstall "com.example.${service_target}" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}"
83+
echo "Waiting for 20 seconds..."
84+
sleep 20
85+
fi
86+
87+
BUNDLE_PATH="bazel-bin/${service_package_dir}/${service_target}.bundle.tar"
88+
echo "Installing service from $BUNDLE_PATH"
89+
inctl service install "$BUNDLE_PATH" --solution "${{ inputs.solution-id }}" --org "${{ inputs.organization }}"
90+
done
91+
92+
echo "--- Adding Services ---"
93+
if [ ${#SERVICES_TARGET_NAMES[@]} -eq 0 ]; then
94+
echo "No services were installed, skipping 'add' step."
95+
exit 0
96+
fi
97+
98+
echo "Fetching full list of available assets to find service full names..."
99+
LATEST_ASSET_LIST=$(inctl asset list --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}")
100+
101+
for SERVICE_SHORT_NAME in "${SERVICES_TARGET_NAMES[@]}"; do
102+
SERVICE_FULL_NAME=""
103+
while IFS= read -r full_service_name; do
104+
if [[ "$full_service_name" == *".$SERVICE_SHORT_NAME" ]]; then
105+
SERVICE_FULL_NAME=$(echo "$full_service_name" | xargs)
106+
break
107+
fi
108+
done <<< "$LATEST_ASSET_LIST"
109+
110+
if [ -n "$SERVICE_FULL_NAME" ]; then
111+
echo "Adding service '$SERVICE_FULL_NAME' as '$SERVICE_SHORT_NAME'..."
112+
inctl service add "$SERVICE_FULL_NAME" \
113+
--org "${{ inputs.organization }}" \
114+
--solution "${{ inputs.solution-id }}" \
115+
--name "$SERVICE_SHORT_NAME"
116+
else
117+
echo "::warning::Could not find full name for short name '$SERVICE_SHORT_NAME'. Skipping 'add'."
118+
fi
119+
done
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'Run SBL Test'
2+
description: 'Runs a Bazel-based SBL test target.'
3+
4+
inputs:
5+
organization:
6+
description: 'The Intrinsic organization'
7+
required: true
8+
solution-id:
9+
description: 'The Intrinsic solution ID'
10+
required: true
11+
test-target:
12+
description: 'The Bazel target of the test to run'
13+
required: true
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Run SBL Python Test
19+
shell: bash
20+
run: |
21+
echo "Running SBL test: ${{ inputs.test-target }}"
22+
bazel run ${{ inputs.test-target }} -- \
23+
--org "${{ inputs.organization }}" \
24+
--solution-id "${{ inputs.solution-id }}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Start Intrinsic Solution'
2+
description: 'Leases a VM, starts a solution, and registers a post-job hook to clean up.'
3+
4+
inputs:
5+
organization:
6+
description: 'The Intrinsic organization'
7+
required: true
8+
solution-id:
9+
description: 'The Intrinsic solution ID'
10+
required: true
11+
vm-duration:
12+
description: 'Duration time (hours) for the VM lease'
13+
required: false
14+
default: '1'
15+
16+
runs:
17+
using: 'node20'
18+
main: 'dist/index.js'
19+
post: 'dist/teardown.js'

0 commit comments

Comments
 (0)