Skip to content

Commit eb96784

Browse files
authored
[MOO-1887] Improve "Start runtime" and upgrade config (#293)
2 parents f90978d + 4df7b0d commit eb96784

63 files changed

Lines changed: 414 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Archive Test Results
2+
description: Archive runtime logs, screenshots, and artifacts from test runs
3+
inputs:
4+
platform:
5+
description: Platform (android or ios)
6+
required: true
7+
test-type:
8+
description: Test type (widget name or js-actions)
9+
required: true
10+
workspace-path:
11+
description: Workspace path for artifacts
12+
required: false
13+
default: ${{ github.workspace }}
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Archive runtime logs
19+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #v4
20+
if: always()
21+
with:
22+
name: ${{ inputs.platform }}-runtime-logs-${{ inputs.test-type }}
23+
path: log/*.log
24+
if-no-files-found: ignore
25+
26+
- name: Archive test screenshots
27+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #v4
28+
if: always()
29+
with:
30+
name: ${{ inputs.platform }}-screenshots-${{ inputs.test-type }}
31+
path: ${{ inputs.workspace-path }}/maestro/images/actual/${{ inputs.platform }}/**/*.png
32+
if-no-files-found: ignore
33+
34+
- name: Archive artifacts
35+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #v4
36+
if: always()
37+
with:
38+
name: ${{ inputs.platform }}-artifacts-${{ inputs.test-type }}
39+
path: packages/pluggableWidgets/**/artifacts/
40+
if-no-files-found: ignore
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Setup Maestro"
2+
description: "Install and cache Maestro"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Cache Maestro"
7+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
8+
with:
9+
path: $HOME/.local/bin/maestro
10+
key: maestro-${{ runner.os }}-v1
11+
12+
- name: "Install Maestro"
13+
shell: bash
14+
run: |
15+
if [ ! -f "$HOME/.local/bin/maestro/bin/maestro" ]; then
16+
mkdir -p $HOME/.local/bin
17+
curl -L "https://github.com/mobile-dev-inc/maestro/releases/latest/download/maestro.zip" -o maestro.zip
18+
unzip maestro.zip -d $HOME/.local/bin
19+
chmod +x $HOME/.local/bin/maestro/bin/maestro
20+
fi
21+
echo "$HOME/.local/bin" >> $GITHUB_PATH
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Setup Node with Cached Dependencies'
2+
description: 'Set up Node.js and install dependencies with caching'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: "Set up node"
7+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
8+
with:
9+
node-version-file: .nvmrc
10+
11+
- name: "Setup pnpm"
12+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
13+
- name: "Get pnpm store directory"
14+
id: pnpm-cache
15+
shell: bash
16+
run: |
17+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
18+
- name: "Setup cache"
19+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
20+
with:
21+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
22+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
23+
restore-keys: |
24+
${{ runner.os }}-pnpm-store-
25+
26+
- name: "Install dependencies"
27+
run: pnpm install --frozen-lockfile
28+
shell: bash
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "Setup Python Common"
2+
description: "Setup Python and install dependencies"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
7+
with:
8+
python-version: '3.12'
9+
- run: pip install PyYAML httplib2
10+
shell: bash
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Setup Tools"
2+
description: "Common setup for widget and js test jobs"
3+
inputs:
4+
mendix_version:
5+
description: "Mendix version"
6+
required: true
7+
outputs:
8+
java-path:
9+
description: "Path to the installed Java"
10+
value: ${{ steps.setup-java.outputs.path }}
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: "Setup Python and dependencies"
15+
uses: ./.github/actions/setup-python
16+
17+
- name: "Setup Node and dependencies"
18+
uses: ./.github/actions/setup-node-with-cache
19+
20+
- name: "Setup Java 21"
21+
id: setup-java
22+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 #v4
23+
with:
24+
distribution: "temurin"
25+
java-version: "21"
26+
27+
- name: "Cache Mendix runtime"
28+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
29+
with:
30+
path: tmp/runtime.tar.gz
31+
key: mendix-runtime-${{ inputs.mendix_version }}
32+
33+
- name: "Cache m2ee-tools"
34+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
35+
with:
36+
path: tmp/m2ee
37+
key: m2ee-tools-v1
38+
39+
- name: "Install Maestro"
40+
uses: ./.github/actions/setup-maestro
41+
42+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Setup Xcode CLI Tools"
2+
description: "Ensure Xcode CLI tools are configured"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Verify and set Xcode CLI tools"
7+
shell: bash
8+
run: |
9+
if ! xcode-select --print-path; then
10+
echo "Xcode CLI tools not set. Setting them now."
11+
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
12+
else
13+
echo "Xcode CLI tools are already configured."
14+
fi

.github/actions/start-runtime/action.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Download Artifact from Specific Run"
2+
description: "Download an artifact from a specific workflow run using GitHub CLI"
3+
inputs:
4+
artifact_name:
5+
description: "Name of the artifact to download"
6+
required: true
7+
run_id:
8+
description: "Workflow run ID"
9+
required: true
10+
output_dir:
11+
description: "Directory to extract the artifact"
12+
required: true
13+
platform:
14+
description: "Platform (android or ios)"
15+
required: true
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: "Install GitHub CLI"
20+
shell: bash
21+
run: |
22+
if ! command -v gh &> /dev/null; then
23+
if [[ "$RUNNER_OS" == "Linux" ]]; then
24+
sudo apt update
25+
sudo apt install -y gh
26+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
27+
brew install gh
28+
fi
29+
fi
30+
- name: "Authenticate GitHub CLI"
31+
shell: bash
32+
run: |
33+
unset GITHUB_TOKEN
34+
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
35+
- name: "Fetch artifact URL"
36+
id: fetch-artifacts
37+
shell: bash
38+
run: |
39+
url=$(gh api "repos/${{ github.repository }}/actions/runs/${{ inputs.run_id }}/artifacts" --jq '.artifacts[] | select(.name == "${{ inputs.artifact_name }}") | .archive_download_url')
40+
echo "artifacts_url=$url" >> $GITHUB_ENV
41+
- name: "Download and extract artifact"
42+
if: env.artifacts_url != ''
43+
shell: bash
44+
run: |
45+
curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -o ${{ inputs.platform }}-app.zip "$artifacts_url"
46+
unzip ${{ inputs.platform }}-app.zip -d ${{ inputs.output_dir }}

.github/scripts/setup-runtime.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ sed -i -- "s=\$ROOT_PATH=$WORKSPACE=g" project/m2ee-native.yml
1515
sed -i -- "s=\$JAVA_HOME=$JAVA_PATH=g" project/m2ee-native.yml
1616

1717
mkdir -p var/log var/opt/m2ee var/run bin tmp
18-
git clone https://github.com/KevinVlaanderen/m2ee-tools.git tmp/m2ee
18+
# Clone m2ee-tools only if not cached
19+
if [ ! -d tmp/m2ee ]; then
20+
git clone https://github.com/KevinVlaanderen/m2ee-tools.git tmp/m2ee
21+
fi
1922
mv tmp/m2ee/src/* var/opt/m2ee
2023
chmod a=rwx var/log/ var/run/
2124
echo "#!/bin/bash -x" > bin/m2ee
2225
echo "python3 var/opt/m2ee/m2ee.py \$@" >>bin/m2ee
2326
chmod +x bin/m2ee
2427

28+
# Download only if not cached
2529
mkdir -p "$WORKSPACE/project/runtimes" "$WORKSPACE/project/data/model-upload" "$WORKSPACE/project/data/database" "$WORKSPACE/project/data/files" "$WORKSPACE/project/data/tmp"
26-
wget -q "https://cdn.mendix.com/runtime/mendix-$MENDIX_VERSION.tar.gz" -O tmp/runtime.tar.gz
27-
tar xfz tmp/runtime.tar.gz --directory "$WORKSPACE/project/runtimes"
28-
rm tmp/runtime.tar.gz
30+
if [ ! -f tmp/runtime.tar.gz ]; then
31+
wget -q "https://cdn.mendix.com/runtime/mendix-$MENDIX_VERSION.tar.gz" -O tmp/runtime.tar.gz
32+
fi
33+
tar xfz tmp/runtime.tar.gz --directory "$WORKSPACE/project/runtimes"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Arguments
5+
MDA_FILE="$1"
6+
MENDIX_VERSION="$2"
7+
JAVA_PATH="$3"
8+
WORKSPACE="$4"
9+
10+
# Ensure setup script is executable
11+
chmod +x .github/scripts/setup-runtime.sh
12+
13+
# Run setup
14+
.github/scripts/setup-runtime.sh "$MDA_FILE" "$MENDIX_VERSION" "$JAVA_PATH" "$WORKSPACE"
15+
16+
# Stop any running Mendix runtime before starting a new one
17+
if bin/m2ee -c "$WORKSPACE/project/m2ee-native.yml" status | grep -q "running"; then
18+
echo "Stopping previous Mendix runtime..."
19+
bin/m2ee -c "$WORKSPACE/project/m2ee-native.yml" stop
20+
sleep 10
21+
fi
22+
23+
# Start runtime
24+
START_OUTPUT=$(bin/m2ee -c "$WORKSPACE/project/m2ee-native.yml" --verbose --yolo start 2>&1)
25+
echo "Full output from start command:"
26+
echo "$START_OUTPUT"
27+
if [ $? -eq 0 ]; then
28+
echo "Runtime started successfully (exit code)."
29+
exit 0
30+
fi
31+
32+
echo "Runtime did not start successfully."
33+
exit 1

0 commit comments

Comments
 (0)