Created
April 11, 2024 09:14
-
-
Save sregg/18e201b3ac8175852bb4fd7a5c3688ca to your computer and use it in GitHub Desktop.
Maestro GitHub Actions Workflow
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: E2E tests | |
on: | |
workflow_dispatch: | |
# daily builds on week days at 6pm EDT (22:00 UTC or 23:00 UTC (day light savings adjustment)) | |
schedule: | |
- cron: '00 23 * * 1,2,3,4,5' | |
env: | |
NO_FLIPPER: 1 | |
MAESTRO_DRIVER_STARTUP_TIMEOUT: 180000 | |
jobs: | |
e2e-tests-ios: | |
name: E2E tests iOS | |
timeout-minutes: 60 | |
runs-on: macos-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Build Cache | |
uses: mikehardy/buildcache-action@v2 | |
- name: Setup Node Environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
cache: yarn | |
- name: Set System Timezone | |
uses: szenius/[email protected] | |
with: | |
timezoneMacos: 'America/Toronto' | |
- name: Install NPM Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Set Up Ruby Environment | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7.5 | |
bundler-cache: true | |
- name: Pods Cache | |
uses: actions/cache@v3 | |
with: | |
path: ios/Pods | |
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} | |
- name: Install Pods | |
run: cd ios && pod install --repo-update && cd .. | |
- name: Set Up Ruby Environment in ios folder | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7.5 | |
working-directory: ios | |
bundler-cache: true | |
- name: Installing Maestro | |
run: curl -Ls "https://get.maestro.mobile.dev" | bash | |
- name: Installing Maestro dependencies | |
run: | | |
brew tap facebook/fb | |
brew install facebook/fb/idb-companion | |
- name: Build app for simulator | |
working-directory: ios | |
run: | | |
xcrun xcodebuild \ | |
-scheme "cookinmarketplace-staging" \ | |
-workspace "cookinmarketplace.xcworkspace" \ | |
-configuration "Release Staging" \ | |
-sdk "iphonesimulator" \ | |
-destination "generic/platform=iOS Simulator" \ | |
-derivedDataPath "temp_build" | |
- name: Create XCode Logs Artifact | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: xcode-logs | |
path: | | |
/Users/runner/Library/Logs/gym/Cookin Staging-cookinmarketplace-staging.log | |
- name: Setup e2e tests | |
env: | |
APP_PATH: './ios/temp_build/Build/Products/Release Staging-iphonesimulator/Cookin Staging.app' | |
run: | | |
echo "Launching iOS Simulator" | |
xcrun simctl boot "iPhone 14 Pro" | |
echo "Installing app on Simulator" | |
xcrun simctl install booted "${{ env.APP_PATH }}" | |
echo "Start video record" | |
xcrun simctl io booted recordVideo video.mp4 --codec=h264 & echo $! > video_record.pid | |
- name: Run e2e tests (3 retries) | |
run: | | |
i=0 | |
while [ $i -le 2 ]; do | |
$HOME/.maestro/bin/maestro test tests/e2e/place-order.yaml && break | |
let i=i+1 | |
if [ $i -eq 3 ]; then | |
echo "Failed after 3 attempts" | |
exit 1 | |
fi | |
done | |
- name: Stop video record | |
if: always() | |
run: kill -SIGINT $(cat video_record.pid) | |
- name: Upload artifacts | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: e2e-report | |
path: | | |
video.mp4 | |
~/.maestro/tests/** | |
- name: Notify Failure to Slack (#engineering-alerts) | |
uses: slackapi/[email protected] | |
if: failure() | |
with: | |
payload: | | |
{ | |
"text": "Failed e2e tests: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Failed e2e tests: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_ENG_ALERTS }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment