Repository navigation
1300 lines (1271 loc) · 64.6 KB
/
Copy pathNativePipeline.yml
File metadata and controls
1300 lines (1271 loc) · 64.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Run Native Pipeline
on:
workflow_dispatch:
inputs:
run_name:
description: "Provide a name for the run"
required: false
default: ""
mendix_version:
description: "Provide the SP version to be used (e.g., 10.14.0.43709) - has to be a released version (Default: latest from Mendix versions.json)"
required: false
default: ""
nt_branch:
description: "Native Template branch/tag to use (Leave empty to auto-select based on Mendix version)"
default: ""
required: false
type: string
test_project_ref:
description: "mendix/Native-Mobile-Resources ref (commit SHA) to build against (leave empty for the pinned default)"
default: ""
required: false
type: string
LOCAL_TEST_ARTIFACT_RUN_ID:
description: "Workflow run ID for local artifact download (leave empty for normal CI). Use the full run ID from the URL, not the run number displayed in UI."
required: false
default: ""
update_baselines:
description: "Capture new screenshot baselines instead of asserting. Tests still run (to produce screenshots) but visual mismatches won't fail the run; download the *-screenshots-* artifacts and commit them under maestro/images/expected/."
required: false
default: false
type: boolean
workspace:
description: "Select a widget to test (Default will run all)"
required: true
default: "*-native"
type: choice
# NOTE: This list must be kept in sync with packages/pluggableWidgets/*-native folders
# The determine-widget-scope.sh script automatically discovers widgets, but GitHub Actions
# doesn't support dynamic dropdown options, so this list must be updated manually when
# adding or removing widgets.
options:
- "*-native"
- js-actions
- accordion-native
- activity-indicator-native
- animation-native
- app-events-native
- background-gradient-native
- background-image-native
- badge-native
- bar-chart-native
- barcode-scanner-native
- bottom-sheet-native
- carousel-native
- color-picker-native
- column-chart-native
- feedback-native
- floating-action-button-native
- gallery-native
- gallery-text-filter-native
- image-native
- intro-screen-native
- line-chart-native
- listview-swipe-native
- maps-native
- notifications-native
- pie-doughnut-chart-native
- popup-menu-native
- progress-bar-native
- progress-circle-native
- qr-code-native
- radio-buttons-native
- range-slider-native
- rating-native
- repeater-native
- safe-area-view-native
- signature-native
- slider-native
- switch-native
- toggle-buttons-native
- video-player-native
- web-view-native
# Trigger on PR
pull_request:
branches:
- main
- 'mx/**'
# Surface capture mode in the run title (workflow_dispatch inputs aren't shown in the UI),
# otherwise fall back to the provided run_name / default. inputs.update_baselines is the
# typed boolean from workflow_dispatch (null on pull_request).
run-name: ${{ inputs.update_baselines && '🔄 Capture screenshot baselines' || (github.event.inputs.run_name || 'Run Native Pipeline') }}
# Cancel superseded runs for the same PR/branch; a new push should not race an in-flight pipeline.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
LOCAL_TEST_ARTIFACT_RUN_ID: ${{ github.event.inputs.LOCAL_TEST_ARTIFACT_RUN_ID || '' }}
# Opt out of Maestro's anonymous analytics (avoids a network call, keeps runs deterministic).
MAESTRO_CLI_NO_ANALYTICS: "1"
# When "true" (set via the update_baselines dispatch input), the maestro run steps tolerate
# assertScreenshot failures so a capture run can produce fresh baselines without going red.
UPDATE_BASELINES: ${{ github.event.inputs.update_baselines || 'false' }}
# Pin the test project (mendix/Native-Mobile-Resources) to a SHA for reproducibility instead
# of tracking a moving `main`. Single source of truth — bump deliberately. The repo publishes
# no tags, so a commit SHA is the only stable ref. Override per run via the dispatch input.
NATIVE_MOBILE_RESOURCES_REF: ${{ github.event.inputs.test_project_ref || '599d5cba0ce4f45278bbaa67d912815d8f85a3b6' }}
permissions:
packages: write
jobs:
scope:
runs-on: ubuntu-26.04
outputs:
scope: ${{ steps.scope.outputs.scope }}
widgets: ${{ steps.scope.outputs.widgets }}
widgets_to_test: ${{ steps.scope.outputs.widgets_to_test }}
js_actions_changed: ${{ steps.scope.outputs.js_actions_changed }}
full_build: ${{ steps.scope.outputs.full_build }}
steps:
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Full history so the scope script can diff against the PR base merge-base
# (covers every commit in the PR, not just the latest).
fetch-depth: 0
- name: "Determine scope"
id: scope
# Pass the PR base SHA (empty on non-PR events → the script's dispatch path handles it).
run: |
chmod +x ./.github/scripts/determine-widget-scope.sh
./.github/scripts/determine-widget-scope.sh "${{ github.event_name }}" "${{ github.event.inputs.workspace }}" "${{ github.event.pull_request.base.sha || github.event.before }}" "${{ github.sha }}"
- name: "Debug Scope Output"
run: |
echo "Scope is: ${{ steps.scope.outputs.scope }}"
echo "Widgets to build: ${{ steps.scope.outputs.widgets }}"
echo "Widgets to test: ${{ steps.scope.outputs.widgets_to_test }}"
echo "JS actions changed: ${{ steps.scope.outputs.js_actions_changed }}"
mendix-version:
runs-on: ubuntu-26.04
outputs:
mendix_version: ${{ steps.set-mendix-version.outputs.MENDIX_VERSION }}
steps:
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set Mendix version
id: set-mendix-version
run: |
if [[ -n "${{ github.event.inputs.mendix_version }}" ]]; then
echo "MENDIX_VERSION=${{ github.event.inputs.mendix_version }}" >> "$GITHUB_OUTPUT"
else
MENDIX_VERSION=$(jq -r '.latest' configs/e2e/mendix-versions.json)
echo "MENDIX_VERSION=$MENDIX_VERSION" >> "$GITHUB_OUTPUT"
fi
- name: "Debug Mendix Version"
run: |
echo "Mendix Version: ${{ steps.set-mendix-version.outputs.MENDIX_VERSION }}"
determine-nt-version:
needs: [mendix-version]
runs-on: ubuntu-26.04
outputs:
nt_branch: ${{ steps.set-output.outputs.nt_branch }}
steps:
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Check if nt_branch was specified"
id: check-input
run: |
if [[ -n "${{ github.event.inputs.nt_branch }}" ]]; then
echo "Using specified nt_branch: ${{ github.event.inputs.nt_branch }}"
echo "nt_branch=${{ github.event.inputs.nt_branch }}" >> "$GITHUB_OUTPUT"
echo "source=input" >> "$GITHUB_OUTPUT"
else
echo "No nt_branch specified, will determine from mendix_version"
echo "source=auto" >> "$GITHUB_OUTPUT"
fi
- name: "Download mendix_version.json from native-template repo"
if: steps.check-input.outputs.source == 'auto'
run: |
curl -s -o mendix_version.json https://raw.githubusercontent.com/mendix/native-template/master/mendix_version.json
cat mendix_version.json
- name: "Determine Native Template version based on Mendix version"
if: steps.check-input.outputs.source == 'auto'
id: determine-nt-branch
# Node (preinstalled on the runner) — no setup-python / pip; the script has no deps.
run: node ./.github/scripts/determine-nt-version.mjs "${{ needs.mendix-version.outputs.mendix_version }}"
- name: "Set output nt_branch"
id: set-output
run: |
if [[ "${{ steps.check-input.outputs.source }}" == "input" ]]; then
echo "nt_branch=${{ github.event.inputs.nt_branch }}" >> "$GITHUB_OUTPUT"
else
echo "nt_branch=${{ steps.determine-nt-branch.outputs.nt_branch }}" >> "$GITHUB_OUTPUT"
fi
- name: "Debug final branch output"
run: |
echo "Final nt_branch value: ${{ steps.set-output.outputs.nt_branch }}"
docker-images:
needs: [mendix-version]
runs-on: ubuntu-26.04
steps:
- name: "Login to GitHub Container Registry"
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Check if docker image already exists"
run: |
docker manifest inspect ghcr.io/${{ github.repository }}/mxbuild:${{ needs.mendix-version.outputs.mendix_version }} || EXIT_CODE=$?
echo "IMAGE_MISSING=$EXIT_CODE" >> "$GITHUB_ENV"
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: ${{ env.IMAGE_MISSING != 0 }}
- name: "Build mxbuild image"
if: ${{ env.IMAGE_MISSING != 0 }}
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
file: ./.github/scripts/mxbuild.Dockerfile
context: ./.github/scripts
build-args: |
MENDIX_VERSION=${{ needs.mendix-version.outputs.mendix_version }}
push: true
tags: ghcr.io/${{ github.repository }}/mxbuild:${{ needs.mendix-version.outputs.mendix_version }}
resources:
needs: [scope, mendix-version]
runs-on: ubuntu-26.04
permissions:
packages: read
contents: read
steps:
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: "Setup Node and dependencies (with pnpm store cache)"
uses: ./.github/actions/setup-node-with-cache
- name: "Restore built resources (dist) cache"
id: resources-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
# Built widget .mpk / JS-action dist are reproducible from source + toolchain, so
# key on widget/JS-action src + their package.json + the lockfile. An infra-only
# change (no src touched) keeps the same key → exact hit → skip the rebuild below.
path: |
packages/pluggableWidgets/*/dist
packages/jsActions/*/dist
key: resources-dist-v1-${{ hashFiles('packages/pluggableWidgets/*/src/**', 'packages/jsActions/*/src/**', 'packages/pluggableWidgets/*/package.json', 'packages/jsActions/*/package.json', 'pnpm-lock.yaml') }}
- name: "Build resources"
# On a full build with an exact cache hit every widget's dist is already current, so
# skip the slow rollup/babel rebuild. Otherwise build the scoped widgets + JS actions
# in one pnpm invocation (multiple --filter targets run concurrently).
run: |
if [ "${{ needs.scope.outputs.full_build }}" = "true" ] && [ "${{ steps.resources-cache.outputs.cache-hit }}" = "true" ]; then
echo "Full build with cached resources — skipping rebuild."
exit 0
fi
filters=()
if [ "${{ needs.scope.outputs.js_actions_changed }}" = "true" ] || \
[ "${{ github.event.inputs.workspace }}" = "js-actions" ] || \
[ "${{ github.event.inputs.workspace }}" = "*-native" ] || \
[ "${{ github.event_name }}" = "schedule" ]; then
filters+=(--filter=mobile-resources-native --filter=nanoflow-actions-native)
fi
while read -r w; do
[ -n "$w" ] && filters+=(--filter="$w")
done < <(echo '${{ needs.scope.outputs.widgets }}' | jq -r '.[]')
if [ ${#filters[@]} -gt 0 ]; then
echo "Building: ${filters[*]}"
pnpm "${filters[@]}" run build
else
echo "Nothing to build."
fi
- name: "Unit test"
# One --filter per workspace, exactly like "Build resources" above. Passing the whole
# `scope` string as a single filter (--filter="--all --include 'a b'") makes pnpm treat
# that entire string as ONE workspace pattern: it matches nothing, prints "No projects
# matched the filters" and exits 0 — so the unit tests silently never ran.
#
# Tests run for widgets_to_test, not `widgets`: a widget whose only change is under e2e/
# is deliberately not rebuilt but should still have its unit tests run.
run: |
filters=()
if [ "${{ needs.scope.outputs.js_actions_changed }}" = "true" ]; then
filters+=(--filter=mobile-resources-native --filter=nanoflow-actions-native)
fi
while read -r w; do
[ -n "$w" ] && filters+=(--filter="$w")
done < <(echo '${{ needs.scope.outputs.widgets_to_test }}' | jq -r '.[]')
if [ ${#filters[@]} -eq 0 ]; then
echo "No workspaces in scope — nothing to unit test."
exit 0
fi
echo "Unit testing: ${filters[*]}"
pnpm -r "${filters[@]}" run test
- name: "Save built resources (dist) cache"
# Only after a full build (every widget built), so a partial build never populates the
# shared cache with an incomplete dist set under a key a later full build could hit.
if: ${{ needs.scope.outputs.full_build == 'true' && steps.resources-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
packages/pluggableWidgets/*/dist
packages/jsActions/*/dist
key: ${{ steps.resources-cache.outputs.cache-primary-key }}
- name: "Write resources manifest"
# Guarantees the resources artifact always contains at least one file, so the
# download in the `project` job never fails. A widgets-PR whose only changes are
# under e2e/ builds nothing (those widgets test against the baseline project), which
# would otherwise leave the artifact empty → not created → project download error.
run: |
{
echo "built widgets: ${{ needs.scope.outputs.widgets }}"
echo "tested widgets: ${{ needs.scope.outputs.widgets_to_test }}"
echo "js_actions_changed: ${{ needs.scope.outputs.js_actions_changed }}"
echo "full_build: ${{ needs.scope.outputs.full_build }}"
} > resources-manifest.txt
- name: "Upload JS actions resources artifact"
if: ${{ github.event.inputs.workspace == 'js-actions' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7
with:
name: resources
path: |
resources-manifest.txt
packages/jsActions/mobile-resources-native/dist/**/*
packages/jsActions/nanoflow-actions-native/dist/**/*
- name: "Upload widget and JS actions resources artifact"
if: ${{ github.event.inputs.workspace != 'js-actions' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7
with:
name: resources
path: |
resources-manifest.txt
packages/pluggableWidgets/**/dist/*/*.mpk
packages/jsActions/mobile-resources-native/dist/**/*
packages/jsActions/nanoflow-actions-native/dist/**/*
project:
needs: [resources, mendix-version]
runs-on: ubuntu-26.04
container:
image: ghcr.io/${{ github.repository }}/mxbuild:${{ needs.mendix-version.outputs.mendix_version }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "Install curl and unzip"
run: |
apt update
apt install -y curl unzip
- name: "Download test project"
# Pinned to a SHA (NATIVE_MOBILE_RESOURCES_REF) for reproducible builds.
run: curl -L -o project.zip "https://github.com/mendix/Native-Mobile-Resources/archive/${NATIVE_MOBILE_RESOURCES_REF}.zip"
- name: "Extract test project"
# GitHub names the archive's top dir after the ref (Native-Mobile-Resources-<ref>);
# rename it back to the stable Native-Mobile-Resources-main that the rest of the job
# references, so pinning the ref doesn't ripple through every downstream path.
run: |
unzip -qq project.zip -d .
rm -rf Native-Mobile-Resources-main
mv "Native-Mobile-Resources-${NATIVE_MOBILE_RESOURCES_REF}" Native-Mobile-Resources-main
- name: "Download resources artifact"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: resources
path: resources
- name: "List resources"
run: ls -R resources
- name: "Overlay built widget mpks"
if: ${{ github.event.inputs.workspace != 'js-actions' }}
shell: bash
# Located by `find` rather than a fixed-depth glob: upload-artifact strips the least-common
# ancestor of the paths it is given, so the depth here follows whatever else is in the
# artifact. Adding resources-manifest.txt at the repo root moved that ancestor from
# packages/ to the root, every path gained a packages/ prefix, and the old
# 'resources/pluggableWidgets/**' glob silently stopped matching — so no built mpk was
# installed and the e2e suite tested the baseline project's widgets instead.
#
# And it is fatal rather than silent: a widget that was built but not installed makes the
# e2e run test something other than the commit under test, which is worse than not running.
run: |
set -uo pipefail
# A widget's dist/ can hold MORE THAN ONE version dir (e.g. image-native ships
# dist/3.1.1 and dist/3.1.2 after a version bump, since the widget build does not clear
# dist/ the way the jsActions rollup does). Every version emits an identically-named
# .mpk, so installing them in `find` order let an arbitrary — in practice the OLDEST —
# build win and the e2e suite silently tested stale widget code.
#
# Deduplicate on the mpk basename, keeping the highest version dir per widget: key on
# the filename, sort by the parent dir with -V (version sort, so 3.1.10 > 3.1.2), and
# keep the last of each group.
find resources -type f -path '*/dist/*/*.mpk' \
| awk -F/ '{ print $NF "\t" $(NF-1) "\t" $0 }' \
| sort -t"$(printf '\t')" -k1,1 -k2,2V \
| awk -F'\t' '{ best[$1] = $3 } END { for (n in best) print best[n] }' \
| sort > /tmp/mpks.txt
found=0
while IFS= read -r oldPath; do
[ -n "$oldPath" ] || continue
found=$((found + 1))
echo "installing $(basename "$oldPath") (from ${oldPath#resources/})"
mv -f "$oldPath" "Native-Mobile-Resources-main/widgets/$(basename "$oldPath")"
done < /tmp/mpks.txt
# The scope this job was given, read from the manifest rather than needs.scope: `project`
# does not depend on `scope`, so its outputs are not visible here. Compared as a string
# rather than parsed as JSON: the manifest line is written by echoing an interpolated
# expression, and the shell strips the inner quotes on the way in, so it reads
# [a, b] rather than ["a","b"].
built=$(sed -n 's/^built widgets: //p' resources/resources-manifest.txt)
echo "mpks installed: ${found}; widgets in scope: ${built:-unknown}"
# Count the widgets the resources job says it built, and require an .mpk for EVERY one.
# Checking only `found -eq 0` passed a multi-widget run in which just one widget's mpk
# made it through — the rest silently tested the baseline project's stale build, which
# is the same class of failure the zero-check exists to prevent.
expected=$(printf '%s' "$built" | tr -d '[]' | tr ',' '\n' | sed 's/^ *//; s/ *$//' | grep -c . || true)
if [ "${expected:-0}" -gt 0 ] && [ "$found" -lt "$expected" ]; then
echo "::error::Expected ${expected} built widget mpk(s) (${built}) but installed ${found} — the test project would run stale widgets."
echo "--- mpks found under resources/ ---"
cat /tmp/mpks.txt
echo "--- all files under resources/ ---"
find resources -type f | head -50
exit 1
fi
- name: "Register widgets in the test project"
# Run unconditionally: update-widgets must sync the project's widget definitions with the
# mpks in widgets/ regardless of whether THIS run overlaid fresh ones. Must NOT be nested
# in the mpk-move guard — a `js-actions` dispatch (or any run that builds no mpks) would
# then skip it and leave stale Atlas widget defs for the portable-app build.
shell: bash
run: mx update-widgets --loose-version-check Native-Mobile-Resources-main/NativeComponentsTestProject.mpr
# Same layout-independence as the mpk overlay above: locate the dist dir rather than assume
# its depth in the artifact. Each guard also checks its OWN source dir — nanoflow-actions
# previously tested mobile-resources-native, so it moved either both or neither.
#
# `cp -R <src>/.` rather than `mv <src>/*`: the destination in the test project already
# ships a populated node_modules/, and `mv` refuses to rename a directory over a non-empty
# one ("Directory not empty") instead of merging into it. cp recurses and merges, so the
# built files win per-file while packages the build treats as external (and therefore does
# not collect into dist/node_modules) survive in the project. The trailing /. copies the
# directory's contents including dotfiles, which <src>/* would miss.
- name: "Move mobile-resources"
shell: bash
run: |
src=$(find resources -type d -path '*/mobile-resources-native/dist' | head -1)
if [ -n "$src" ]; then
echo "installing mobile-resources from $src"
cp -Rf "$src"/. Native-Mobile-Resources-main/javascriptsource/nativemobileresources/actions/
fi
- name: "Move nanoflow-actions"
shell: bash
run: |
src=$(find resources -type d -path '*/nanoflow-actions-native/dist' | head -1)
if [ -n "$src" ]; then
echo "installing nanoflow-actions from $src"
cp -Rf "$src"/. Native-Mobile-Resources-main/javascriptsource/nanoflowcommons/actions/
fi
- name: "Build portable app package (self-contained runtime)"
# Run this BEFORE the native-packager deploy: portable-app-package re-prepares and
# CLEANS the project's deployment/ directory, which would wipe the native bundles.
# app.zip lives outside deployment/, so the later deploy's clean doesn't touch it.
# Output must live inside the project root: mxbuild's WhitelistAware path check
# rejects arbitrary output paths for the portable-app-package target.
run: |
mxbuild --target=portable-app-package \
-o Native-Mobile-Resources-main/app.zip \
--loose-version-check Native-Mobile-Resources-main/NativeComponentsTestProject.mpr
- name: "Build native bundles (deploy + native-packager)"
# Compiles the model and emits the Android/iOS JS bundles in native-template-ready
# layout at deployment/native/bundle/{android,iOS}. Supported replacement for the old
# create-native-bundle hack. Runs LAST so nothing cleans deployment/ afterward.
run: |
mxbuild --target=deploy --native-packager \
--loose-version-check Native-Mobile-Resources-main/NativeComponentsTestProject.mpr
echo "=== native bundle output ==="
ls -R Native-Mobile-Resources-main/deployment/native/bundle 2>/dev/null \
|| find Native-Mobile-Resources-main -name 'index.*.bundle' -o -name 'bundle' -type d 2>/dev/null
- name: "Upload Android bundle"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7
with:
name: android-bundle
path: Native-Mobile-Resources-main/deployment/native/bundle/android
if-no-files-found: error
- name: "Upload iOS bundle"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7
with:
name: ios-bundle
path: Native-Mobile-Resources-main/deployment/native/bundle/iOS
if-no-files-found: error
- name: "Upload portable app package"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7
with:
name: app-package
path: Native-Mobile-Resources-main/app.zip
android-app:
needs: [project, determine-nt-version]
runs-on: ubuntu-26.04
# Skip this job if we're using artifacts from a specific run; the native bundles now come
# from the project job (deploy + native-packager), so gate on project success.
if: ${{ github.event.inputs.LOCAL_TEST_ARTIFACT_RUN_ID == '' && !cancelled() && (needs.project.result == 'success') }}
steps:
- name: Debug branch value
run: echo "Using branch ${{ needs.determine-nt-version.outputs.nt_branch }}"
- name: "Check out Native Template for Native Components Test Project"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: mendix/native-template
ref: ${{ needs.determine-nt-version.outputs.nt_branch }}
path: native-template
- name: "Detect Android NDK version from native-template"
shell: bash
run: |
set -euo pipefail
# native-template declares e.g. ndkVersion = "27.3.13750724" in android/build.gradle
NDK=$(grep -oE 'ndkVersion[[:space:]]*=?[[:space:]]*"[0-9.]+"' native-template/android/build.gradle \
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true)
if [ -z "$NDK" ]; then
echo "::warning::Could not detect ndkVersion from native-template; gradle will resolve/download it."
else
echo "Detected NDK version: $NDK"
fi
echo "ANDROID_NDK_VERSION=$NDK" >> "$GITHUB_ENV"
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: native-widgets
- name: "Download Android bundle and assets"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: android-bundle
path: bundles/android
# Only the JS bundle can be swapped into a cached APK: aapt2 rewrites the artifact's res/
# density qualifiers into resources.arsc, so a resource change needs a full rebuild.
- name: "Resolve Android APK cache inputs"
shell: bash
run: |
set -euo pipefail
NT_SHA=$(git -C native-template rev-parse HEAD)
echo "NT_SHA=$NT_SHA" >> "$GITHUB_ENV"
SDK="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
BT_DIR=$(ls -1d "$SDK"/build-tools/* 2>/dev/null | sort -V | tail -1)
if [ -z "${BT_DIR:-}" ]; then
echo "::error::No Android build-tools found under $SDK; cannot align/sign a swapped APK."
exit 1
fi
echo "BUILD_TOOLS_DIR=$BT_DIR" >> "$GITHUB_ENV"
echo "BUILD_TOOLS_ID=$(basename "$BT_DIR")" >> "$GITHUB_ENV"
echo "native-template $NT_SHA, build-tools $(basename "$BT_DIR")"
- name: "Restore built Android APK"
id: android-apk-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: android-apk-cache
# No restore-keys: a partial-input change must rebuild. gradle autolinks from
# native_dependencies.json, so it belongs in the key.
key: android-apk-v1-${{ runner.os }}-${{ env.BUILD_TOOLS_ID }}-${{ env.NT_SHA }}-${{ hashFiles('native-template/package-lock.json', 'native-widgets/configs/e2e/native_dependencies.json', 'native-widgets/configs/e2e/config.json', 'native-widgets/configs/e2e/google-services.json', 'native-widgets/scripts/test/add-native-dependencies.js') }}
- name: "Verify restored Android APK"
shell: bash
run: |
set -euo pipefail
cached=false
apk="android-apk-cache/app-appstore-debug.apk"
test_apk="android-apk-cache/app-appstore-debug-androidTest.apk"
if [ "${{ steps.android-apk-cache.outputs.cache-hit }}" = "true" ] && [ -f "$apk" ]; then
if ! unzip -l "$apk" | grep -q 'assets/index.android.bundle$'; then
echo "::warning::APK cache hit but no assets/index.android.bundle inside; rebuilding."
elif [ ! -f "$test_apk" ]; then
echo "::warning::APK cache hit but the androidTest APK is missing; rebuilding."
else
# aapt2's -v4 density suffix means paths differ, so compare by CONTENT.
stale=""
while IFS= read -r f; do
rel=${f#bundles/android/}
name=$(basename "$f")
entry=$(unzip -l "$apk" | awk '{print $4}' \
| grep -E "^res/$(dirname "$rel" | sed 's|res/||')(-v[0-9]+)?/$name$" | head -1 || true)
if [ -z "$entry" ]; then stale="$stale $rel(absent)"; continue; fi
if ! cmp -s <(unzip -p "$apk" "$entry") "$f"; then stale="$stale $rel"; fi
done < <(find bundles/android/res -type f 2>/dev/null)
if [ -n "$stale" ]; then
echo "::warning::Bundle resources differ from the cached APK (${stale# }); rebuilding rather than swapping only the JS bundle."
else
cached=true
echo "APK_PATH=$apk" >> "$GITHUB_ENV"
echo "TEST_APK_PATH=$test_apk" >> "$GITHUB_ENV"
echo "Reusing cached APK: $apk"
fi
fi
else
echo "No usable Android APK cache; building."
fi
echo "ANDROID_APK_CACHED=$cached" >> "$GITHUB_ENV"
- name: "Set up Node"
if: env.ANDROID_APK_CACHED != 'true'
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: native-template/.nvmrc
cache: npm
cache-dependency-path: native-template/package-lock.json
- name: "Cache Android Build"
if: env.ANDROID_APK_CACHED != 'true'
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
native-template/android/app/build
!native-template/android/app/build/outputs
!native-template/android/app/build/intermediates
!native-template/android/app/build/tmp
!native-template/android/app/build/reports
key: ${{ runner.os }}-android-build-${{ hashFiles('native-template/android/app/src/**/*.java', 'native-template/android/app/src/**/*.kt', 'native-template/android/app/build.gradle') }}
restore-keys: |
${{ runner.os }}-android-build-
- name: "Copy files to the right location"
if: env.ANDROID_APK_CACHED != 'true'
run: |
# native-packager output is pre-split: bundle/android/{assets/index.android.bundle, res/...}
# maps directly onto app/src/main/{assets,res} (per the official manual-build doc).
mkdir -p native-template/android/app/src/main
cp -r bundles/android/* native-template/android/app/src/main/
mv native-widgets/configs/e2e/config.json native-template
mv native-widgets/configs/e2e/google-services.json native-template/android/app
node native-widgets/scripts/test/add-native-dependencies.js
- name: "Install dependencies"
if: env.ANDROID_APK_CACHED != 'true'
working-directory: native-template
run: npm i
- name: "Setup JDK "
if: env.ANDROID_APK_CACHED != 'true'
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #v5.2.0
with:
java-version: 21
distribution: temurin
cache: gradle
# Install the NDK explicitly and cache it (keyed on the version detected from
# native-template), instead of letting the gradle build download ~1GB every run.
# (${{ }} expressions are expanded by Actions, so they are safe in cache `path`
# — unlike shell $VARs.) If detection failed, these no-op and gradle resolves it.
- name: "Cache Android NDK"
id: cache-ndk
if: env.ANDROID_NDK_VERSION != '' && env.ANDROID_APK_CACHED != 'true'
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: /usr/local/lib/android/sdk/ndk/${{ env.ANDROID_NDK_VERSION }}
key: ${{ runner.os }}-android-ndk-${{ env.ANDROID_NDK_VERSION }}
- name: "Install Android NDK"
if: env.ANDROID_NDK_VERSION != '' && env.ANDROID_APK_CACHED != 'true' && steps.cache-ndk.outputs.cache-hit != 'true'
shell: bash
run: |
set -euo pipefail
SDK="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
SDKMANAGER="$SDK/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$(command -v sdkmanager || true)"
fi
if [ -z "${SDKMANAGER:-}" ] || [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$(find "$SDK" -type f -name sdkmanager 2>/dev/null | head -1)"
fi
echo "Using sdkmanager: $SDKMANAGER"
# Accept licenses first (yes can SIGPIPE under pipefail, so tolerate it), then install.
yes | "$SDKMANAGER" --licenses > /dev/null 2>&1 || true
"$SDKMANAGER" "ndk;${ANDROID_NDK_VERSION}"
- name: "Build Android app"
if: env.ANDROID_APK_CACHED != 'true'
working-directory: native-template/android
# The CI emulator is x86_64, so only compile that ABI's native code instead of all
# four (arm64-v8a, armeabi-v7a, x86, x86_64) — cuts the C/C++ build by ~75%.
#
# --build-cache turns on Gradle's local build cache (task-output content cache). It lives
# under ~/.gradle/caches/build-cache-1, already persisted by setup-java's `cache: gradle`,
# so unchanged tasks (incl. RN libs' native compiles, which don't change run-to-run) are
# reused instead of recompiled. Safe: a cache miss just rebuilds.
run: ./gradlew assembleAppstoreDebug assembleAppstoreDebugAndroidTest -PreactNativeArchitectures=x86_64 --build-cache
- name: "List APK files"
if: env.ANDROID_APK_CACHED != 'true'
run: |
echo "Listing APK files in the output directory:"
ls -R native-template/android/app/build/outputs/apk/
- name: "Stage the built APKs for caching"
if: env.ANDROID_APK_CACHED != 'true'
shell: bash
run: |
set -euo pipefail
out=native-template/android/app/build/outputs/apk
mkdir -p android-apk-cache
cp "$out/appstore/debug/app-appstore-debug.apk" android-apk-cache/
cp "$out/androidTest/appstore/debug/app-appstore-debug-androidTest.apk" android-apk-cache/
ls -l android-apk-cache
- name: "Save built Android APK"
if: env.ANDROID_APK_CACHED != 'true'
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: android-apk-cache
key: ${{ steps.android-apk-cache.outputs.cache-primary-key }}
- name: "Swap the JS bundle into the cached APK"
# -0 (store) is required — the bundle is Hermes bytecode mmapped out of the APK and
# `zip -u` would deflate it. Re-signing is required because the edit voids the signature.
if: env.ANDROID_APK_CACHED == 'true'
shell: bash
run: |
set -euo pipefail
test -f bundles/android/assets/index.android.bundle
KS="$HOME/.android/debug.keystore"
if [ ! -f "$KS" ]; then
mkdir -p "$HOME/.android"
keytool -genkeypair -keystore "$KS" -storepass android -keypass android \
-alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10950 \
-dname "C=US, O=Android, CN=Android Debug"
fi
before=$(unzip -v "$APK_PATH" | awk '/assets\/index.android.bundle$/ {print $2}')
rm -rf apk-swap && mkdir -p apk-swap/assets
cp bundles/android/assets/index.android.bundle apk-swap/assets/
( cd apk-swap && zip -q -X -0 -u "$OLDPWD/$APK_PATH" assets/index.android.bundle )
"$BUILD_TOOLS_DIR/zipalign" -p -f 4 "$APK_PATH" apk-swap/aligned.apk
"$BUILD_TOOLS_DIR/apksigner" sign --ks "$KS" --ks-pass pass:android \
--ks-key-alias androiddebugkey --key-pass pass:android apk-swap/aligned.apk
mv apk-swap/aligned.apk "$APK_PATH"
"$BUILD_TOOLS_DIR/apksigner" verify "$APK_PATH"
after=$(unzip -v "$APK_PATH" | awk '/assets\/index.android.bundle$/ {print $2}')
if [ "$after" != "Stored" ]; then
echo "::error::index.android.bundle is '$after', expected 'Stored' (was '$before'). Hermes bytecode must stay uncompressed."
exit 1
fi
cmp <(unzip -p "$APK_PATH" assets/index.android.bundle) bundles/android/assets/index.android.bundle
echo "Swapped JS bundle into $APK_PATH (Stored, signature verified)"
- name: "Collect APKs for upload"
shell: bash
run: |
set -euo pipefail
mkdir -p apk-out/appstore/debug apk-out/androidTest/appstore/debug
if [ "$ANDROID_APK_CACHED" = "true" ]; then
cp "$APK_PATH" apk-out/appstore/debug/app-appstore-debug.apk
cp "$TEST_APK_PATH" apk-out/androidTest/appstore/debug/app-appstore-debug-androidTest.apk
else
out=native-template/android/app/build/outputs/apk
cp "$out/appstore/debug/app-appstore-debug.apk" apk-out/appstore/debug/
cp "$out/androidTest/appstore/debug/app-appstore-debug-androidTest.apk" apk-out/androidTest/appstore/debug/
fi
find apk-out -name '*.apk' -exec ls -l {} +
- name: "Archive Android app"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7
with:
name: android-app
path: apk-out/**/*.apk
if-no-files-found: error
ios-app:
needs: [project, determine-nt-version]
runs-on: macos-26
# Skip this job if we're using artifacts from a specific run; the native bundles now come
# from the project job (deploy + native-packager), so gate on project success.
if: ${{ github.event.inputs.LOCAL_TEST_ARTIFACT_RUN_ID == '' && !cancelled() && (needs.project.result == 'success') }}
steps:
- name: "Check out Native Template for Native Components Test Project"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: mendix/native-template
ref: ${{ needs.determine-nt-version.outputs.nt_branch }}
path: native-template
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: native-widgets
- name: "Download iOS bundle and assets"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ios-bundle
path: bundles/ios
# `Bundle` is a folder reference resolved at launch by getJSBundleFile(), not compiled in,
# so a widget-only change can reuse the cached .app with that folder swapped.
- name: "Resolve iOS app cache inputs"
shell: bash
run: |
set -euo pipefail
NT_SHA=$(git -C native-template rev-parse HEAD)
echo "NT_SHA=$NT_SHA" >> "$GITHUB_ENV"
echo "XCODE_ID=$(xcodebuild -version | tr '\n' '-' | tr -d ' ')" >> "$GITHUB_ENV"
echo "native-template $NT_SHA"
- name: "Restore built iOS app"
id: ios-app-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: native-template/ios/build/Build/Products
# No restore-keys: `pod install` regenerates Podfile.lock from native_dependencies.json,
# so the lock alone is not enough.
key: ios-app-v1-${{ runner.os }}-${{ env.XCODE_ID }}-${{ env.NT_SHA }}-${{ hashFiles('native-template/package-lock.json', 'native-template/ios/Podfile', 'native-template/ios/Podfile.lock', 'native-widgets/configs/e2e/native_dependencies.json', 'native-widgets/configs/e2e/config.json', 'native-widgets/scripts/test/add-native-dependencies.js') }}
- name: "Verify restored iOS app"
shell: bash
run: |
set -euo pipefail
cached=false
# Keep in sync with install_ios_app() in maestro/helpers/prepare_ios.sh.
app="native-template/ios/build/Build/Products/Debug-iphonesimulator/NativeTemplate.app"
if [ "${{ steps.ios-app-cache.outputs.cache-hit }}" = "true" ]; then
if [ ! -d "$app" ]; then
echo "::warning::iOS app cache hit but $app is missing; rebuilding."
find native-template/ios/build/Build/Products -maxdepth 2 -name '*.app' 2>/dev/null || true
else
js=$(find "$app" -name 'index.ios.bundle' 2>/dev/null | head -1 || true)
if [ -z "$js" ]; then
echo "::warning::iOS app cache hit but no index.ios.bundle inside $app; rebuilding."
else
cached=true
echo "APP_PATH=$app" >> "$GITHUB_ENV"
echo "APP_BUNDLE_DIR=$(dirname "$js")" >> "$GITHUB_ENV"
echo "Reusing cached app: $app (bundle at $(dirname "$js"))"
fi
fi
else
echo "No usable iOS app cache; building."
fi
echo "IOS_APP_CACHED=$cached" >> "$GITHUB_ENV"
- name: "Set up Node"
if: env.IOS_APP_CACHED != 'true'
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: native-template/.nvmrc
cache: npm
cache-dependency-path: native-template/package-lock.json
- name: "Copy files to the right location"
if: env.IOS_APP_CACHED != 'true'
run: |
# native-packager emits bundle/iOS/{index.ios.bundle, assets/...}; copy the lot into
# ios/Bundle (per the official manual-build doc).
mkdir -p native-template/ios/Bundle
cp -r bundles/ios/* native-template/ios/Bundle/
mv native-widgets/configs/e2e/config.json native-template
node native-widgets/scripts/test/add-native-dependencies.js
- name: "Install Node dependencies"
if: env.IOS_APP_CACHED != 'true'
working-directory: native-template
run: npm i
- name: "Setup Pods cache"
if: env.IOS_APP_CACHED != 'true'
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
# Also cache CocoaPods' own download cache so `pod install` is fast even when
# the Pods/ dir misses. (~ is expanded by actions/cache.)
path: |
native-template/Pods
~/Library/Caches/CocoaPods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: "Install Pod dependencies"
if: env.IOS_APP_CACHED != 'true'
working-directory: native-template/ios
run: pod install
- name: "Build iOS app"
if: env.IOS_APP_CACHED != 'true'
working-directory: native-template/ios
# Build for the simulator's native arch (arm64 on Apple Silicon runners).
# ONLY_ACTIVE_ARCH=YES already limits to the active arch; the old
# VALID_ARCHS="i386 x86_64" forced dead/foreign archs and broke on macos-26.
run: xcodebuild -workspace NativeTemplate.xcworkspace -scheme nativeTemplate -configuration Debug -sdk iphonesimulator -derivedDataPath build ONLY_ACTIVE_ARCH=YES
- name: "Save built iOS app"
if: env.IOS_APP_CACHED != 'true'
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: native-template/ios/build/Build/Products
key: ${{ steps.ios-app-cache.outputs.cache-primary-key }}
- name: "Swap the JS bundle into the cached app"
# _CodeSignature goes stale, which is fine: simulator apps are not signature verified.
if: env.IOS_APP_CACHED == 'true'
shell: bash
run: |
set -euo pipefail
rm -rf "$APP_BUNDLE_DIR"
mkdir -p "$APP_BUNDLE_DIR"
cp -R bundles/ios/. "$APP_BUNDLE_DIR"/
test -f "$APP_BUNDLE_DIR/index.ios.bundle"
echo "Swapped bundle into $APP_PATH"
ls -l "$APP_BUNDLE_DIR"
- name: "Archive iOS app"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7
with:
name: ios-app
path: native-template/ios/build/Build/Products/**/*.app
# NOTE: no iOS counterpart to android-avd-cache — simslim's state is not persisted anywhere
# cacheable (see slim_simulator() in maestro/helpers/prepare_ios.sh), so each shard slims itself.
android-avd-cache:
runs-on: ubuntu-26.04
# Warm a booted-emulator snapshot once and cache it, so the per-widget Android shards
# restore it instead of cold-booting (~1-2 min saved per shard). Pure speed optimization:
# shards fall back to a cold boot on cache miss, so a failure here doesn't block tests.
steps:
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: "AVD cache"
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
# Keep in sync with the emulator config and the restore step in the test jobs.
key: avd-android-35-x86_64-google_apis-pixel
- name: "Create AVD and generate snapshot for caching"
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: 35
target: google_apis
arch: x86_64
profile: pixel
force-avd-creation: false
# 2 vCPUs for the emulator. GitHub-hosted Linux runners have only 4 vCPUs total, so
# leave 2 for the host (adb, Maestro, the JS bundler proxy). This is the action's
# default and the sweet spot on free runners; it's written to the AVD's config.ini
# (hw.cpu.ncore) and is what the emulator actually honors — a `-cores N` in
# emulator-options below would be silently overridden, so we set it here instead.
cores: 2
emulator-options: "-no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -memory 4096"
disable-animations: false
script: echo "Generated AVD snapshot for caching."
android-widget-tests:
needs: [scope, mendix-version, project, android-app, android-avd-cache]
# Run if widgets need testing (widgets_to_test is not empty) and project succeeds
if: ${{ needs.scope.outputs.widgets_to_test != '[]' && !cancelled() && needs.project.result == 'success' && (needs.android-app.result == 'success' || needs.android-app.result == 'skipped') }}
runs-on: ubuntu-26.04
# 30 min hard cap per widget shard. A healthy widget's flows run in ~30s each; the cap is a
# backstop for genuinely wedged shards. Bumped 20→30 after a run where shards were cancelled
# at 20 min — that was traced to a video-recording bug (the on-device screenrecord wasn't
# being stopped, adding ~2.5 min/flow); with that fixed 30 is comfortable headroom. If shards
# still hit 30, the cause is real app instability, not the cap — needs a different fix.
timeout-minutes: 30
strategy:
# 5 parallel Linux shards. Bounded by GitHub Free's 20 total concurrent-job cap (not the
# macOS-5 cap that limits the iOS matrix), so there's headroom. iOS stays at 4 to keep a
# macOS slot of headroom under that 5-job ceiling.
max-parallel: 5
matrix:
widget: ${{ fromJson(needs.scope.outputs.widgets_to_test) }}
fail-fast: false
steps:
- name: "Check out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: "Download portable app package"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: app-package
# Used only when specific run id is provided when triggering the jbo
- name: "Download Android app from specific run"
if: ${{ env.LOCAL_TEST_ARTIFACT_RUN_ID != '' }}
uses: ./.github/actions/use-arficats-from-specific-run
with:
artifact_name: android-app
run_id: ${{ env.LOCAL_TEST_ARTIFACT_RUN_ID }}
output_dir: android-app
platform: android
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: "Download Android app"
if: ${{ env.LOCAL_TEST_ARTIFACT_RUN_ID == '' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: android-app
path: android-app
- name: "Setup needed tools"
id: setup-needed-tools
uses: ./.github/actions/setup-tools
- name: "Start Mendix runtime"
uses: ./.github/actions/start-mendix-runtime
with:
java-home: ${{ steps.setup-needed-tools.outputs.java-path }}
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: "Restore AVD snapshot"
# Restore-only: the android-avd-cache job is the sole writer, so shards don't
# each try to re-save the same key. Must match that job's key.
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-android-35-x86_64-google_apis-pixel
- name: "Run android tests"
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: 35