Skip to content

Commit 9498b8e

Browse files
committed
Add caching into 'Start runtime'
1 parent 001a493 commit 9498b8e

4 files changed

Lines changed: 186 additions & 117 deletions

File tree

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

Lines changed: 0 additions & 51 deletions
This file was deleted.

.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

.github/workflows/NativePipeline.yml

Lines changed: 144 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,38 @@ jobs:
514514
with:
515515
name: android-app
516516
path: android-app
517-
518-
- name: "Start runtime"
519-
uses: ./.github/actions/start-runtime
517+
- name: "Setup Python"
518+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
519+
with:
520+
python-version: '3.x'
521+
cache: 'pip'
522+
- name: "Install Python dependencies"
523+
run: pip install PyYAML httplib2
524+
- name: "Cache Mendix runtime"
525+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
526+
with:
527+
path: tmp/runtime.tar.gz
528+
key: mendix-runtime-${{ needs.mendix-version.outputs.mendix_version }}
529+
- name: "Cache m2ee-tools"
530+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
531+
with:
532+
path: tmp/m2ee
533+
key: m2ee-tools-v1
534+
- name: "Setup Java 21"
535+
id: setup-java
536+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 #v4
520537
with:
521-
mda-file: automation.mda
522-
mendix-version: ${{ needs.mendix-version.outputs.mendix_version }}
538+
distribution: "temurin"
539+
java-version: "21"
540+
541+
- name: "Start runtime with retry"
542+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
543+
with:
544+
timeout_minutes: 10
545+
max_attempts: 3
546+
command: |
547+
chmod +x .github/scripts/start-runtime-with-verification.sh
548+
.github/scripts/start-runtime-with-verification.sh automation.mda ${{ needs.mendix-version.outputs.mendix_version }} "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
523549
524550
- name: "Install Maestro"
525551
uses: ./.github/actions/setup-maestro
@@ -618,11 +644,42 @@ jobs:
618644
# curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -o ios-app.zip "$artifacts_url"
619645
# unzip ios-app.zip -d ios-app
620646

621-
- name: "Start runtime"
622-
uses: ./.github/actions/start-runtime
647+
- name: "Setup Python and dependencies"
648+
run: |
649+
sudo apt-get update
650+
sudo apt-get install -y python3 python3-pip
651+
pip3 install PyYAML httplib2
652+
653+
- name: "Cache Mendix runtime"
654+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
655+
with:
656+
path: tmp/runtime.tar.gz
657+
key: mendix-runtime-${{ needs.mendix-version.outputs.mendix_version }}
658+
- name: "Cache m2ee-tools"
659+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
660+
with:
661+
path: tmp/m2ee
662+
key: m2ee-tools-v1
663+
- name: "Cache pip"
664+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
665+
with:
666+
path: ~/.cache/pip
667+
key: ${{ runner.os }}-pip-pyaml-httplib2
668+
- name: "Setup Java 21"
669+
id: setup-java
670+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 #v4
623671
with:
624-
mda-file: automation.mda
625-
mendix-version: ${{ needs.mendix-version.outputs.mendix_version }}
672+
distribution: "temurin"
673+
java-version: "21"
674+
675+
- name: "Start runtime with retry"
676+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
677+
with:
678+
timeout_minutes: 10
679+
max_attempts: 3
680+
command: |
681+
chmod +x .github/scripts/start-runtime-with-verification.sh
682+
.github/scripts/start-runtime-with-verification.sh automation.mda ${{ needs.mendix-version.outputs.mendix_version }} "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
626683
627684
- name: "Download iOS app"
628685
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
@@ -631,7 +688,6 @@ jobs:
631688
path: ios-app
632689
- name: "Setup Xcode CLI Tools"
633690
uses: ./.github/actions/setup-xcode-cli-tools
634-
635691
- name: "Install Maestro"
636692
uses: ./.github/actions/setup-maestro
637693
- name: "Verify maestro"
@@ -676,13 +732,8 @@ jobs:
676732
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
677733
with:
678734
fetch-depth: 0
679-
- name: "Set up node"
680-
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
681-
with:
682-
node-version-file: .nvmrc
683-
cache: yarn
684-
- name: "Install dependencies"
685-
run: yarn install --immutable
735+
- name: "Setup Node and dependencies"
736+
uses: ./.github/actions/setup-node-with-cache
686737
- name: "Download project MDA file"
687738
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
688739
with:
@@ -692,26 +743,46 @@ jobs:
692743
with:
693744
name: android-app
694745
path: android-app
746+
- name: "Setup Python and dependencies"
747+
run: |
748+
sudo apt-get update
749+
sudo apt-get install -y python3 python3-pip
750+
pip3 install PyYAML httplib2
751+
752+
- name: "Cache Mendix runtime"
753+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
754+
with:
755+
path: tmp/runtime.tar.gz
756+
key: mendix-runtime-${{ needs.mendix-version.outputs.mendix_version }}
757+
- name: "Cache m2ee-tools"
758+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
759+
with:
760+
path: tmp/m2ee
761+
key: m2ee-tools-v1
762+
- name: "Cache pip"
763+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
764+
with:
765+
path: ~/.cache/pip
766+
key: ${{ runner.os }}-pip-pyaml-httplib2
767+
- name: "Setup Java 21"
768+
id: setup-java
769+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 #v4
770+
with:
771+
distribution: "temurin"
772+
java-version: "21"
695773
- name: "Start runtime with retry"
696-
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08
774+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
697775
with:
698776
timeout_minutes: 10
699777
max_attempts: 3
700778
command: |
701-
.github/scripts/setup-runtime.sh "${{ inputs.mda-file }}" "${{ inputs.mendix-version }}" "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
702-
# Then verify
703-
grep "The MxRuntime is fully started now." var/opt/m2ee/m2ee.log
779+
chmod +x .github/scripts/start-runtime-with-verification.sh
780+
.github/scripts/start-runtime-with-verification.sh automation.mda ${{ needs.mendix-version.outputs.mendix_version }} "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
781+
704782
- name: "Install Maestro"
705-
run: |
706-
mkdir -p $HOME/.local/bin
707-
curl -L "https://github.com/mobile-dev-inc/maestro/releases/latest/download/maestro.zip" -o maestro.zip
708-
unzip maestro.zip -d $HOME/.local/bin
709-
chmod +x $HOME/.local/bin/maestro/bin/maestro
710-
echo "$HOME/.local/bin" >> $GITHUB_PATH
783+
uses: ./.github/actions/setup-maestro
711784
- name: Verify maestro
712785
run: $HOME/.local/bin/maestro/bin/maestro --version
713-
- name: Set up Android SDK
714-
run: echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
715786
- name: Enable KVM
716787
run: |
717788
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
@@ -764,24 +835,55 @@ jobs:
764835
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
765836
with:
766837
fetch-depth: 0
767-
- name: "Set up node"
768-
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
769-
with:
770-
node-version-file: .nvmrc
771-
cache: yarn
772-
- name: "Install dependencies"
773-
run: |
774-
yarn cache clean
775-
yarn install --immutable
838+
- name: "Setup Node and dependencies"
839+
uses: ./.github/actions/setup-node-with-cache
776840
- name: "Download project MDA file"
777841
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
778842
with:
779843
name: mda
780-
- name: "Start runtime"
781-
uses: ./.github/actions/start-runtime
844+
- name: "Setup Python and dependencies"
845+
run: |
846+
sudo apt-get update
847+
sudo apt-get install -y python3 python3-pip
848+
pip3 install PyYAML httplib2
849+
850+
- name: "Cache Mendix runtime"
851+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
852+
with:
853+
path: tmp/runtime.tar.gz
854+
key: mendix-runtime-${{ needs.mendix-version.outputs.mendix_version }}
855+
- name: "Cache m2ee-tools"
856+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
857+
with:
858+
path: tmp/m2ee
859+
key: m2ee-tools-v1
860+
- name: "Cache pip"
861+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4
862+
with:
863+
path: ~/.cache/pip
864+
key: ${{ runner.os }}-pip-pyaml-httplib2
865+
- name: "Setup Java 21"
866+
id: setup-java
867+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 #v4
782868
with:
783-
mda-file: automation.mda
784-
mendix-version: ${{ needs.mendix-version.outputs.mendix_version }}
869+
distribution: "temurin"
870+
java-version: "21"
871+
872+
- name: "Start runtime with retry"
873+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
874+
with:
875+
timeout_minutes: 10
876+
max_attempts: 3
877+
command: |
878+
chmod +x .github/scripts/start-runtime-with-verification.sh
879+
.github/scripts/start-runtime-with-verification.sh automation.mda ${{ needs.mendix-version.outputs.mendix_version }} "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
880+
881+
- name: "Setup Xcode CLI Tools"
882+
uses: ./.github/actions/setup-xcode-cli-tools
883+
- name: "Install Maestro"
884+
uses: ./.github/actions/setup-maestro
885+
- name: Verify maestro
886+
run: $HOME/.local/bin/maestro/bin/maestro --version
785887

786888
- name: "Download iOS app"
787889
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
@@ -790,26 +892,6 @@ jobs:
790892
path: ios-app
791893
- name: Check iOS App Path
792894
run: ls ios-app
793-
794-
- name: "Verify Xcode CLI Tools"
795-
run: |
796-
if ! xcode-select --print-path; then
797-
echo "Xcode CLI tools not set. Setting them now."
798-
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
799-
else
800-
echo "Xcode CLI tools are already configured."
801-
fi
802-
- name: "Install Maestro"
803-
run: |
804-
mkdir -p $HOME/.local/bin
805-
curl -L "https://github.com/mobile-dev-inc/maestro/releases/latest/download/maestro.zip" -o maestro.zip
806-
unzip maestro.zip -d $HOME/.local/bin
807-
chmod +x $HOME/.local/bin/maestro/bin/maestro
808-
echo "$HOME/.local/bin" >> $GITHUB_PATH
809-
- name: "Verify maestro"
810-
run: $HOME/.local/bin/maestro/bin/maestro --version
811-
- name: "List Available Simulators"
812-
run: xcrun simctl list devices
813895
- name: "Run iOS tests"
814896
run: |
815897
chmod +x maestro/helpers/prepare_ios.sh

0 commit comments

Comments
 (0)