Skip to content

Debug Workflow (replace me in your branch) #28

Debug Workflow (replace me in your branch)

Debug Workflow (replace me in your branch) #28

Workflow file for this run

# HOW TO USE THIS WORKFLOW FOR BRANCH TESTING
#
# GitHub only shows workflow_dispatch workflows that exist on the default branch
# (master), but when you trigger them manually you can choose which branch to
# run against — GitHub will use the workflow file from that branch.
#
# Steps to test a workflow on your feature branch:
# 1. In your branch, replace the contents of this file with the workflow you
# want to test (keep the `workflow_dispatch` trigger so it stays triggerable).
# 2. Push your branch.
# 3. Go to Actions → "Debug Workflow (replace me in your branch)" → "Run workflow".
# 4. Select your branch from the dropdown and click "Run workflow".
#
# The contents of this file on master are intentionally left as a no-op stub.
# Do NOT merge your debug changes back to master.
name: Debug Workflow (replace me in your branch)
on:
# Manual trigger for testing
workflow_dispatch:
concurrency:
group: Visreg-Mobile-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
actions: read
pull-requests: write
env:
CI: true
jobs:
ios:
name: Visreg iOS
runs-on: macos-latest
environment: production
outputs:
percy_url: ${{ steps.percy-upload.outputs.percy_url }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 1
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- uses: ./.github/actions/setup
- name: Set Percy branch
run: |
BRANCH_INPUT="${{ inputs.branch }}"
if [[ -n "$BRANCH_INPUT" ]]; then
echo "PERCY_BRANCH=$BRANCH_INPUT" >> "$GITHUB_ENV"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "PERCY_BRANCH=${{ github.head_ref }}" >> "$GITHUB_ENV"
else
echo "PERCY_BRANCH=${{ github.ref_name }}" >> "$GITHUB_ENV"
fi
- name: Install Maestro
run: node packages/mobile-visreg/src/setup.mjs
- name: Add Maestro to PATH
run: echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Prepare iOS app (extract prebuild + patch JS bundle)
run: yarn nx run mobile-app:patch-bundle-ios
- name: Boot iOS simulator
run: |
xcrun simctl boot "iPhone 16" || true
xcrun simctl bootstatus booted
- name: Install app on simulator
run: xcrun simctl install booted apps/mobile-app/prebuilds/ios-release-hermes.app
- name: Capture screenshots
run: yarn nx run mobile-visreg:ios
- name: Upload to Percy
id: percy-upload
if: always()
run: |
OUTPUT=$(yarn nx run mobile-visreg:upload 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
PERCY_URL=$(echo "$OUTPUT" | grep -oE 'https://percy\.io[^[:space:]]+' | head -1)
echo "percy_url=$PERCY_URL" >> "$GITHUB_OUTPUT"
exit $EXIT_CODE
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_MOBILE }}
PERCY_BRANCH: ${{ env.PERCY_BRANCH }}
PERCY_PARALLEL_NONCE: ${{ github.run_id }}
PERCY_PARALLEL_TOTAL: 1
# android:
# name: Visreg Android
# runs-on: ubuntu-latest
# environment: production
# if: >
# github.event_name == 'push' ||
# github.event_name == 'workflow_dispatch' ||
# contains(github.event.pull_request.labels.*.name, 'visreg-mobile')
# steps:
# - name: Harden the runner (Audit all outbound calls)
# uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
# with:
# egress-policy: audit
# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
# with:
# fetch-depth: 1
# ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
# - uses: ./.github/actions/setup
# - name: Set Percy branch
# run: |
# BRANCH_INPUT="${{ inputs.branch }}"
# if [[ -n "$BRANCH_INPUT" ]]; then
# echo "PERCY_BRANCH=$BRANCH_INPUT" >> "$GITHUB_ENV"
# elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
# echo "PERCY_BRANCH=${{ github.head_ref }}" >> "$GITHUB_ENV"
# else
# echo "PERCY_BRANCH=${{ github.ref_name }}" >> "$GITHUB_ENV"
# fi
# - name: Install Maestro
# run: node packages/mobile-visreg/src/setup.mjs
# - name: Add Maestro to PATH
# run: echo "$HOME/.maestro/bin" >> $GITHUB_PATH
# - name: Prepare Android app (extract prebuild + patch JS bundle)
# run: yarn nx run mobile-app:patch-bundle-android
# # Enable KVM hardware acceleration for the Android emulator.
# # Without this, the emulator runs in software emulation mode, which takes 6+ minutes to boot
# # and is significantly more flaky. Ubuntu GHA runners support KVM but it must be explicitly
# # unlocked via udev rules before use.
# # Ref: https://github.com/marketplace/actions/android-emulator-runner
# - 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: Start Android emulator + run visreg
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 30
# arch: x86_64
# profile: pixel_7_pro
# avd-name: cds_detox
# # -no-window -gpu swiftshader_indirect: headless software rendering (no display available in CI)
# # -no-boot-anim -noaudio -camera-back none: disable unused subsystems to speed up boot
# # -no-snapshot: disable snapshot load and save entirely (clean state every run)
# emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# disable-animations: true
# script: |
# # Enable Demo Mode to freeze status bar (avoids false Percy diffs)
# adb shell settings put global sysui_demo_allowed 1
# adb shell am broadcast -a com.android.systemui.demo -e command enter
# adb shell am broadcast -a com.android.systemui.demo -e command clock --es hhmm 1200
# adb shell am broadcast -a com.android.systemui.demo -e command battery --es level 100 --es plugged false
# adb shell am broadcast -a com.android.systemui.demo -e command network --es mobile show --es level 4 --es wifi show
# # sys.boot_completed=1 fires before all services are ready; wait for
# # the package manager specifically before attempting install.
# while ! adb shell pm list packages > /dev/null 2>&1; do echo "Waiting for package manager..."; sleep 1; done
# adb install -r apps/mobile-app/prebuilds/android-release-hermes/binary.apk
# # Copy Maestro debug artifacts after the run so they can be uploaded after the emulator shuts down
# yarn nx run mobile-visreg:android; cp -r ~/.maestro/tests /tmp/maestro-debug || true
# - name: Upload Maestro debug artifacts
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: maestro-debug-android
# path: /tmp/maestro-debug/
# if-no-files-found: ignore
# - name: Upload to Percy
# if: always()
# run: yarn nx run mobile-visreg:visreg-upload
# env:
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_MOBILE }}
# PERCY_BRANCH: ${{ env.PERCY_BRANCH }}
# PERCY_PARALLEL_NONCE: ${{ github.run_id }}
# PERCY_PARALLEL_TOTAL: 2
# comment-pr:
# name: Comment Percy Link
# needs: [ios, android]
# if: always() && github.event_name == 'pull_request'
# runs-on: ubuntu-latest
# steps:
# - name: Post Percy link on PR
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PERCY_URL: ${{ needs.ios.outputs.percy_url }}
# run: |
# BODY="${PERCY_URL:-Percy build URL unavailable}"
# gh pr comment ${{ github.event.pull_request.number }} \
# --repo ${{ github.repository }} \
# --body "$BODY" \
# --edit-last 2>/dev/null || \
# gh pr comment ${{ github.event.pull_request.number }} \
# --repo ${{ github.repository }} \
# --body "$BODY"