Skip to content

Commit

Permalink
Merge branch 'develop' into chore/2312
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Apr 22, 2024
2 parents 6655c22 + b8ef745 commit c2dba47
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 69 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/e2e-android-self.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Detox E2E Android (self-hosted)

on:
push:
paths:
- packages/mobile/**
- packages/backend/**
- packages/state-manager/**
- .github/workflows/e2e-android-self.yml

jobs:
detox-android-self-hosted:
timeout-minutes: 10
runs-on: [self-hosted, macOS, ARM64, android]

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
npm i
npm run lerna bootstrap --scope @quiet/eslint-config,@quiet/logger,@quiet/common,@quiet/types,@quiet/state-manager,@quiet/backend,@quiet/identity,@quiet/mobile,backend-bundle
- name: Pull binaries
run: |
git lfs install --force
git lfs pull
- name: Pass local config
run : |
cat << EOF >> packages/mobile/android/local.properties
ndk.path=/Users/quiet/Library/Android/sdk/ndk/25.1.8937393
EOF
- name: Build Detox
run: |
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
cd packages/mobile
detox build -c android.emu.debug.ci
- name: Run basic tests
run: |
cd packages/mobile
detox test starter -c android.emu.debug.ci
82 changes: 63 additions & 19 deletions .github/workflows/e2e-android.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,88 @@
name: E2E Android
name: Detox E2E Android

on:
push:
paths:
- packages/mobile/**
- packages/backend/**
- packages/state-manager/**
- .github/workflows/e2e-android.yml
on: workflow_dispatch

jobs:
detox-android:
timeout-minutes: 10
runs-on: [self-hosted, macOS, ARM64, android]
timeout-minutes: 25
runs-on: [macos-latest-xlarge]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@master
with:
node-version: 18.12.1

- name: Install dependencies
run: |
npm i
npm run lerna bootstrap --scope @quiet/eslint-config,@quiet/logger,@quiet/common,@quiet/types,@quiet/state-manager,@quiet/backend,@quiet/identity,@quiet/mobile,backend-bundle
npm ci
npm run lerna bootstrap -- --scope=\'{@quiet/eslint-config,@quiet/logger,@quiet/common,@quiet/types,@quiet/state-manager,@quiet/backend,@quiet/identity,@quiet/mobile,backend-bundle}\'
- name: Pull binaries
run: |
git lfs install
git lfs install --force
git lfs pull
- name: Pass local config
run : |
cat << EOF >> packages/mobile/android/local.properties
ndk.path=/Users/quiet/Library/Android/sdk/ndk/25.1.8937393
EOF
# see: https://stackoverflow.com/questions/67264212/android-emulator-crash-when-start-hvf-error-hv-error
- name: Create qemu entitlements
run: |
{
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
echo '<plist version="1.0">'
echo '<dict>'
echo ' <key>com.apple.security.hypervisor</key>'
echo ' <true/>'
echo '</dict>'
echo '</plist>'
} >> $ANDROID_HOME/emulator/qemu/darwin-aarch64/entitlements.xml
- name: Re-sign qemu binary
run: |
cd $ANDROID_HOME/emulator/qemu/darwin-aarch64
codesign -s - --entitlements entitlements.xml --force qemu-system-aarch64 --verbose
- name: Install SDK image
run: yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-34;google_apis;arm64-v8a'

- name: Create AVD
run: $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n emulator_ci -k 'system-images;android-34;google_apis;arm64-v8a' -d 'pixel_7'

- name: Boot AVD
run: $ANDROID_HOME/emulator/emulator -avd emulator_ci

- name: Install pm2
run: npm install pm2@latest -g

- name: Start metro
run: |
cd packages/mobile
pm2 --name METRO start npm -- start
- name: Install Detox CLI
run: npm install detox-cli --global

- name: Build Detox
run: |
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
cd packages/mobile
detox build -c android.emu.debug.ci
- name: Run basic tests
run: |
cd packages/mobile
detox test starter -c android.emu.debug.ci
- name: Stop metro
run: pm2 stop METRO

- name: Take screenshot
if: always()
run: | # TODO
- name: Upload screenshot
if: always()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: screenshot.png
path: screenshot.png
1 change: 1 addition & 0 deletions .github/workflows/e2e-crossplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- packages/state-manager/**
- packages/identity/**
- packages/common/**
- packages/e2e-tests/**

jobs:
mac:
Expand Down
62 changes: 50 additions & 12 deletions .github/workflows/e2e-ios.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
name: E2E iOS
name: Detox E2E iOS

on:
push:
paths:
- packages/mobile/**
- packages/backend/**
- packages/state-manager/**
on: workflow_dispatch

jobs:
detox-ios:
timeout-minutes: 10
runs-on: [self-hosted, macOS, ARM64, iOS]
timeout-minutes: 25
runs-on: [macos-latest-xlarge]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@master
with:
node-version: 18.12.1

- name: Install dependencies
run: |
npm i
npm run lerna bootstrap --scope @quiet/eslint-config,@quiet/logger,@quiet/common,@quiet/types,@quiet/state-manager,@quiet/backend,@quiet/identity,@quiet/mobile,backend-bundle
npm ci
npm run lerna bootstrap -- --scope=\'{@quiet/eslint-config,@quiet/logger,@quiet/common,@quiet/types,@quiet/state-manager,@quiet/backend,@quiet/identity,@quiet/mobile,backend-bundle}\'
- name: Pull binaries
run: |
git lfs install
git lfs install --force
git lfs pull
- name: Install pods
run: |
cd packages/mobile/ios
pod install
- name: List simulator devices
run: xcrun simctl list devices

- name: Boot simulator
run: |
UDID=$(xcrun simctl list devices | grep 'iPhone 15 (' | awk -F '[()]' '{print $2}' | awk 'NR==2')
xcrun simctl boot "$UDID"
- name: Install pm2
run: npm install pm2@latest -g

- name: Start metro
run: |
cd packages/mobile
pm2 --name METRO start npm -- start
- name: Install Detox CLI
run: npm install detox-cli --global

- name: Install applesimutils
run: |
brew tap wix/brew
brew install applesimutils
- name: Build Detox
run: |
cd packages/mobile
Expand All @@ -39,3 +62,18 @@ jobs:
run: |
cd packages/mobile
detox test starter -c ios.sim.debug.ci
- name: Stop metro
run: pm2 stop METRO

- name: Take screenshot
if: always()
run: |
/usr/bin/xcrun simctl io booted screenshot screenshot.png
- name: Upload screenshot
if: always()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: screenshot.png
path: screenshot.png
23 changes: 12 additions & 11 deletions .github/workflows/e2e-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,28 @@ jobs:
max_attempts: 3
shell: bash
command: cd packages/e2e-tests && npm run test oneClient.test.ts

- name: Run multiple clients test
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
with:
timeout_minutes: 30
max_attempts: 3
shell: bash
command: cd packages/e2e-tests && npm run test multipleClients.test.ts


- name: Run user profile test
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
max_attempts: 3
shell: bash
command: cd packages/e2e-tests && npm run test userProfile.test.ts

- name: Run invitation link test - Includes 2 separate application clients
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
with:
timeout_minutes: 25
timeout_minutes: 10
max_attempts: 3
shell: bash
command: cd packages/e2e-tests && npm run test invitationLink.test.ts


- name: Run multiple clients test
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
with:
timeout_minutes: 30
max_attempts: 3
shell: bash
command: cd packages/e2e-tests && npm run test multipleClients.test.ts
4 changes: 2 additions & 2 deletions packages/e2e-tests/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export class App {
console.log('App closed', this.buildSetup.dataDir)
}

async cleanup() {
async cleanup(force: boolean = false) {
console.log(`Performing app cleanup`, this.buildSetup.dataDir)
if (this.isOpened) {
throw new Error(`App with dataDir ${this.buildSetup.dataDir} is still open, close before cleaning up!`)
}
this.buildSetup.clearDataDir()
this.buildSetup.clearDataDir(force)
}

get saveStateButton() {
Expand Down
5 changes: 4 additions & 1 deletion packages/e2e-tests/src/tests/invitationLink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ describe('New user joins using invitation link while having app opened', () => {
beforeAll(async () => {
ownerApp = new App()
guestApp = new App({ defaultDataDir: true })
if (process.platform === 'win32') {
await guestApp.cleanup(true)
}
})

beforeEach(async () => {
Expand Down Expand Up @@ -143,7 +146,7 @@ describe('New user joins using invitation link while having app opened', () => {
const copiedCode = url.hash.substring(1)
expect(() => parseInvitationCode(copiedCode)).not.toThrow()
const data = parseInvitationCode(copiedCode)
const commandFull = `${command[process.platform as SupportedPlatformDesktop]} "${composeInvitationDeepUrl(data)}"`
const commandFull = `${command[process.platform as SupportedPlatformDesktop]} ${process.platform === 'win32' ? '""' : ''} "${composeInvitationDeepUrl(data)}"`
console.log(`Calling ${commandFull}`)
execSync(commandFull)
console.log('Guest opened invitation link')
Expand Down
6 changes: 3 additions & 3 deletions packages/e2e-tests/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export class BuildSetup {
}

private getBinaryLocation() {
console.log('filename', this.fileName)
switch (process.platform) {
case 'linux':
console.log('filename', this.fileName)
return `${__dirname}/../Quiet/${this.fileName ? this.fileName : BuildSetup.getEnvFileName()}`
case 'win32':
return `${process.env.LOCALAPPDATA}\\Programs\\@quietdesktop\\Quiet.exe`
Expand Down Expand Up @@ -234,8 +234,8 @@ export class BuildSetup {
await this.driver?.close()
}

public clearDataDir() {
if (process.env.IS_CI === 'true') {
public clearDataDir(force: boolean = false) {
if (process.env.IS_CI === 'true' && !force) {
console.warn('Not deleting data directory because we are running in CI')
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/.detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
emulator_ci: {
type: 'android.emulator',
device: {
avdName: 'Pixel_7_API_31',
avdName: 'emulator_ci',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/e2e/utils/consts/timeouts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const BASIC = 5000
export const LONG = 20000
export const STARTUP = 90000
export const STARTUP = 120000
2 changes: 1 addition & 1 deletion packages/mobile/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'

platform :ios, '17.4'
platform :ios, '17.1'

target 'Quiet' do
config = use_native_modules!
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,6 @@ SPEC CHECKSUMS:
Tor: 39dc71bf048312e202608eb499ca5c74e841b503
Yoga: 13c8ef87792450193e117976337b8527b49e8c03

PODFILE CHECKSUM: 811e75c5d23ebd5b5f3e16c6dd4bae230db730d0
PODFILE CHECKSUM: eed49772dde039b0723324c813c83dd4c1af35f7

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
4 changes: 2 additions & 2 deletions packages/mobile/ios/Quiet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5300,7 +5300,7 @@
INFOPLIST_FILE = Quiet/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Quiet;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
IPHONEOS_DEPLOYMENT_TARGET = 17.4;
IPHONEOS_DEPLOYMENT_TARGET = 17.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -5396,7 +5396,7 @@
INFOPLIST_FILE = Quiet/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Quiet;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
IPHONEOS_DEPLOYMENT_TARGET = 17.4;
IPHONEOS_DEPLOYMENT_TARGET = 17.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Loading

0 comments on commit c2dba47

Please sign in to comment.