From 36bce2d90dcf13b5dc9cd282349a05fd9f57c3c6 Mon Sep 17 00:00:00 2001 From: Luis E <35935591+luisecm@users.noreply.github.com> Date: Tue, 30 Jan 2024 08:41:28 -0600 Subject: [PATCH] chore(appium): use a custom warp node for CI automation tests (#1771) --- .github/workflows/ui-test-automation.yml | 292 +++++++++++++++++------ utils/replace_node.sh | 10 + 2 files changed, 235 insertions(+), 67 deletions(-) create mode 100755 utils/replace_node.sh diff --git a/.github/workflows/ui-test-automation.yml b/.github/workflows/ui-test-automation.yml index 7587692d1bf..cdf7f8092aa 100644 --- a/.github/workflows/ui-test-automation.yml +++ b/.github/workflows/ui-test-automation.yml @@ -13,12 +13,55 @@ env: CARGO_TERM_COLOR: always jobs: + create-node: + runs-on: ubuntu-latest + steps: + - name: Checkout Warp directory πŸ”– + uses: actions/checkout@v4 + with: + repository: Satellite-im/Warp + + - name: Set up cargo cache πŸ› οΈ + uses: Swatinem/rust-cache@v2 + + - name: Install Rust πŸ’Ώ + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.73.0 + override: true + components: rustfmt, clippy + + - name: Run cargo build shuttle on Warp πŸš€ + run: cargo build --bin shuttle --release + + - name: Launch CI instance of Warp πŸš€ + run: ./target/release/shuttle --keyfile key.bin --listen-addr /ip4/127.0.0.1/tcp/4444 > peerID.txt & + + - name: Upload Artifact Peer ID data⬆️ + uses: actions/upload-artifact@v3 + with: + name: peerID + path: peerID.txt + + - name: Upload Artifact Key File data⬆️ + uses: actions/upload-artifact@v3 + with: + name: keyfile + path: key.bin + build-mac: + needs: create-node runs-on: macos-13 steps: - - name: Checkout Repo πŸ”– + - name: Checkout Uplink Repo πŸ”– uses: actions/checkout@v4 + - name: Download Peer ID file πŸ—³οΈ + uses: actions/download-artifact@v3 + with: + name: peerID + path: ./warp + - name: Set up cargo cache πŸ› οΈ uses: Swatinem/rust-cache@v2 @@ -34,6 +77,11 @@ jobs: run: | rustup target add x86_64-apple-darwin aarch64-apple-darwin + - name: Replace Warp Peer ID in Uplink πŸš€ + run: | + chmod +x ./utils/replace_node.sh + ./utils/replace_node.sh + - name: Build executable πŸ–₯️ run: make dmg continue-on-error: true @@ -67,13 +115,20 @@ jobs: type: add build-windows: + needs: create-node runs-on: labels: windows-latest steps: - - name: Checkout testing directory πŸ”– + - name: Checkout Uplink Repo πŸ”– uses: actions/checkout@v4 + - name: Download Peer ID file πŸ—³οΈ + uses: actions/download-artifact@v3 + with: + name: peerID + path: ./warp + - name: Set up cargo cache πŸ› οΈ uses: Swatinem/rust-cache@v2 @@ -83,18 +138,21 @@ jobs: toolchain: 1.73.0 components: rustfmt, clippy - - name: Build executable πŸ–₯️ - run: cargo build --release -F production_mode - continue-on-error: true + - name: Get Warp Peer ID and Build app πŸš€ + run: | + $localPeerId = Select-String -Path .\warp\peerID.txt -Pattern 'Local PeerID: ([^\s]*)' | ForEach-Object { $_.Matches.Groups[1].Value } + echo "localPeerId=$localPeerId" >> $env:GITHUB_ENV + $env:SHUTTLE_ADDR_POINT="/ip4/127.0.0.1/tcp/4444/p2p/" + $localPeerId + cargo build --release - name: Copy Extensions πŸ—³οΈ run: | - mkdir ./ui/extra/extensions - cp -r ./target/release/emoji_selector.d ./ui/extra/extensions/ - cp -r ./target/release/emoji_selector.dll ./ui/extra/extensions/ - cp -r ./target/release/emoji_selector.dll.exp ./ui/extra/extensions/ - cp -r ./target/release/emoji_selector.dll.lib ./ui/extra/extensions/ - cp -r ./target/release/emoji_selector.pdb ./ui/extra/extensions/ + mkdir .\ui\extra\extensions + cp -r .\target\release\emoji_selector.d .\ui\extra\extensions\ + cp -r .\target\release\emoji_selector.dll .\ui\extra\extensions\ + cp -r .\target\release\emoji_selector.dll.exp .\ui\extra\extensions\ + cp -r .\target\release\emoji_selector.dll.lib .\ui\extra\extensions\ + cp -r .\target\release\emoji_selector.pdb .\ui\extra\extensions\ - name: Upload Executable ⬆️ uses: actions/upload-artifact@v3 @@ -102,17 +160,17 @@ jobs: name: Uplink-Windows if-no-files-found: error path: | - target/release/uplink.exe + target\release\uplink.exe - name: Upload Windows Assets uses: actions/upload-artifact@v3 with: name: uplink-windows-assets path: | - ui/extra/images/ - ui/extra/prism_langs/ - ui/extra/themes/ - ui/extra/extensions/ + ui\extra\images\ + ui\extra\prism_langs\ + ui\extra\themes\ + ui\extra\extensions\ - name: Add label if any of build or test jobs failed if: failure() @@ -128,22 +186,45 @@ jobs: runs-on: macos-13 steps: - - name: Checkout working directory πŸ”– - uses: actions/checkout@v4 - - name: Checkout testing directory πŸ”– uses: actions/checkout@v4 with: repository: Satellite-im/testing-uplink - path: "./appium-tests" + + - name: Checkout Warp directory πŸ”– + uses: actions/checkout@v4 + with: + repository: Satellite-im/Warp + path: "./warp" + + - name: Download Key file πŸ—³οΈ + uses: actions/download-artifact@v3 + with: + name: keyfile + path: ./warp + + - name: Install Rust πŸ’Ώ + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.73.0 + override: true + components: rustfmt, clippy - name: Setup Node.js πŸ”¨ uses: actions/setup-node@v3 with: node-version: 18.17.1 + cache: "npm" + + - name: Cache NPM dependencies πŸ”¨ + uses: actions/cache@v3 + id: cache-mac + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - name: Install NPM dependencies πŸ“¦ - working-directory: ./appium-tests + if: steps.cache-mac.outputs.cache-hit != 'true' run: npm ci - name: Enable opening app not codesigned πŸ–₯️ @@ -153,10 +234,10 @@ jobs: uses: actions/download-artifact@v3 with: name: app-macos - path: ./appium-tests/apps + path: ./apps - name: Copy DMG to Appium Apps Directory πŸ’Ώ - working-directory: ./appium-tests/apps + working-directory: ./apps run: | unzip Uplink-Mac-Universal.zip cp -r ./Uplink.app /Applications/ @@ -181,41 +262,47 @@ jobs: - name: Delete Cache Folder and copy reusable data run: | rm -rf ~/.uplink - mkdir ./appium-tests/tests/fixtures/users/mac2 - cp -r ./appium-tests/tests/fixtures/users/FriendsTestUser/ ./appium-tests/tests/fixtures/users/mac2/FriendsTestUser + mkdir ./tests/fixtures/users/mac2 + cp -r ./tests/fixtures/users/FriendsTestUser/ ./tests/fixtures/users/mac2/FriendsTestUser + + - name: Run cargo build shuttle on Warp πŸš€ + working-directory: ./warp + run: cargo build --bin shuttle --release + + - name: Launch CI instance of Warp πŸš€ + working-directory: ./warp + run: ./target/release/shuttle --keyfile key.bin --listen-addr /ip4/127.0.0.1/tcp/4444 & - name: Run Tests on MacOS πŸ§ͺ - run: | - cd ./appium-tests - npm run mac.ci + run: npm run mac.ci - name: Upload Test Report - MacOS CI if: always() uses: actions/upload-artifact@v3 with: name: test-report-macos-ci - path: ./appium-tests/test-report/*.xml + path: ./test-report/*.xml - name: Upload Allure Test Results if: always() uses: actions/upload-artifact@v3 with: name: test-allure-macos-ci - path: ./appium-tests/allure-results/ + path: ./allure-results/ - name: Upload Screenshots for MacOS πŸ“· uses: actions/upload-artifact@v3 if: failure() with: name: appium-screenshots-MacOS - path: ./appium-tests/test-results + path: ./test-results - name: Upload Appium Log for MacOS πŸ“· uses: actions/upload-artifact@v3 if: failure() with: name: appium-log-macos - path: ./appium-tests/appium.log + path: ./appium.log - name: Add label if any of test jobs failed if: failure() @@ -231,22 +318,45 @@ jobs: runs-on: macos-13 steps: - - name: Checkout working directory πŸ”– - uses: actions/checkout@v4 - - name: Checkout testing directory πŸ”– uses: actions/checkout@v4 with: repository: Satellite-im/testing-uplink - path: "./appium-tests" + + - name: Checkout Warp directory πŸ”– + uses: actions/checkout@v4 + with: + repository: Satellite-im/Warp + path: "./warp" + + - name: Download Key file πŸ—³οΈ + uses: actions/download-artifact@v3 + with: + name: keyfile + path: ./warp + + - name: Install Rust πŸ’Ώ + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.73.0 + override: true + components: rustfmt, clippy - name: Setup Node.js πŸ”¨ uses: actions/setup-node@v3 with: node-version: 18.17.1 + cache: "npm" + + - name: Cache NPM dependencies πŸ”¨ + uses: actions/cache@v3 + id: cache-mac + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - name: Install NPM dependencies πŸ“¦ - working-directory: ./appium-tests + if: steps.cache-mac.outputs.cache-hit != 'true' run: npm ci - name: Enable opening app not codesigned πŸ–₯️ @@ -256,10 +366,10 @@ jobs: uses: actions/download-artifact@v3 with: name: app-macos - path: ./appium-tests/apps + path: ./apps - name: Copy DMG to Appium Apps Directory πŸ’Ώ - working-directory: ./appium-tests/apps + working-directory: ./apps run: | unzip Uplink-Mac-Universal.zip cp -r ./Uplink.app ./Uplink2.app @@ -286,38 +396,44 @@ jobs: defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false + - name: Run cargo build shuttle on Warp πŸš€ + working-directory: ./warp + run: cargo build --bin shuttle --release + + - name: Launch CI instance of Warp πŸš€ + working-directory: ./warp + run: ./target/release/shuttle --keyfile key.bin --listen-addr /ip4/127.0.0.1/tcp/4444 & + - name: Run Tests on MacOS πŸ§ͺ - run: | - cd ./appium-tests - npm run mac.multiremote + run: npm run mac.multiremote - name: Upload Test Report - MacOS Chats if: always() uses: actions/upload-artifact@v3 with: name: test-report-macos-chats - path: ./appium-tests/test-report/*.xml + path: ./test-report/*.xml - name: Upload Allure Test Results for MacOS Chats if: always() uses: actions/upload-artifact@v3 with: name: test-allure-macos-chats - path: ./appium-tests/allure-results/ + path: ./allure-results/ - name: Upload Screenshots for MacOS Chats πŸ“· uses: actions/upload-artifact@v3 if: failure() with: name: appium-screenshots-MacOS-chats - path: ./appium-tests/test-results + path: ./test-results - name: Upload Appium Log for MacOS Chats πŸ“· uses: actions/upload-artifact@v3 if: failure() with: name: appium-log-macos-chats - path: ./appium-tests/appium.log + path: ./appium.log - name: Add label if any of test jobs failed if: failure() @@ -333,14 +449,29 @@ jobs: runs-on: windows-latest steps: - - name: Checkout working directory πŸ”– - uses: actions/checkout@v4 - - name: Checkout testing directory πŸ”– uses: actions/checkout@v4 with: repository: Satellite-im/testing-uplink - path: "./appium-tests" + + - name: Checkout Warp directory πŸ”– + uses: actions/checkout@v4 + with: + repository: Satellite-im/Warp + path: "./warp" + + - name: Download Key file πŸ—³οΈ + uses: actions/download-artifact@v3 + with: + name: keyfile + path: ./warp + + - name: Install Rust πŸ’Ώ + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.73.0 + override: true + components: rustfmt, clippy - name: Change resolution on Windows Runner run: Set-DisplayResolution -Width 1920 -Height 1080 -Force @@ -350,25 +481,33 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18.17.1 + cache: "npm" + + - name: Cache NPM dependencies πŸ”¨ + uses: actions/cache@v3 + id: cache-mac + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - name: Install NPM dependencies πŸ“¦ - working-directory: ./appium-tests + if: steps.cache-mac.outputs.cache-hit != 'true' run: npm ci - name: Download the Windows app πŸ—³οΈ uses: actions/download-artifact@v3 with: name: Uplink-Windows - path: ./appium-tests/apps + path: ./apps - name: Download the Windows app assets uses: actions/download-artifact@v3 with: name: uplink-windows-assets - path: ./appium-tests/apps + path: ./apps - name: Move Windows assets to correct locations πŸ’Ώ - working-directory: ./appium-tests/apps + working-directory: ./apps run: | mkdir ./bin/extra mkdir ./extra @@ -395,37 +534,46 @@ jobs: run: If (Test-Path $home/.uplink) {Remove-Item -Recurse -Force $home/.uplink} Else { Break } shell: powershell + - name: Run cargo build shuttle on Warp πŸš€ + working-directory: ./warp + run: cargo build --bin shuttle --release + + - name: Launch CI instance of Warp πŸš€ + working-directory: ./warp + run: ./target/release/shuttle --keyfile key.bin --listen-addr /ip4/127.0.0.1/tcp/4444 & + - name: Run Tests on Windows πŸ§ͺ - working-directory: ./appium-tests - run: npm run windows.ci + run: | + $env:DRIVER="windows" + npm run windows.ci - name: Upload Test Report - Windows CI if: always() uses: actions/upload-artifact@v3 with: name: test-report-windows-ci - path: ./appium-tests/test-report/*.xml + path: ./test-report/*.xml - name: Upload Allure Test Results if: always() uses: actions/upload-artifact@v3 with: name: test-allure-windows-ci - path: ./appium-tests/allure-results/ + path: ./allure-results/ - name: Upload Screenshots for Windows πŸ“· uses: actions/upload-artifact@v3 if: failure() with: name: appium-screenshots-windows - path: ./appium-tests/test-results + path: ./test-results - name: Upload Appium Log for Windows πŸ“· uses: actions/upload-artifact@v3 if: failure() with: name: appium-log-windows - path: ./appium-tests/appium.log + path: ./appium.log - name: Add label if any of test jobs failed if: failure() @@ -438,7 +586,14 @@ jobs: publish-results: if: always() - needs: [build-mac, build-windows, test-mac, test-mac-chats, test-windows] + needs: + - create-node + - build-mac + - build-windows + - test-mac + - test-mac-chats + - test-windows + runs-on: ubuntu-latest permissions: checks: write @@ -531,12 +686,13 @@ jobs: remove-label: needs: - - build-mac - - build-windows - - test-mac - - test-mac-chats - - test-windows - - publish-results + - create-node + - build-mac + - build-windows + - test-mac + - test-mac-chats + - test-windows + - publish-results runs-on: ubuntu-latest @@ -548,6 +704,8 @@ jobs: uses: geekyeggo/delete-artifact@v2 with: name: | + peerID + keyfile Uplink-Windows uplink-windows-assets app-macos diff --git a/utils/replace_node.sh b/utils/replace_node.sh new file mode 100755 index 00000000000..7564afa1d0d --- /dev/null +++ b/utils/replace_node.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Read the values from ./warp/peerID +local_peer_id=$(grep -o 'Local PeerID: [^[:space:]]*' ./warp/peerID.txt | awk '{print $NF}') + +# Update the values in ./common/src/warp_runner/mod.rs and store in a temporary file +sed -e "s#cargo build --release -F#SHUTTLE_ADDR_POINT=/ip4/127.0.0.1/tcp/4444/p2p/$local_peer_id cargo build --release -F#" ./Makefile > temp_file + +# Replace the original mod.rs with the modified content +mv temp_file ./Makefile