-
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.
Add workflow to run detox iOS tests (#7878)
- Loading branch information
1 parent
cf254f8
commit f46ddb4
Showing
37 changed files
with
1,898 additions
and
9,240 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
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
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
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
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.