Skip to content

Commit ae65935

Browse files
authored
Make tests and infrastructure less flaky (#273)
2 parents 8efa87e + 4929b4e commit ae65935

File tree

68 files changed

+209
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+209
-94
lines changed

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

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,38 @@ runs:
1414
uses: actions/[email protected]
1515
with:
1616
python-version: "3.x"
17+
1718
- name: "Install Python dependencies"
1819
run: pip install pyaml httplib2
1920
shell: bash
21+
2022
- name: "Setup Java 21"
2123
id: setup-java
2224
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 #v4
2325
with:
2426
distribution: "temurin"
2527
java-version: "21"
26-
- name: "Extract deployment package"
27-
run: |
28-
mkdir project
29-
unzip -qq ${{ inputs.mda-file }} -d project
30-
cp configs/e2e/m2ee-native.yml project/m2ee-native.yml
31-
sed -i -- 's=$ROOT_PATH=${{ github.workspace }}=g' project/m2ee-native.yml
32-
sed -i -- 's=$JAVA_HOME=${{ steps.setup-java.outputs.path }}=g' project/m2ee-native.yml
28+
29+
- name: "Make setup-runtime.sh executable"
30+
run: chmod +x .github/scripts/setup-runtime.sh
3331
shell: bash
34-
- name: "Setup m2ee"
32+
33+
- name: "Initial setup"
3534
run: |
36-
mkdir -p var/log var/opt/m2ee var/run bin tmp
37-
git clone https://github.com/KevinVlaanderen/m2ee-tools.git tmp/m2ee
38-
mv tmp/m2ee/src/* var/opt/m2ee
39-
chmod a=rwx var/log/ var/run/
40-
echo "#!/bin/bash -x" > bin/m2ee
41-
echo "python3 var/opt/m2ee/m2ee.py \$@" >>bin/m2ee
42-
chmod +x bin/m2ee
35+
.github/scripts/setup-runtime.sh "${{ inputs.mda-file }}" "${{ inputs.mendix-version }}" "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
4336
shell: bash
44-
- name: "Setup mxruntime"
37+
38+
- name: "Start mxruntime with retries"
4539
run: |
46-
mkdir -p ${{ github.workspace }}/project/runtimes ${{ github.workspace }}/project/data/model-upload ${{ github.workspace }}/project/data/database ${{ github.workspace }}/project/data/files ${{ github.workspace }}/project/data/tmp
47-
wget -q https://cdn.mendix.com/runtime/mendix-${{ inputs.mendix-version }}.tar.gz -O tmp/runtime.tar.gz
48-
tar xfz tmp/runtime.tar.gz --directory ${{ github.workspace }}/project/runtimes
49-
rm tmp/runtime.tar.gz
50-
shell: bash
51-
- name: "Start mxruntime"
52-
run: bin/m2ee -c ${{ github.workspace }}/project/m2ee-native.yml --verbose --yolo start
53-
shell: bash
40+
MAX_RETRIES=3
41+
RETRY=0
42+
until bin/m2ee -c ${{ github.workspace }}/project/m2ee-native.yml --verbose --yolo start; do
43+
RETRY=$((RETRY+1))
44+
if [ $RETRY -ge $MAX_RETRIES ]; then
45+
echo "mxruntime failed after $MAX_RETRIES attempts."
46+
exit 1
47+
fi
48+
echo "mxruntime failed, retrying ($RETRY/$MAX_RETRIES)..."
49+
.github/scripts/setup-runtime.sh "${{ inputs.mda-file }}" "${{ inputs.mendix-version }}" "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
50+
done
51+
shell: bash

.github/scripts/determine-nt-version.py

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,51 +37,48 @@
3737
if best_match:
3838
print(f"Best matching range: {best_match}")
3939

40-
# Get the major version to look for in tags
40+
# Get the major version to look for in releases
4141
max_pattern = version_data[best_match].get("max", "")
42-
major_version = max_pattern.split('.')[0]
43-
44-
print(f"Looking for latest version with major version: {major_version}")
42+
if max_pattern == "*":
43+
major_version = None
44+
print("Looking for latest available release (no major version restriction)")
45+
else:
46+
major_version = max_pattern.split('.')[0]
47+
print(f"Looking for latest release with major version: {major_version}")
4548

46-
# Get available tags from native-template repository
47-
response = requests.get('https://api.github.com/repos/mendix/native-template/tags')
49+
# Get available releases from native-template repository
50+
response = requests.get('https://api.github.com/repos/mendix/native-template/releases')
4851
if response.status_code == 200:
49-
all_tags = response.json()
50-
tag_names = [tag['name'] for tag in all_tags]
51-
print(f"Available tags: {tag_names}")
52+
all_releases = response.json()
53+
release_names = [release['tag_name'] for release in all_releases]
54+
print(f"Available releases: {release_names}")
5255

53-
# Find the latest version matching the major version
54-
matching_tags = []
56+
# Find the latest release matching the major version
57+
matching_releases = []
5558

56-
for tag in tag_names:
57-
# Remove 'v' prefix if present for comparison
59+
for release in all_releases:
60+
tag = release['tag_name']
5861
clean_tag = tag[1:] if tag.startswith('v') else tag
59-
60-
# Check if the tag starts with the major version
61-
if clean_tag.startswith(f"{major_version}."):
62-
try:
63-
# Try to parse as a version (this handles proper version numbers)
64-
tag_version = version.parse(clean_tag)
65-
matching_tags.append((tag, tag_version))
66-
except:
67-
# Skip tags that don't parse as proper versions
68-
pass
62+
try:
63+
tag_version = version.parse(clean_tag)
64+
if major_version is None or clean_tag.startswith(f"{major_version}."):
65+
matching_releases.append((tag, tag_version))
66+
except:
67+
pass
6968

70-
if matching_tags:
71-
# Sort by version (highest last) and get the last one
72-
matching_tags.sort(key=lambda x: x[1])
73-
latest_version = matching_tags[-1][0]
74-
print(f"Selected Native Template version: {latest_version}")
69+
if matching_releases:
70+
matching_releases.sort(key=lambda x: x[1])
71+
latest_tag = matching_releases[-1][0]
72+
print(f"Selected Native Template release: {latest_tag}")
7573
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
76-
f.write(f"nt_branch={latest_version}\n")
74+
f.write(f"nt_branch={latest_tag}\n")
7775
else:
78-
# Fallback to min version if no matching tag found
7976
min_version = version_data[best_match].get("min", "")
80-
print(f"No matching tag found, using minimum version: {min_version}")
77+
print(f"No matching release found, using minimum version: {min_version}")
8178
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
8279
f.write(f"nt_branch={min_version}\n")
8380
else:
84-
print(f"Failed to get tags: {response.status_code}")
81+
print(f"Failed to get releases: {response.status_code}")
8582
print("Using master as fallback")
8683
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
8784
f.write("nt_branch=master\n")

.github/scripts/setup-runtime.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
MDA_FILE="$1"
5+
MENDIX_VERSION="$2"
6+
JAVA_PATH="$3"
7+
WORKSPACE="$4"
8+
9+
rm -rf project var tmp bin
10+
11+
mkdir project
12+
unzip -qq "$MDA_FILE" -d project
13+
cp configs/e2e/m2ee-native.yml project/m2ee-native.yml
14+
sed -i -- "s=\$ROOT_PATH=$WORKSPACE=g" project/m2ee-native.yml
15+
sed -i -- "s=\$JAVA_HOME=$JAVA_PATH=g" project/m2ee-native.yml
16+
17+
mkdir -p var/log var/opt/m2ee var/run bin tmp
18+
git clone https://github.com/KevinVlaanderen/m2ee-tools.git tmp/m2ee
19+
mv tmp/m2ee/src/* var/opt/m2ee
20+
chmod a=rwx var/log/ var/run/
21+
echo "#!/bin/bash -x" > bin/m2ee
22+
echo "python3 var/opt/m2ee/m2ee.py \$@" >>bin/m2ee
23+
chmod +x bin/m2ee
24+
25+
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

.github/workflows/NativePipeline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ jobs:
439439
android-tests:
440440
needs: [scope, mendix-version, project, android-app]
441441
runs-on: ubuntu-22.04
442+
timeout-minutes: 60
442443
strategy:
443444
matrix:
444445
widget: ${{ fromJson(needs.scope.outputs.widgets) }}
@@ -557,6 +558,7 @@ jobs:
557558
ios-tests:
558559
needs: [scope, mendix-version, project, ios-app]
559560
runs-on: macos-15
561+
timeout-minutes: 60
560562
strategy:
561563
matrix:
562564
widget: ${{ fromJson(needs.scope.outputs.widgets) }}

configs/e2e/mendix-versions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"latest": "10.22.0.68245",
3-
"8": "8.18.23.62193"
2+
"latest": "10.24.0.73019"
43
}

maestro/helpers/compare_screenshots.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ fs.readdirSync(actualDir).forEach(file => {
5757
];
5858
} else if (platform === 'android') {
5959
ignoredAreas = [
60-
{ x: 0, y: 0, width, height: 50 } // Ignore top 40 pixels on Android
60+
{ x: 0, y: 0, width, height: 50 }, // Ignore top 50 pixels on Android
61+
{ x: width - 15, y: 0, width: 15, height } // Ignore right 15 pixels on Android
6162
];
6263
}
6364

0 commit comments

Comments
 (0)