Skip to content

Commit

Permalink
test(connect): specify transport
Browse files Browse the repository at this point in the history
  • Loading branch information
mroz22 committed Nov 21, 2024
1 parent f8a8b5b commit 728d6e0
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 153 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/template-connect-test-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@ jobs:
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -i ${{ inputs.includeFilter }}" >> "$GITHUB_ENV"
- if: ${{ inputs.testRandomizedOrder }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -r" >> "$GITHUB_ENV"
- if: ${{ inputs.transport }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -t ${{ inputs.transport }}" >> "$GITHUB_ENV"
- run: './docker/docker-connect-test.sh ${{ inputs.testEnv }} -p "${{ inputs.testPattern }}" -f "${{ inputs.testsFirmware }}" $ADDITIONAL_ARGS'
29 changes: 26 additions & 3 deletions .github/workflows/test-connect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,26 @@ jobs:
dailyMatrix: ${{ steps.set-matrix-daily.outputs.dailyMatrix }}
otherDevicesMatrix: ${{ steps.set-matrix-other-devices.outputs.otherDevicesMatrix }}
allFwsMatrix: ${{ steps.set-matrix-all-firmwares.outputs.allFwsMatrix }}
allTransportsMatrix: ${{ steps.set-matrix-all-transports.outputs.allTransportsMatrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set daily matrix
id: set-matrix-daily
run: echo "dailyMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=T2T1 --firmware=2-latest --env=all --groups=api,api-flaky --cache_tx=true --transport=Bridge)" >> $GITHUB_OUTPUT
run: echo "dailyMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=T2T1 --firmware=2-latest --env=all --groups=api,api-flaky --cache_tx=true --transport=2.0.33)" >> $GITHUB_OUTPUT

- name: Set all firmwares matrix
id: set-matrix-all-firmwares
run: echo "allFwsMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=T2T1 --firmware=all --env=all --groups=all --cache_tx=false --transport=Bridge)" >> $GITHUB_OUTPUT
run: echo "allFwsMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=T2T1 --firmware=all --env=all --groups=all --cache_tx=false --transport=2.0.33)" >> $GITHUB_OUTPUT

- name: Set other devices matrix
id: set-matrix-other-devices
run: echo "otherDevicesMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=all --firmware=2-main --env=node --groups=api --cache_tx=true --transport=Bridge)" >> $GITHUB_OUTPUT
run: echo "otherDevicesMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=all --firmware=2-main --env=node --groups=api --cache_tx=true --transport=2.0.33)" >> $GITHUB_OUTPUT

- name: Set all transports matrix
id: set-matrix-all-transports
run: echo "allTransportsMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=T2T1 --firmware=2-latest --env=node --groups=api --cache_tx=true --transport=2.0.32,2.0.33)" >> $GITHUB_OUTPUT

PR-check:
needs: [build, set-matrix]
Expand Down Expand Up @@ -158,3 +163,21 @@ jobs:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set-matrix.outputs.otherDevicesMatrix) }}

all-transports:
needs: [build, set-matrix]
name: all-transports-api ${{ matrix.key }} {{ matrix.transport }}
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.repository == 'trezor/trezor-suite'
uses: ./.github/workflows/template-connect-test-params.yml
with:
testPattern: ${{ matrix.groups.pattern }}
includeFilter: ${{ matrix.groups.includeFilter }}
testsFirmware: ${{ matrix.firmware }}
testDescription: ${{ matrix.transport }}
cache_tx: ${{ matrix.cache_tx }}
transport: ${{ matrix.transport }}
testEnv: ${{ matrix.env }}
testFirmwareModel: ${{ matrix.model }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set-matrix.outputs.allTransportsMatrix) }}
10 changes: 9 additions & 1 deletion docker/docker-connect-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ show_usage() {
echo " -u Firmware url"
echo " -m Firmware model, example: R'"
echo " -r Randomize test order (node only)"
echo " -t Specify transport / bridge version"
}

# default options
Expand All @@ -53,10 +54,12 @@ USE_WS_CACHE=true
PATTERN=""
FIRMWARE_MODEL=""
RANDOMIZE=false
TRANSPORT="2.0.33"

# echo $OPTARG
# user options
OPTIND=2
while getopts ":p:i:e:f:u:m:hdcr" opt; do
while getopts ":p:i:e:f:u:m:t:hdcr" opt; do
case $opt in
d)
DOCKER=false
Expand Down Expand Up @@ -86,6 +89,9 @@ while getopts ":p:i:e:f:u:m:hdcr" opt; do
r)
RANDOMIZE=true
;;
t)
TRANSPORT=$OPTARG
;;
h) # Script usage
show_usage
exit 0
Expand Down Expand Up @@ -115,6 +121,7 @@ export TESTS_SCRIPT=$SCRIPT
export TESTS_FIRMWARE_URL=$FIRMWARE_URL
export TESTS_FIRMWARE_MODEL=$FIRMWARE_MODEL
export TESTS_RANDOM=$RANDOMIZE
export TESTS_TRANSPORT=$TRANSPORT

runDocker() {
docker compose -f ./docker/docker-compose.connect-test.yml up -d
Expand All @@ -132,6 +139,7 @@ run() {
echo " TxCache: ${USE_TX_CACHE}"
echo " WsCache: ${USE_WS_CACHE}"
echo " Random: ${RANDOMIZE}"
echo " Transport: ${TRANSPORT}"

if [ $DOCKER = true ]; then
runDocker
Expand Down
5 changes: 4 additions & 1 deletion packages/connect/e2e/common.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export const setup = async (
TrezorUserEnvLink.state = options;

// after all is done, start bridge again
await TrezorUserEnvLink.startBridge();
await TrezorUserEnvLink.startBridge(
// @ts-expect-error
process.env.TESTS_TRANSPORT,
);
};

export const initTrezorConnect = async (
Expand Down
Loading

0 comments on commit 728d6e0

Please sign in to comment.