Skip to content

Commit adda12c

Browse files
committed
Add Dockerfile and GitHub Actions workflow for KNIME extension build
1 parent af47399 commit adda12c

File tree

6 files changed

+2574
-1009
lines changed

6 files changed

+2574
-1009
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
echo "=== KNIME Workflow Execution Summary ==="
3+
4+
# Get workflow information
5+
if [ -f "/home/knime/workflow-info.env" ]; then
6+
. /home/knime/workflow-info.env
7+
WORKFLOW_NAME=$(basename "$WORKFLOW_DIR")
8+
echo "Executed Workflow: $WORKFLOW_NAME"
9+
echo "Workflow Location: $WORKFLOW_DIR"
10+
else
11+
echo "⚠ WARNING: Could not determine which workflow was executed"
12+
WORKFLOW_NAME="Unknown"
13+
fi
14+
15+
echo ""
16+
17+
if [ -f "/home/knime/workflow-console.log" ]; then
18+
echo "Log file found, analyzing execution..."
19+
LOG_FILE="/home/knime/workflow-console.log"
20+
21+
echo "Workflow Status:"
22+
if grep -q "Workflow executed sucessfully" "$LOG_FILE" || grep -q "Workflow execution done" "$LOG_FILE"; then
23+
echo "✓ SUCCESS: Workflow completed successfully"
24+
elif grep -q "ERROR" "$LOG_FILE"; then
25+
echo "✗ FAILED: Workflow execution failed"
26+
else
27+
echo "? UNKNOWN: Could not determine workflow status"
28+
fi
29+
30+
echo ""
31+
echo "Node Execution Summary:"
32+
# Count nodes that finished execution
33+
EXECUTED_NODES=$(grep -c "End execute" "$LOG_FILE" 2>/dev/null || echo "0")
34+
echo "- Nodes executed: $EXECUTED_NODES"
35+
36+
# List executed nodes with timing
37+
echo "- Executed nodes:"
38+
grep "End execute" "$LOG_FILE" | sed 's/.*: / /' | sed 's/ End execute/ completed in/' || echo " None found"
39+
40+
echo ""
41+
echo "Execution Timing:"
42+
# Extract workflow execution time
43+
WORKFLOW_TIME=$(grep "Workflow execution done" "$LOG_FILE" | sed -n 's/.*Finished in \([^)]*\).*/\1/p' || echo "Unknown")
44+
echo "- Total workflow time: $WORKFLOW_TIME"
45+
46+
# Extract start and end times
47+
START_TIME=$(grep "Executing workflow" "$LOG_FILE" | head -1 | cut -d' ' -f1-2 2>/dev/null || echo "Unknown")
48+
END_TIME=$(grep "Workflow execution done" "$LOG_FILE" | tail -1 | cut -d' ' -f1-2 2>/dev/null || echo "Unknown")
49+
echo "- Started: $START_TIME"
50+
echo "- Completed: $END_TIME"
51+
52+
echo ""
53+
echo "Issues Summary:"
54+
# Count errors and warnings
55+
ERROR_COUNT=$(grep -c ": ERROR :" "$LOG_FILE" 2>/dev/null || echo "0")
56+
WARN_COUNT=$(grep -c ": WARN :" "$LOG_FILE" 2>/dev/null || echo "0")
57+
echo "- Errors: $ERROR_COUNT"
58+
echo "- Warnings: $WARN_COUNT"
59+
60+
# Show first error if any
61+
if [ "$ERROR_COUNT" -gt 0 ]; then
62+
echo ""
63+
echo "First Error:"
64+
grep ": ERROR :" "$LOG_FILE" | head -1 | sed 's/^/ /'
65+
fi
66+
67+
# Show first warning if any
68+
if [ "$WARN_COUNT" -gt 0 ]; then
69+
echo ""
70+
echo "First Warning:"
71+
grep ": WARN :" "$LOG_FILE" | head -1 | sed 's/^/ /'
72+
fi
73+
74+
echo ""
75+
echo "Summary:"
76+
echo "- Workflow: $WORKFLOW_NAME"
77+
echo "- Log file location: $LOG_FILE"
78+
echo "- Log file size: $(du -h "$LOG_FILE" | cut -f1)"
79+
else
80+
echo "⚠ WARNING: No log file found at expected location"
81+
echo "Checking for alternative log locations..."
82+
find /home/knime -name "*.log" -type f 2>/dev/null | head -10
83+
fi
84+
echo "============================================"

.github/workflows/Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Define the base image
2+
FROM public.ecr.aws/i0n0z6j1/knime:5.7.0-nightly
3+
4+
# Path inside the image where the local update site will be copied
5+
ARG LOCAL_UPDATE_SITE_PATH=/home/knime/local-update-site
6+
ARG LOCAL_UPDATE_SITE_SRC
7+
ENV LOCAL_UPDATE_SITE_SRC=${LOCAL_UPDATE_SITE_SRC}
8+
9+
# Define the list of update sites and features
10+
# Add the local update site (copied into the image) to the list of update sites via file:// URL
11+
# Ensure the local update site is present in the build context under ./local-update-site
12+
ENV KNIME_UPDATE_SITES="file://${LOCAL_UPDATE_SITE_PATH}, https://update.knime.com/analytics-platform/nightly"
13+
14+
# Install features from the update sites
15+
# Allow overriding via build-arg; fallback to a sensible default matching knime.yml (group_id + ".features." + name)
16+
ARG KNIME_FEATURES_ARG
17+
ENV KNIME_FEATURES="${KNIME_FEATURES_ARG:-org.tutorial.features.first_extension.feature.group}"
18+
19+
# Install CA Certificates
20+
USER root
21+
RUN apt-get update && \
22+
apt-get install -y ca-certificates chromium-browser unzip && \
23+
update-ca-certificates && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
USER knime
27+
28+
# Copy the local update site produced by the build into the image so it's available during installation
29+
# The source folder can be overridden via --build-arg LOCAL_UPDATE_SITE_SRC=...
30+
COPY --chown=knime:knime ${LOCAL_UPDATE_SITE_SRC} ${LOCAL_UPDATE_SITE_PATH}
31+
32+
# Execute extension installation script
33+
RUN ./install-extensions.sh
34+
35+
# pre-start executor to improve startup time
36+
RUN KNIME_EXECUTOR_CONNECTION_RETRIES=0 knime/knime -data /home/knime/knime-workspace -consolelog -nosplash -application com.knime.enterprise.slave.KNIME_REMOTE_APPLICATION; rm -rf /home/knime/knime-workspace
37+
38+
# Copy the demo workflow into the image
39+
COPY --chown=knime:knime demo/ /home/knime/demo-workflow/
40+
41+
# Find and unzip the first .knwf file in the demo folder
42+
RUN KNWF_FILE=$(find /home/knime/demo-workflow -name "*.knwf" -type f | head -1) && \
43+
if [ -z "$KNWF_FILE" ]; then \
44+
echo "ERROR: No .knwf file found in demo folder" && exit 1; \
45+
fi && \
46+
WORKFLOW_NAME=$(basename "$KNWF_FILE" .knwf) && \
47+
echo "Found workflow: $KNWF_FILE" && \
48+
echo "Extracting to: /home/knime/demo-workflow/$WORKFLOW_NAME" && \
49+
unzip "$KNWF_FILE" -d "/home/knime/demo-workflow/$WORKFLOW_NAME" && \
50+
echo "WORKFLOW_DIR=/home/knime/demo-workflow/$WORKFLOW_NAME" > /home/knime/workflow-info.env
51+
52+
# Copy the workflow analysis script
53+
COPY --chown=knime:knime .github/scripts/analyze-workflow.sh /home/knime/analyze-workflow.sh
54+
RUN chmod +x /home/knime/analyze-workflow.sh
55+
56+
# Run the demo workflow to test the extension
57+
RUN . /home/knime/workflow-info.env && \
58+
echo "Running workflow from: $WORKFLOW_DIR" && \
59+
knime/knime -reset -consolelog -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir="$WORKFLOW_DIR" > /home/knime/workflow-console.log 2>&1
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: 'Run KNIME Workflow Test'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
run_build:
7+
description: 'Run build job'
8+
required: false
9+
default: 'true'
10+
pull_request:
11+
types: [opened, synchronize, reopened]
12+
push:
13+
branches: [ master ]
14+
15+
jobs:
16+
build:
17+
name: Bundle extension and build image
18+
runs-on: ubuntu-latest
19+
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run_build == 'true' }}
20+
env:
21+
LOCAL_UPDATE_SITE_DIR: local-update-site
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Pixi
27+
uses: prefix-dev/setup-pixi@v0
28+
29+
- name: Install environment
30+
run: pixi install
31+
32+
- name: Build local update site
33+
run: pixi run build
34+
35+
- name: Upload update site artifact
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: extensionartifacts-for-update-site-${{ github.run_id }}
39+
path: ${{ env.LOCAL_UPDATE_SITE_DIR }}
40+
41+
- name: Compute KNIME feature group from knime.yml
42+
id: knime_meta
43+
shell: bash
44+
run: |
45+
pixi run -e build python - <<'PY'
46+
import os
47+
import yaml
48+
with open('knime.yml', 'r', encoding='utf-8') as f:
49+
y = yaml.safe_load(f)
50+
group_id = (y.get('group_id') or '').strip()
51+
name = (y.get('name') or '').strip()
52+
if not group_id or not name:
53+
raise SystemExit(f"Failed to parse group_id/name from knime.yml (group_id={group_id}, name={name})")
54+
feature_group_id = f"{group_id}.features.{name}.feature.group"
55+
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as gh:
56+
print(f"feature_group_id={feature_group_id}", file=gh)
57+
print("Computed feature group:", feature_group_id)
58+
PY
59+
60+
- name: Build KNIME image with local update site
61+
run: |
62+
docker build \
63+
-f .github/workflows/Dockerfile \
64+
--build-arg LOCAL_UPDATE_SITE_SRC="${{ env.LOCAL_UPDATE_SITE_DIR }}" \
65+
--build-arg KNIME_FEATURES_ARG="${{ steps.knime_meta.outputs.feature_group_id }}" \
66+
-t knime-executor-with-extension:ci .
67+
68+
- name: Analyze workflow execution results
69+
id: workflow_analysis
70+
run: |
71+
echo "Extracting workflow execution results..."
72+
ANALYSIS_OUTPUT=$(docker run --rm knime-executor-with-extension:ci /home/knime/analyze-workflow.sh)
73+
echo "$ANALYSIS_OUTPUT"
74+
75+
# Extract key metrics for badge
76+
EXECUTED_NODES=$(echo "$ANALYSIS_OUTPUT" | grep "Nodes executed:" | sed 's/.*: //')
77+
ERROR_COUNT=$(echo "$ANALYSIS_OUTPUT" | grep "Errors:" | sed 's/.*: //')
78+
79+
# Determine badge status
80+
if echo "$ANALYSIS_OUTPUT" | grep -q "SUCCESS"; then
81+
if [ "$ERROR_COUNT" = "0" ]; then
82+
BADGE_MESSAGE="workflow passed-${EXECUTED_NODES} nodes"
83+
BADGE_COLOR="brightgreen"
84+
else
85+
BADGE_MESSAGE="workflow passed-${EXECUTED_NODES} nodes, ${ERROR_COUNT} errors"
86+
BADGE_COLOR="yellow"
87+
fi
88+
else
89+
BADGE_MESSAGE="workflow failed"
90+
BADGE_COLOR="red"
91+
fi
92+
93+
echo "badge_message=$BADGE_MESSAGE" >> $GITHUB_OUTPUT
94+
echo "badge_color=$BADGE_COLOR" >> $GITHUB_OUTPUT
95+
echo "executed_nodes=$EXECUTED_NODES" >> $GITHUB_OUTPUT
96+
echo "error_count=$ERROR_COUNT" >> $GITHUB_OUTPUT
97+
98+
- name: Update workflow status badge
99+
if: github.ref == 'refs/heads/master'
100+
run: |
101+
# Create badge URL that you can use in README
102+
BADGE_URL="https://img.shields.io/badge/${{ steps.workflow_analysis.outputs.badge_message }}-${{ steps.workflow_analysis.outputs.badge_color }}"
103+
echo "Badge URL: $BADGE_URL"
104+
echo "You can use this in your README.md:"
105+
echo "![Workflow Status]($BADGE_URL)"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ![Image](https://www.knime.com/sites/default/files/knime_logo_github_40x40_4layers.png) KNIME® - KNIME PYTHON EXTENSION TEMPLATE
22

33
[![CI](https://github.com/knime/knime-python-extension-template/actions/workflows/ci.yml/badge.svg)](https://github.com/knime/knime-python-extension-template/actions/workflows/ci.yml)
4+
[![Workflow Test](https://github.com/marc-lehner/knime-python-extension-template/actions/workflows/run_knime_workflow_test.yml/badge.svg)](https://github.com/marc-lehner/knime-python-extension-template/actions/workflows/run_knime_workflow_test.yml)
45

56
This repository is maintained by the [KNIME Team Rakete](mailto:team-rakete@knime.com).
67

0 commit comments

Comments
 (0)