Add native pipeline workflow #99
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Native Pipeline | |
on: | |
workflow_dispatch: | |
# schedule: | |
# - cron: "0 6 * * *" | |
# push: | |
# branches: [master] | |
pull_request: | |
# branches: [master] | |
permissions: | |
packages: write | |
jobs: | |
scope: | |
runs-on: ubuntu-latest | |
outputs: | |
scope: ${{ steps.scope.outputs.scope }} | |
steps: | |
- name: "Determine scope" | |
id: scope | |
run: | | |
if [ ${{ github.event_name }} == 'pull_request' ]; then | |
echo "scope=--since --include '*-native'" >> $GITHUB_OUTPUT | |
elif [ {{ github.event_name }} != 'pull_request' ]; then | |
echo "scope=--include '*-native'" >> $GITHUB_OUTPUT | |
fi | |
mendix-version: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Check out code" | |
uses: actions/[email protected] | |
- name: "Get Mendix version" | |
id: get-mendix-version | |
uses: notiz-dev/[email protected] | |
with: | |
path: configs/e2e/mendix-versions.json | |
prop_path: latest | |
outputs: | |
mendix-version: ${{ steps.get-mendix-version.outputs.prop }} | |
docker-images: | |
needs: mendix-version | |
runs-on: ubuntu-22.04 | |
env: | |
MENDIX_VERSION: ${{ needs.mendix-version.outputs.mendix-version }} | |
steps: | |
- name: "Login to GitHub Container Registry" | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Check if docker image already exists" | |
run: | | |
docker manifest inspect ghcr.io/mendix/native-widgets/mxbuild:${{ env.MENDIX_VERSION }} || EXIT_CODE=$? | |
echo "IMAGE_MISSING=$EXIT_CODE" >> $GITHUB_ENV | |
- name: "Check out code" | |
uses: actions/[email protected] | |
if: ${{ env.IMAGE_MISSING != 0 }} | |
- name: "Build mxbuild image" | |
if: ${{ env.IMAGE_MISSING != 0 }} | |
uses: docker/[email protected] | |
with: | |
file: ./.github/scripts/mxbuild.Dockerfile | |
context: ./.github/scripts | |
build-args: | | |
MENDIX_VERSION=${{ env.MENDIX_VERSION }} | |
push: true | |
tags: ghcr.io/mendix/native-widgets/mxbuild:${{ env.MENDIX_VERSION }} | |
secrets: GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} | |
resources: | |
needs: scope | |
runs-on: ubuntu-22.04 | |
permissions: | |
packages: read | |
contents: read | |
steps: | |
- name: "Check out code" | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: "Set up node" | |
uses: actions/[email protected] | |
with: | |
node-version-file: .nvmrc | |
cache: yarn | |
- name: "Install dependencies" | |
run: yarn install --immutable | |
- name: "Unit test" | |
run: yarn workspaces foreach ${{ needs.scope.outputs.scope }} run test | |
- name: "Run build for development" | |
run: yarn workspaces foreach ${{ needs.scope.outputs.scope }} run build | |
env: | |
NODE_OPTIONS: --max_old_space_size=6144 | |
- name: "Upload resources artifact" | |
uses: actions/[email protected] | |
with: | |
name: resources | |
path: | | |
packages/pluggableWidgets/**/dist/*/*.mpk | |
packages/jsActions/mobile-resources-native/dist/**/* | |
packages/jsActions/nanoflow-actions-native/dist/**/* | |
project: | |
needs: [resources, mendix-version] | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/mendix/native-widgets/mxbuild:${{ needs.mendix-version.outputs.mendix-version }} | |
steps: | |
- name: "Download test project" | |
run: curl -L -o project.zip https://github.com/mendix/Native-Mobile-Resources/archive/refs/heads/main.zip | |
- name: "Extract test project" | |
uses: montudor/[email protected] | |
with: | |
args: unzip -qq project.zip | |
- name: "Download resources artifact" | |
uses: actions/[email protected] | |
with: | |
name: resources | |
path: resources | |
- name: "Move widgets" | |
shell: bash | |
run: | | |
if compgen -G 'resources/pluggableWidgets/**/dist/*/*.mpk' > /dev/null; then | |
for oldPath in resources/pluggableWidgets/**/dist/*/*.mpk; do | |
newPath=Native-Mobile-Resources-main/widgets/$(basename $oldPath) | |
mv -f $oldPath $newPath | |
done | |
mx update-widgets --loose-version-check Native-Mobile-Resources-main/NativeComponentsTestProject.mpr | |
fi | |
- name: "Move mobile-resources" | |
shell: bash | |
run: | | |
if compgen -G 'resources/jsActions/mobile-resources-native/*' > /dev/null; then | |
mv -f resources/jsActions/mobile-resources-native/* Native-Mobile-Resources-main/javascriptsource/nativemobileresources/actions/ | |
fi | |
- name: "Move nanoflow-actions" | |
shell: bash | |
run: | | |
if compgen -G 'resources/jsActions/mobile-resources-native/*' > /dev/null; then | |
mv -f resources/jsActions/nanoflow-actions-native/* Native-Mobile-Resources-main/javascriptsource/nanoflowcommons/actions/ | |
fi | |
- name: "Build test project" | |
run: mxbuild -o automation.mda Native-Mobile-Resources-main/NativeComponentsTestProject.mpr | |
- name: "Upload MDA" | |
uses: actions/[email protected] | |
with: | |
name: mda | |
path: automation.mda | |
android-bundle: | |
needs: [project, mendix-version] | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/mendix/native-widgets/mxbuild:${{ needs.mendix-version.outputs.mendix-version }} | |
steps: | |
- name: "Check out code" | |
uses: actions/[email protected] | |
- name: "Download deployment package" | |
uses: actions/[email protected] | |
with: | |
name: mda | |
- name: "Create Android bundle" | |
uses: ./.github/actions/create-native-bundle | |
with: | |
platform: android | |
mda-file: automation.mda | |
ios-bundle: | |
needs: [project, mendix-version] | |
runs-on: ubuntu-22.04 | |
container: ghcr.io/mendix/native-widgets/mxbuild:${{ needs.mendix-version.outputs.mendix-version }} | |
steps: | |
- name: "Check out code" | |
uses: actions/[email protected] | |
- name: "Download project MDA file" | |
uses: actions/[email protected] | |
with: | |
name: mda | |
- name: "Create iOS bundle" | |
uses: ./.github/actions/create-native-bundle | |
with: | |
platform: ios | |
mda-file: automation.mda | |
android-app: | |
needs: [android-bundle] | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Check out Native Template for Native Components Test Project" | |
uses: actions/[email protected] | |
with: | |
repository: mendix/native-template | |
ref: master | |
path: native-template | |
- name: "Check out code" | |
uses: actions/[email protected] | |
with: | |
path: native-widgets | |
- name: "Download Android bundle and assets" | |
uses: actions/[email protected] | |
with: | |
name: android-bundle | |
path: bundles/android | |
- name: "Set up Node" | |
uses: actions/[email protected] | |
with: | |
node-version-file: native-template/.nvmrc | |
cache: npm | |
cache-dependency-path: native-template/package-lock.json | |
- name: "Copy files to the right location" | |
run: | | |
mv bundles/android/index.android.bundle native-template/android/app/src/main/assets/index.android.bundle | |
cp -r bundles/android/assets/* native-template/android/app/src/main/res/ | |
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" | |
working-directory: native-template | |
run: npm i | |
- name: "Setup JDK 11" | |
uses: actions/[email protected] | |
with: | |
java-version: 11 | |
distribution: temurin | |
cache: gradle | |
- name: "Build Android app" | |
working-directory: native-template/android | |
run: ./gradlew assembleAppstoreDebug assembleAppstoreDebugAndroidTest | |
- name: "Archive Android app" | |
uses: actions/[email protected] | |
with: | |
name: android-app | |
path: native-template/android/app/build/outputs/apk/**/*.apk | |
ios-app: | |
needs: [ios-bundle] | |
runs-on: macos-12 | |
steps: | |
- name: "Check out Native Template for Native Components Test Project" | |
uses: actions/[email protected] | |
with: | |
repository: mendix/native-template | |
ref: master | |
path: native-template | |
- name: "Check out code" | |
uses: actions/[email protected] | |
with: | |
path: native-widgets | |
- name: "Download iOS bundle and assets" | |
uses: actions/[email protected] | |
with: | |
name: ios-bundle | |
path: bundles/ios | |
- name: "Set up Node" | |
uses: actions/[email protected] | |
with: | |
node-version-file: native-template/.nvmrc | |
cache: npm | |
cache-dependency-path: native-template/package-lock.json | |
- name: "Copy files to the right location" | |
run: | | |
mv bundles/ios/index.ios.bundle native-template/ios/Bundle/index.ios.bundle | |
mv bundles/ios/assets/assets 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" | |
working-directory: native-template | |
run: npm i | |
- name: "Setup Pods cache" | |
uses: actions/[email protected] | |
with: | |
path: native-template/Pods | |
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pods- | |
- name: "Install Pod dependencies" | |
working-directory: native-template/ios | |
run: pod install | |
- name: "Build iOS app" | |
working-directory: native-template/ios | |
run: xcodebuild -workspace NativeTemplate.xcworkspace -scheme nativeTemplate -configuration Debug -sdk iphonesimulator -derivedDataPath build ONLY_ACTIVE_ARCH=YES VALID_ARCHS="i386 x86_64" | |
- name: "Archive iOS app" | |
uses: actions/[email protected] | |
with: | |
name: ios-app | |
path: native-template/ios/build/Build/Products/**/*.app | |
android-avd: | |
runs-on: macos-12 | |
steps: | |
- name: "Check out code" | |
uses: actions/[email protected] | |
- name: "Setup AVD cache" | |
uses: actions/[email protected] | |
id: avd-cache | |
with: | |
path: | | |
/Users/runner/.android/avd/* | |
/Users/runner/.android/adb* | |
/Users/runner/Library/Android/sdk/system-images/**/* | |
key: pixel_30_x86_64_default_3core_and_system_images | |
- name: "Create AVD and generate snapshot for caching" | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/[email protected] | |
with: | |
api-level: 30 | |
target: default | |
arch: x86_64 | |
profile: pixel | |
cores: 3 | |
ram-size: 4096M | |
heap-size: 512M | |
avd-name: NATIVE_pixel_30 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: echo "AVD created" | |
android-tests: | |
needs: [scope, mendix-version, project, android-app, android-avd] | |
runs-on: macos-12 | |
steps: | |
- name: "Check out code" | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: "Set up node" | |
uses: actions/[email protected] | |
with: | |
node-version-file: .nvmrc | |
cache: yarn | |
- name: "Install dependencies" | |
run: yarn install --immutable | |
- name: "Download project MDA file" | |
uses: actions/[email protected] | |
with: | |
name: mda | |
- name: "Start runtime" | |
uses: ./.github/actions/start-runtime | |
with: | |
mda-file: automation.mda | |
mendix-version: ${{ needs.mendix-version.outputs.mendix-version }} | |
- name: "Download Android app" | |
uses: actions/[email protected] | |
with: | |
name: android-app | |
path: android-app | |
- name: "Move android apps to correct location" | |
run: | | |
mkdir -p detox/apps | |
find android-app -type f -iname "*.apk" -exec mv {} detox/apps/ \; | |
- name: "Setup AVD cache" | |
uses: actions/[email protected] | |
id: avd-cache | |
with: | |
path: | | |
/Users/runner/.android/avd/* | |
/Users/runner/.android/adb* | |
/Users/runner/Library/Android/sdk/system-images/**/* | |
key: pixel_30_x86_64_default_3core_and_system_images | |
- name: "Run tests" | |
uses: reactivecircus/[email protected] | |
with: | |
api-level: 30 | |
target: default | |
arch: x86_64 | |
profile: pixel | |
cores: 3 | |
ram-size: 4096M | |
heap-size: 512M | |
avd-name: NATIVE_pixel_30 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: | | |
adb shell "rm -fr /data/local/tmp/detox" | |
adb shell "mkdir -p /data/local/tmp/detox" | |
adb push "/Users/runner/work/native-widgets/native-widgets/detox/apps/app-appstore-debug.apk" "/data/local/tmp/detox/Application.apk" | |
adb push "/Users/runner/work/native-widgets/native-widgets/detox/apps/app-appstore-debug-androidTest.apk" "/data/local/tmp/detox/Test.apk" | |
adb shell pm install -r -g -t /data/local/tmp/detox/Application.apk 2>/dev/null | |
adb shell pm install -r -g -t /data/local/tmp/detox/Test.apk 2>/dev/null | |
yarn workspaces foreach ${{ needs.scope.outputs.scope }} run test:e2e:android | |
- name: "Archive runtime logs" | |
uses: actions/[email protected] | |
if: always() | |
with: | |
name: android-runtime-logs | |
path: log/*.log | |
if-no-files-found: ignore | |
- name: "Archive test screenshot diff results" | |
uses: actions/[email protected] | |
if: failure() | |
with: | |
name: android-screenshot-results | |
path: | | |
${{ github.workspace }}/packages/**/e2e/images/diffs/**/*.png | |
${{ github.workspace }}/packages/**/e2e/images/actual/**/*.png | |
if-no-files-found: ignore | |
- name: "Archive artifacts" | |
uses: actions/[email protected] | |
if: always() | |
with: | |
name: android-artifacts | |
path: packages/pluggableWidgets/**/artifacts/ | |
if-no-files-found: ignore | |
ios-tests: | |
needs: [scope, mendix-version, project, ios-app] | |
runs-on: macos-12 | |
steps: | |
- name: "Check out code" | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: "Set up node" | |
uses: actions/[email protected] | |
with: | |
node-version-file: .nvmrc | |
cache: yarn | |
- name: "Install dependencies" | |
run: yarn install --immutable | |
- name: "Download project MDA file" | |
uses: actions/[email protected] | |
with: | |
name: mda | |
- name: "Start runtime" | |
uses: ./.github/actions/start-runtime | |
with: | |
mda-file: automation.mda | |
mendix-version: ${{ needs.mendix-version.outputs.mendix-version }} | |
- name: "Download iOS app" | |
uses: actions/[email protected] | |
with: | |
name: ios-app | |
path: ios-app | |
- name: "Move iOS app to correct location" | |
run: | | |
mkdir -p detox/apps | |
find ios-app -type d -iname "*.app" -exec cp -R {} detox/apps/ \; | |
- name: Install Detox Dependencies | |
run: | | |
brew tap wix/brew | |
brew install applesimutils | |
- name: "Run tests" | |
run: yarn workspaces foreach ${{ needs.scope.outputs.scope }} run test:e2e:ios | |
- name: "Archive runtime logs" | |
uses: actions/[email protected] | |
if: always() | |
with: | |
name: ios-runtime-logs | |
path: log/*.log | |
if-no-files-found: ignore | |
- name: "Archive test screenshot diff results" | |
uses: actions/[email protected] | |
if: failure() | |
with: | |
name: ios-screenshot-results | |
path: | | |
${{ github.workspace }}/packages/**/e2e/images/diffs/**/*.png | |
${{ github.workspace }}/packages/**/e2e/images/actual/**/*.png | |
if-no-files-found: ignore | |
- name: "Archive artifacts" | |
uses: actions/[email protected] | |
if: always() | |
with: | |
name: ios-artifacts | |
path: packages/pluggableWidgets/**/artifacts/ | |
if-no-files-found: ignore |