-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into markdownAndFilePreviewInThreadList
- Loading branch information
Showing
724 changed files
with
60,876 additions
and
32,880 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: bandwidth-throttling | ||
description: Action to throttle the bandwidth on MacOS runner | ||
|
||
inputs: | ||
test_server_host: | ||
description: The host of the test server, no protocol | ||
required: true | ||
download_speed: | ||
description: The download speed limit (in Kbit/s) | ||
required: false | ||
default: "3300" | ||
upload_speed: | ||
description: The upload speed limit (in Kbit/s) | ||
required: false | ||
default: "3300" | ||
latency: | ||
description: The latency (in ms) each way | ||
required: false | ||
default: "500" | ||
disable: | ||
description: Disable throttling | ||
required: false | ||
default: "false" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: disable first | ||
if: ${{ inputs.disable == 'true' }} | ||
shell: bash | ||
continue-on-error: true | ||
run: | | ||
sudo pfctl -d | ||
sleep 2; | ||
- name: throttle bandwidth down | ||
shell: bash | ||
run: | | ||
# reset pf and dnctl | ||
sudo dnctl -q flush | ||
sudo dnctl -q pipe flush | ||
sudo pfctl -f /etc/pf.conf | ||
sudo pfctl -E | ||
sleep 2; | ||
sudo pfctl -d | ||
sudo dnctl -q flush | ||
sudo dnctl -q pipe flush | ||
echo "dummynet in from ${{ inputs.test_server_host }} to ! 127.0.0.1 pipe 1 | ||
dummynet out from ! 127.0.0.1 to ${{ inputs.test_server_host }} pipe 2" | sudo pfctl -f - | ||
# pipe 1 is download | ||
sudo dnctl pipe 1 config bw ${{ inputs.download_speed }}Kbit/s delay ${{ inputs.latency }}ms | ||
# pipe 2 is upload | ||
sudo dnctl pipe 2 config bw ${{ inputs.upload_speed }}Kbit/s delay ${{ inputs.latency }}ms | ||
sleep 5; | ||
sudo pfctl -E | ||
sleep 5; | ||
- name: test curl after throttling | ||
shell: bash | ||
run: | | ||
curl -o /dev/null -m 20 --retry 2 -s -w 'Total: %{time_total}s\n' 'https://${{ inputs.test_server_host }}/api/v4/system/ping?get_server_status=true' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 Mattermost, Inc. | ||
name: "generate-specs" | ||
description: This action used to split Detox integration tests based on the parallelism provided | ||
|
||
inputs: | ||
search_path: | ||
description: The path to look for from within the directory | ||
required: true | ||
parallelism: | ||
description: The parallelism for the tests | ||
required: true | ||
device_name: | ||
description: The name of Device used for the tests | ||
required: false | ||
default: "iPhone 15" | ||
device_os_version: | ||
description: The os of the device used for the tests | ||
required: false | ||
default: "iOS 17.1" | ||
|
||
outputs: | ||
specs: | ||
description: The specs generated for the strategy | ||
value: ${{ steps.generate-specs.outputs.specs }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: ci/generate-specs | ||
id: generate-specs | ||
env: | ||
PARALLELISM: ${{ inputs.parallelism }} | ||
SEARCH_PATH: ${{ inputs.search_path }} | ||
DEVICE_NAME: ${{ inputs.device_name }} | ||
DEVICE_OS_VERSION: ${{ inputs.device_os_version }} | ||
run: | | ||
set -e | ||
node ${{ github.action_path }}/split-tests.js | tee output.json | ||
echo "specs=$(cat output.json)" >> $GITHUB_OUTPUT | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
class DeviceInfo { | ||
constructor(deviceName, deviceOsVersion) { | ||
this.deviceName = deviceName; | ||
this.deviceOsVersion = deviceOsVersion; | ||
} | ||
} | ||
|
||
class SpecGroup { | ||
constructor(runId, specs, deviceInfo) { | ||
this.runId = runId; | ||
this.specs = specs; | ||
this.deviceName = deviceInfo.deviceName; | ||
this.deviceOsVersion = deviceInfo.deviceOsVersion; | ||
} | ||
} | ||
|
||
class Specs { | ||
constructor(searchPath, parallelism, deviceInfo) { | ||
this.searchPath = searchPath; | ||
this.parallelism = parallelism; | ||
this.rawFiles = []; | ||
this.groupedFiles = []; | ||
this.deviceInfo = deviceInfo; | ||
} | ||
|
||
findFiles() { | ||
const dirPath = path.join(this.searchPath); | ||
|
||
const fileRegex = /\.e2e\.ts$/; | ||
|
||
const walkSync = (currentPath) => { | ||
const files = fs.readdirSync(currentPath); | ||
|
||
files.forEach((file) => { | ||
const filePath = path.join(currentPath, file); | ||
const stats = fs.statSync(filePath); | ||
|
||
if (stats.isDirectory()) { | ||
walkSync(filePath); | ||
} else if (fileRegex.test(filePath)) { | ||
const relativeFilePath = filePath.replace(dirPath + '/', ''); | ||
const fullPath = path.join(this.searchPath, relativeFilePath); | ||
this.rawFiles.push(fullPath); | ||
} | ||
}); | ||
}; | ||
|
||
walkSync(dirPath); | ||
} | ||
|
||
generateSplits() { | ||
const chunkSize = Math.ceil(this.rawFiles.length / this.parallelism); | ||
let runNo = 1; | ||
|
||
for (let i = 0; i < this.rawFiles.length; i += chunkSize) { | ||
const end = Math.min(i + chunkSize, this.rawFiles.length); | ||
const fileGroup = this.rawFiles.slice(i, end).join(' '); | ||
const specFileGroup = new SpecGroup(runNo.toString(), fileGroup, this.deviceInfo); | ||
this.groupedFiles.push(specFileGroup); | ||
|
||
if (end === this.rawFiles.length) { | ||
break; | ||
} | ||
|
||
runNo++; | ||
} | ||
} | ||
|
||
dumpSplits() { | ||
const output = { | ||
include: this.groupedFiles, | ||
}; | ||
|
||
console.log(JSON.stringify(output)); | ||
} | ||
} | ||
|
||
function main() { | ||
const searchPath = process.env.SEARCH_PATH; | ||
const parallelism = parseInt(process.env.PARALLELISM, 10); | ||
const deviceName = process.env.DEVICE_NAME; | ||
const deviceOsVersion = process.env.DEVICE_OS_VERSION; | ||
const deviceInfo = new DeviceInfo(deviceName, deviceOsVersion); | ||
const specs = new Specs(searchPath, parallelism, deviceInfo); | ||
|
||
specs.findFiles(); | ||
specs.generateSplits(); | ||
specs.dumpSplits(); | ||
} | ||
|
||
main(); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: Prepare Low Bandwidth Environment (MacOS & iOS Simulators only) | ||
description: prepare any workflow for low bandwidth testing | ||
|
||
inputs: | ||
test_server_url: | ||
description: The URL of the test server | ||
required: true | ||
device_name: | ||
description: The iOS simulator name | ||
required: true | ||
download_speed: | ||
description: The download speed limit (in Kbit/s) | ||
required: false | ||
default: "3300" | ||
upload_speed: | ||
description: The upload speed limit (in Kbit/s) | ||
required: false | ||
default: "3300" | ||
latency: | ||
description: The latency (in ms) each way | ||
required: false | ||
default: "500" | ||
|
||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: delete the zip file and trash (to free up space) | ||
shell: bash | ||
run: | | ||
rm -rf mobile-artifacts/*.zip | ||
sudo rm -rf ~/.Trash/* | ||
- name: check disk space | ||
shell: bash | ||
run: df -h | ||
|
||
- name: remove protocol from SITE_1_URL | ||
id: remove-protocol | ||
shell: bash | ||
run: | | ||
echo "SITE_1_HOST=${{ inputs.test_server_url }}" | sed -e 's/http:\/\///g' -e 's/https:\/\///g' >> ${GITHUB_OUTPUT} | ||
- name: Throttle Bandwidth 1 | ||
id: throttle-bandwidth-1 | ||
continue-on-error: true | ||
uses: ./.github/actions/bandwidth-throttling | ||
with: | ||
test_server_host: ${{ steps.remove-protocol.outputs.SITE_1_HOST }} | ||
download_speed: ${{ inputs.download_speed }} | ||
upload_speed: ${{ inputs.upload_speed }} | ||
latency: ${{ inputs.latency }} | ||
|
||
- name: Throttle Bandwidth 2 | ||
if: steps.throttle-bandwidth-1.outcome != 'success' | ||
id: throttle-bandwidth-2 | ||
uses: ./.github/actions/bandwidth-throttling | ||
with: | ||
test_server_host: ${{ steps.remove-protocol.outputs.SITE_1_HOST }} | ||
download_speed: ${{ inputs.download_speed}} | ||
upload_speed: ${{ inputs.upload_speed }} | ||
latency: ${{ inputs.latency }} | ||
disable: "true" | ||
|
||
- name: Install mitmproxy & pm2 (process manager) | ||
id: install-mitmproxy-pm2 | ||
shell: bash | ||
run: | | ||
brew install mitmproxy | ||
npm i -g pm2 | ||
- name: Start mitmproxy via mitmdump and stop it (to get .mitmproxy folder) | ||
shell: bash | ||
run: | | ||
pm2 start mitmdump --log /Users/runner/work/mattermost-mobile/mattermost-mobile/mitmdump.log -- --allow-hosts '${{ steps.remove-protocol.outputs.SITE_1_HOST }}' --ignore-hosts 'localhost' -s /Users/runner/work/mattermost-mobile/mattermost-mobile/scripts/mitmdump-flow-parsing.py | ||
sleep 5; | ||
pm2 stop mitmdump | ||
# we need to wait for mitmdump to stop so it'll produce the .mitmproxy folder | ||
sleep 5; | ||
- name: Get simulator UDID | ||
id: get-simulator-udid | ||
shell: bash | ||
run: | | ||
simulator_udid=$(xcrun simctl list devices "${{ inputs.device_name }}" -j | jq '.devices' | jq '."com.apple.CoreSimulator.SimRuntime.iOS-17-4"[0]["udid"]') | ||
echo "simulator_udid="$(echo $simulator_udid) >> ${GITHUB_OUTPUT} | ||
- name: install certificate | ||
shell: bash | ||
run: | | ||
sudo security add-trusted-cert -d -p ssl -p basic -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem | ||
# must boot first before adding root cert | ||
xcrun simctl boot ${{ steps.get-simulator-udid.outputs.simulator_udid }} | ||
xcrun simctl keychain booted add-root-cert ~/.mitmproxy/mitmproxy-ca-cert.pem | ||
sleep 5; | ||
- name: show me booted simulators | ||
shell: bash | ||
run: xcrun simctl list devices booted | grep Booted |
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
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
Oops, something went wrong.