Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mroz22 committed Oct 25, 2024
1 parent 3eb7512 commit e1ccd5b
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 157 deletions.
101 changes: 47 additions & 54 deletions .github/workflows/template-connect-test-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: "[Template] connect unit"
on:
workflow_call:
inputs:
methods:
description: "List of methods to include in tests (example: applySettings,applyFlags,getFeatures)"
type: "string"
required: false
testPattern:
description: "Test pattern to use (example: `init` or `methods`)"
description: "Test pattern to use to match for test files (example: `init` or `methods`)"
type: "string"
required: true
includeFilter:
description: "List of methods to include in tests (example: applySettings,applyFlags,getFeatures)"
type: "string"
required: false
testsFirmware:
description: "Firmware version for the tests (example: 2-latest, 2.2.0, 2-main)"
type: "string"
Expand All @@ -19,16 +19,6 @@ on:
description: "Firmware model for the tests (example: T3T1)"
type: "string"
required: false
nodeEnvironment:
description: "Should the test run on nodejs environment, it runs by default."
type: "boolean"
required: false
default: true
webEnvironment:
description: "Should the test run on web environment, it runs by default."
type: "boolean"
required: false
default: true
testDescription:
description: "A description to make test title more descriptive (example: T3T1-latest)"
type: "string"
Expand All @@ -39,12 +29,25 @@ on:
type: "boolean"
required: false
default: false
cache_tx:
description: "Cache transactions"
type: "string"
required: false
default: false
transport:
description: "Transport to use (example: bridge, node-bridge)"
type: "string"
required: false
default: "Bridge"
testEnv:
description: "Environment to test (example: bridge, web)"
type: "string"
required: true

jobs:
node:
name: "node-${{ inputs.testDescription }}"
test:
name: "${{ inputs.testDescription }}"
runs-on: ubuntu-latest
if: ${{ inputs.nodeEnvironment }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -54,54 +57,44 @@ jobs:
with:
node-version-file: ".nvmrc"
cache: yarn
# todo: ideally do not install everything. possibly only devDependencies could be enough for testing (if there was not for building libs)?
- run: sed -i "/\"node\"/d" package.json
- run: yarn install
# nightly test - run without cached txs
- if: ${{ github.event_name == 'schedule' }}
run: echo "ADDITIONAL_ARGS=-c" >> "$GITHUB_ENV"
- if: ${{ inputs.testFirmwareModel }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -m ${{ inputs.testFirmwareModel }}" >> "$GITHUB_ENV"
- if: ${{ inputs.methods }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -i ${{ inputs.methods }}" >> "$GITHUB_ENV"
- if: ${{ inputs.testRandomizedOrder }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -r" >> "$GITHUB_ENV"
- run: './docker/docker-connect-test.sh node -p "${{ inputs.testPattern }}" -f "${{ inputs.testsFirmware }}" $ADDITIONAL_ARGS'

web:
name: "web-${{ inputs.testDescription }}"
runs-on: ubuntu-latest
if: ${{ inputs.webEnvironment }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn
- run: |
- if: ${{ inputs.testEnv == 'web' }}
run: |
echo -e "\nenableScripts: false" >> .yarnrc.yml
# Install dependencies only for @trezor/connect package
- run: yarn workspaces focus @trezor/connect
- name: Retrieve build connect-web
- if: ${{ inputs.testEnv == 'web' }}
run: yarn workspaces focus @trezor/connect
- if: ${{ inputs.testEnv == 'web' }}
name: Retrieve build connect-web
uses: actions/download-artifact@v4
with:
name: build-artifact-connect-web
path: packages/connect-web/build
- name: Retrieve build connect-iframe
- if: ${{ inputs.testEnv == 'web' }}
name: Retrieve build connect-iframe
uses: actions/download-artifact@v4
with:
name: build-artifact-connect-iframe
path: packages/connect-iframe/build
- run: cd packages/connect-iframe && tree .
- name: "Echo download path"
- if: ${{ inputs.testEnv == 'web' }}
run: cd packages/connect-iframe && tree .
- if: ${{ inputs.testEnv == 'web' }}
name: "Echo download path"
run: echo ${{steps.download.outputs.download-path}}
- if: ${{ github.event_name == 'schedule' }}

# todo: ideally do not install everything. possibly only devDependencies could be enough for testing (if there was not for building libs)?
- if: ${{ inputs.testEnv == 'node' }}
run: sed -i "/\"node\"/d" package.json
- if: ${{ inputs.testEnv == 'node' }}
run: yarn install

# nightly test - run without cached txs
- if: ${{ inputs.cache_tx == 'true' }}
run: echo "ADDITIONAL_ARGS=-c" >> "$GITHUB_ENV"
- if: ${{ inputs.testFirmwareModel }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -m ${{ inputs.testFirmwareModel }}" >> "$GITHUB_ENV"
- if: ${{ inputs.methods }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -i ${{ inputs.methods }}" >> "$GITHUB_ENV"
- run: './docker/docker-connect-test.sh web -p "${{ inputs.testPattern }}" -f "${{ inputs.testsFirmware }}" $ADDITIONAL_ARGS'
- if: ${{ inputs.includeFilter }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -i ${{ inputs.includeFilter }}" >> "$GITHUB_ENV"
- if: ${{ inputs.testRandomizedOrder }}
run: echo "ADDITIONAL_ARGS=$ADDITIONAL_ARGS -r" >> "$GITHUB_ENV"
- run: './docker/docker-connect-test.sh ${{ inputs.testEnv }} -p "${{ inputs.testPattern }}" -f "${{ inputs.testsFirmware }}" $ADDITIONAL_ARGS'
89 changes: 53 additions & 36 deletions .github/workflows/test-connect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,91 +77,108 @@ jobs:

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

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

- name: Set canary devices matrix
id: set-matrix-canary-firmware
run: echo "canaryFirmwareMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js canaryFirmware)" >> $GITHUB_OUTPUT
run: echo "canaryFirmwareMatrix=$(node ./scripts/ci/connect-test-matrix-generator.js --model=T2T1 --firmware=2-main --env=all --groups=all --cache_tx=false --transport=Bridge)" >> $GITHUB_OUTPUT

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

connect-PR:
T2T1_latest-fw_api:
needs: [build, set-matrix]
name: PR-${{ matrix.name }}
if: github.repository == 'trezor/trezor-suite'
name: ${{ matrix.model }}-${{ matrix.firmware }}
uses: ./.github/workflows/template-connect-test-params.yml
with:
testPattern: ${{ matrix.pattern }}
methods: ${{ matrix.methods }}
testPattern: ${{ matrix.groups.pattern }}
includeFilter: ${{ matrix.groups.includeFilter }}
testsFirmware: ${{ matrix.firmware }}
testDescription: ${{ matrix.name }}
testDescription: ${{ matrix.env }} ${{ matrix.groups.name }}
cache_tx: ${{ matrix.cache_tx }}
transport: ${{ matrix.transport }}
testEnv: ${{ matrix.env }}
testFirmwareModel: ${{ matrix.model }}
strategy:
fail-fast: false
fail-fast: true # in PRs we don't want to block CI too much so fail fast is enabled
matrix: ${{ fromJson(needs.set-matrix.outputs.dailyMatrix) }}

connect-randomized-order:
needs: [build, set-matrix]
if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
# if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
name: randomized-${{ matrix.name }}
uses: ./.github/workflows/template-connect-test-params.yml
with:
testPattern: ${{ matrix.pattern }}
methods: ${{ matrix.methods }}
testPattern: ${{ matrix.groups.pattern }}
includeFilter: ${{ matrix.groups.includeFilter }}
testsFirmware: ${{ matrix.firmware }}
testDescription: ${{ matrix.name }}-${{ matrix.firmware }}
testDescription: ${{ matrix.env }} ${{ matrix.groups.name }}
cache_tx: ${{ matrix.cache_tx }}
transport: ${{ matrix.transport }}
testEnv: ${{ matrix.env }}
testFirmwareModel: ${{ matrix.model }}
testRandomizedOrder: true
webEnvironment: false
nodeEnvironment: true
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set-matrix.outputs.dailyMatrix) }}

connect-legacy-firmware:
T2T1_legacy-fw:
needs: [build, set-matrix]
if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
name: legacy-${{ matrix.name }}
# if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
name: T2T1_legacy-fw
uses: ./.github/workflows/template-connect-test-params.yml
with:
testPattern: ${{ matrix.pattern }}
methods: ${{ matrix.methods }}
testPattern: ${{ matrix.groups.pattern }}
includeFilter: ${{ matrix.groups.includeFilter }}
testsFirmware: ${{ matrix.firmware }}
testDescription: ${{ matrix.name }}-${{ matrix.firmware }}
testDescription: ${{ matrix.env }} ${{ matrix.groups.name }}
cache_tx: ${{ matrix.cache_tx }}
transport: ${{ matrix.transport }}
testEnv: ${{ matrix.env }}
testFirmwareModel: ${{ matrix.model }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set-matrix.outputs.legacyFirmwareMatrix) }}

connect-canary-firmware:
T2T1_canary-fw:
needs: [build, set-matrix]
if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
name: canary-${{ matrix.name }}
# if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
name: T2T1_canary-fw
uses: ./.github/workflows/template-connect-test-params.yml
with:
testPattern: ${{ matrix.pattern }}
methods: ${{ matrix.methods }}
testPattern: ${{ matrix.groups.pattern }}
includeFilter: ${{ matrix.groups.includeFilter }}
testsFirmware: ${{ matrix.firmware }}
testDescription: ${{ matrix.name }}-${{ matrix.firmware }}
# testDescription: ${{ matrix.env }} ${{ matrix.groups.name }}
testDescription: Foo bar
cache_tx: ${{ matrix.cache_tx }}
transport: ${{ matrix.transport }}
testEnv: ${{ matrix.env }}
testFirmwareModel: ${{ matrix.model }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set-matrix.outputs.canaryFirmwareMatrix) }}

connect-other-devices:
all-models_api:
needs: [build, set-matrix]
if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
name: other-devices-${{ matrix.name }}-${{ matrix.model }}
# if: github.event_name == 'schedule' && github.repository == 'trezor/trezor-suite'
name: all-models_api
uses: ./.github/workflows/template-connect-test-params.yml
with:
testPattern: ${{ matrix.pattern }}
methods: ${{ matrix.methods }}
testPattern: ${{ matrix.groups.pattern }}
includeFilter: ${{ matrix.groups.includeFilter }}
testsFirmware: ${{ matrix.firmware }}
testDescription: ${{ matrix.env }} ${{ matrix.groups.name }}
cache_tx: ${{ matrix.cache_tx }}
transport: ${{ matrix.transport }}
testEnv: ${{ matrix.env }}
testFirmwareModel: ${{ matrix.model }}
nodeEnvironment: true
webEnvironment: false
testDescription: ${{ matrix.name }}-${{ matrix.firmware }}-${{ matrix.model }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set-matrix.outputs.otherDevicesMatrix) }}
Loading

0 comments on commit e1ccd5b

Please sign in to comment.