Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version Compatibility Testing #179

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 255 additions & 2 deletions .github/workflows/ios-build-and-distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,125 @@ jobs:
path: /var/tmp/PrimerSDK_Debug_Build.zip
if-no-files-found: error

build-and-upload-to-browserstack:
runs-on: macos-latest
timeout-minutes: 30
name: Build and upload app to BrowserStack 🚀
steps:
- name: Cancel previous jobs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Git Checkout
uses: actions/checkout@v3

- name: Select Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa_github_actions
known_hosts: unnecessary

- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
bundler-cache: true

- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'

- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'

- name: Add slack message builder
run: |
yarn add slack-message-builder

- name: Get npm cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- name: Cache npm dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('*/package-lock.json', '*/*/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Set legacy-peer-deps for npm config
run: |
npm config set legacy-peer-deps true

- name: Cache pods
uses: actions/cache@v3
with:
path: |
ios/Pods
~/Library/Caches/CocoaPods
~/.cocoapods
key: ${{ runner.os }}-pods-${{ hashFiles('*/Podfile.lock', '*/*/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-

- name: Install packages
run: |
yarn

- name: Create main.jsbundle
run: |
yarn --cwd example build:ios

- name: Distribute the React Native iOS app on Appetize 🚀
run: |
bundle exec fastlane ios qa_release
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }}
MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }}
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
APPETIZE_API_TOKEN: ${{ secrets.APPETIZE_API_TOKEN }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
SOURCE_BRANCH: ${{ github.head_ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}

- name: Save build log
uses: actions/upload-artifact@v3
id: fastlane_build_log
if: ${{ failure() }}
with:
name: fastlane_build.log
path: /Users/runner/Library/Logs/gym/example_0_70_6-example_0_70_6.log

- name: Save Browserstack ID
uses: actions/upload-artifact@v3
id: save_browserstack_id_step
with:
name: browserstack_id
path: /var/tmp/browserstack_id.txt
if-no-files-found: error

test-via-browserstack:
if: false # Re-enable when we have tests set up
runs-on: ubuntu-latest
needs: build-and-upload-to-appetize
needs: build-and-upload-to-browserstack
name: Browserstack test
steps:
- name: Clone and launch Browserstack tests via Appium 🧪
Expand Down Expand Up @@ -210,4 +324,143 @@ jobs:
if: ${{ success() || failure() }}
run: |
node report-script/github-tests-summary-script.js createGithubSummaryReport



ios-test-rn-version-compatibility:
name: Test react-native version compatibility
needs: build-and-upload-to-browserstack
runs-on: macos-latest
strategy:
matrix:
version: ["0.70.8", "0.72.3"]
steps:
- name: Cancel previous jobs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Git Checkout
uses: actions/checkout@v3

- name: Retrieve Browserstack ID
uses: actions/download-artifact@v3
with:
name: browserstack_id
path: /var/tmp

- name: Select Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa_github_actions
known_hosts: unnecessary

- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
bundler-cache: true

- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'

- name: Add slack message builder
run: |
yarn add slack-message-builder

- name: Get npm cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- name: Cache npm dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('*/package-lock.json', '*/*/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Set legacy-peer-deps for npm config
run: |
npm config set legacy-peer-deps true

- name: Create test app
run: |
npx react-native init testapp --version ${{matrix.version}}

- name: Install Primer SDK
run: |
yarn --cwd testapp add @primer-io/react-native

- name: CocoaPods Install
run: |
cd testapp/ios ; npx pod-install ; cd ..

- name: Move Testing Template Files
run: |
cp -r compat-testing/* testapp/

- name: Install Appium Packages
working-directory: ./testapp
run: |
yarn add --dev \
appium appium-xcuitest-driver \
appium-uiautomator2-driver \
mocha-tags \
@wdio/appium-service \
@wdio/browserstack-service \
@wdio/cli \
@wdio/local-runner \
@wdio/mocha-framework \
@wdio/spec-reporter \
wdio-json-reporter \
@babel/cli \
@babel/preset-env \
@babel/register \
typescript \
ts-node

- name: Run iOS bundler and build
working-directory: ./testapp
run: |
npx react-native run-ios

- name: Start Appium Server
working-directory: ./testapp
run: |
nohup npx appium &

- name: Run Compatibility Tests
working-directory: ./testapp
env:
BROWSERSTACK_USERNAME: ${{secrets.BROWSERSTACK_USERNAME}}
BROWSERSTACK_ACCESS_KEY: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
run: |
export BROWSERSTACK_APP_ID=$(cat /var/tmp/browserstack_id.txt)
npx wdio test-config/wdio.ios.conf.js

- name: Create Slack Report
if: ${{ (success() || failure()) && github.event.pull_request.base.ref == 'master' }}
run: |
node report-scripts/test-report-script.js createSlackReport iOS

- name: Post summary message to a Slack channel
if: ${{ (success() || failure()) && github.event.pull_request.base.ref == 'master' }}
id: slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_MOBILE_SDK_CHANNEL }}
payload-file-path: '/var/tmp/slack-minimal_summary.json'
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ android/keystores/debug.keystore
lib/

# npm
.npmrc
.npmrc
testapp/
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"
ruby ">= 2.6.10"

gem "fastlane"
gem "cocoapods"

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'PluginFile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
Loading
Loading