name: "[Check] Validation" permissions: contents: read on: pull_request: push: branches: - release/2* - release-native/* env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_GHACTIONS_TOKEN }} concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: changed-scopes: name: Determine changed scopes runs-on: ubuntu-latest permissions: contents: read pull-requests: read outputs: default: ${{ steps.checks.outputs.default }} rust: ${{ steps.checks.outputs.rust }} docs: ${{ steps.checks.outputs.docs }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - uses: ./.github/actions/changed-scopes id: checks setup-and-cache: name: Setup and Cache Dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: Install node and yarn uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6 with: node-version-file: ".nvmrc" - name: Install SafeDep PMG uses: safedep/pmg@961499c36c98afbafec10a257ff27fb464073c86 # v0.30.0 continue-on-error: true with: version: v0.32.0 config-file: .github/pmg-config.yml - name: Restore develop Yarn cache uses: ./.github/actions/restore-yarn-cache # We can skip the build for all dependencies, even for those whitelisted, because this process is used only to validate the yarn.lock file. - name: Install deps run: | yarn --immutable --mode=skip-build type-check: name: Type Checking needs: setup-and-cache runs-on: ubuntu-latest env: NODE_OPTIONS: --max-old-space-size=6144 steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: "Checkout branches for Nx" uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Type Check run: yarn type-check --output-style=stream - name: Check Type Declaration Sizes run: yarn requirements:verify --only=type-declaration-size lint: name: Linting and formatting needs: setup-and-cache runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: "Checkout branches for Nx" uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: ESLint cache inputs id: eslint-cache-inputs run: node scripts/ci/eslint-cache-inputs.js - name: ESLint cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5 with: # Nx restores a workspace's `.eslintcache*` only on a task cache hit, so on a miss a fresh # runner lints the whole workspace from zero. This restores every workspace's cache file # so ESLint relints only the files whose content changed. # The key ends in the commit SHA because a cache entry is immutable: without it only the # first run would save and every later run would start from that one snapshot. The # restore key takes the newest entry for the same toolchain instead. # scripts/ci/eslint-cache-inputs.js explains what the toolchain hash covers and why the # paths are listed one by one. # GitHub lets a run restore only entries saved on its own branch or on the default branch, # so a pull request's first run restores the entry that build-develop-eslint-cache.yml # saves on every push to `develop`. path: ${{ steps.eslint-cache-inputs.outputs.paths }} key: ${{ runner.os }}-eslint-basic-${{ steps.eslint-cache-inputs.outputs.toolchain }}-${{ github.sha }} restore-keys: | ${{ runner.os }}-eslint-basic-${{ steps.eslint-cache-inputs.outputs.toolchain }}- - name: Lint JS run: yarn lint:js --output-style=stream - name: Lint Styles run: yarn lint:styles --output-style=stream lint-type-aware: # The type-aware rules are bound by the TypeScript program each lint worker builds, while the # rest of the rules parallelize freely, so the two rule sets run as separate jobs. The config # keeps every rule enabled in both; `ESLINT_RULE_SET` only picks which set a job enforces # (see packages/eslint/src/ruleSets.mjs). # Unlike the `lint` job, it restores no ESLint cache: ESLint reuses a file's cached result while # that file is unchanged, but a type-aware result also depends on the types of the files it # imports, so a restored cache would pass a file that a change elsewhere broke. name: Linting, type-aware rules needs: setup-and-cache runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: "Checkout branches for Nx" uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Lint JS env: ESLINT_RULE_SET: type-aware run: yarn lint:js --output-style=stream rust-checks: name: Rust checks needs: changed-scopes if: needs.changed-scopes.outputs.rust == 'true' runs-on: ubuntu-latest env: # Same toolchain as packages/transport-bluetooth/scripts/Dockerfile RUSTUP_TOOLCHAIN: "1.88.0" defaults: run: working-directory: packages/transport-bluetooth steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: Install Rust toolchain run: rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal --component rustfmt,clippy - name: Cargo Cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5 with: path: | ~/.cargo/registry ~/.cargo/git packages/transport-bluetooth/target key: cargo-${{ runner.os }}-${{ env.RUSTUP_TOOLCHAIN }}-${{ hashFiles('packages/transport-bluetooth/Cargo.lock') }} restore-keys: | cargo-${{ runner.os }}-${{ env.RUSTUP_TOOLCHAIN }}- - name: Rust Formatting run: cargo fmt --all -- --check - name: Create UI build placeholder run: mkdir -p build && touch build/index.html - name: Clippy run: cargo clippy --all-targets --locked -- -D warnings - name: Rust Tests run: cargo test --locked docs-checks: name: Docs checks needs: changed-scopes # With default scope changes the same checks run in "Other Checks". if: needs.changed-scopes.outputs.docs == 'true' && needs.changed-scopes.outputs.default != 'true' runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: "Checkout branches for Nx" uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Check Files for Correct Formatting run: yarn format:verify - name: Verify Requirements run: yarn requirements:verify --only=docs-summary-exhaustive - name: Collect Markdown link inputs run: | git ls-files -s -- '*.md' | awk '$1 != "120000" { print $4 }' > "$RUNNER_TEMP/markdown-link-inputs.txt" - name: Lint Markdown links uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0 with: lycheeVersion: v0.24.2 args: --offline --no-progress --root-dir '${{ github.workspace }}' --files-from '${{ runner.temp }}/markdown-link-inputs.txt' output: ${{ runner.temp }}/markdown-links.md test-madge-circular-imports: name: Check for new Circular Imports needs: setup-and-cache runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: "Checkout branches for Nx" uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Check for new Circular Imports # safedep/pmg covers also the `npx` running inside the shell script run: ./scripts/circular-dependencies/check-circular-dependencies.sh unit-tests-suite: name: Unit Tests (${{ matrix.test-task }}) needs: [changed-scopes, setup-and-cache] # Expand the matrix even when setup is skipped so each required check reports a result. if: ${{ !cancelled() && !failure() }} runs-on: ubuntu-latest timeout-minutes: 30 strategy: fail-fast: false matrix: test-task: [suite, native, "native:trading"] steps: - name: Checkout repository if: needs.changed-scopes.outputs.default == 'true' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: lfs: true - name: "Checkout branches for Nx" if: needs.changed-scopes.outputs.default == 'true' uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" if: needs.changed-scopes.outputs.default == 'true' uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Unit Tests if: needs.changed-scopes.outputs.default == 'true' run: yarn test:unit:${{ matrix.test-task }} --output-style=stream -- --silent build-libs-for-publishing: name: "Build libs for publishing" needs: setup-and-cache runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: "Checkout branches for Nx" uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Build Libs run: yarn build:libs:verify --output-style=stream other-checks: name: Other Checks needs: setup-and-cache runs-on: ubuntu-latest permissions: contents: read pull-requests: read steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: "Checkout branches for Nx" uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Verify Requirements run: yarn requirements:verify - name: Check Files for Correct Formatting run: yarn format:verify - name: Collect Markdown link inputs # All tracked Markdown files; untracked dependencies and generated files are excluded. # Symlinks are skipped: lychee resolves their relative links from the symlink location, # and their targets are checked directly. # Run lychee also on default scope changes, because md files link source code files. run: | git ls-files -s -- '*.md' | awk '$1 != "120000" { print $4 }' > "$RUNNER_TEMP/markdown-link-inputs.txt" - name: Lint Markdown links uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0 with: lycheeVersion: v0.24.2 args: --offline --no-progress --root-dir '${{ github.workspace }}' --files-from '${{ runner.temp }}/markdown-link-inputs.txt' output: ${{ runner.temp }}/markdown-links.md - name: Verify TS Project References run: yarn verify-project-references - name: Detect unused dependencies run: yarn depcheck - name: Install SafeDep PMG uses: safedep/pmg@961499c36c98afbafec10a257ff27fb464073c86 # v0.30.0 continue-on-error: true with: version: v0.32.0 config-file: .github/pmg-config.yml - name: Yarn Dedupe check run: yarn dedupe --check - name: Check dependency domain lists run: ./scripts/ci/list-missing-dependencies.sh - name: Verify Workspace Resolutions run: yarn check-workspace-resolutions # Neither ESLint nor jest can see a React Compiler frozen form read; see # suite-app/app/webpack/reactCompilerFrozenReads.ts. - name: React Compiler frozen form reads run: yarn react-compiler:check - name: Msg-system Config Validation run: yarn workspace @suite-common/message-system validate-config - name: Translation Duplicates run: yarn workspace @suite/intl translations:list-duplicates - name: Translation Unused run: yarn workspace @suite/intl translations:list-unused - name: Check mobile translation source changes uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: native-intl-changes with: filters: | native-intl: - 'suite-native/intl/src/messages.ts' - name: Translation Structure (mobile) if: steps.native-intl-changes.outputs.native-intl == 'true' run: yarn workspace @suite-native/intl translations:verify-structure - name: Check submodule changes if: github.event_name == 'pull_request' uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: submodule-changes with: filters: | submodules: - 'submodules/**' - name: Forbid unlabeled submodule changes if: steps.submodule-changes.outputs.submodules == 'true' env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number }} # Fetch PR labels, allow the update if the author added a tag `trezor-common-update`. run: | if ! gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json labels --jq '.labels[].name' | grep -qx 'trezor-common-update'; then echo "::error::This PR changes /submodules. If the trezor-common update is intended, add the 'trezor-common-update' label and re-run this job." exit 1 fi releases-revision-checks: name: Releases revision Checks needs: setup-and-cache runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 - name: Check releases.json files changes uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: changes with: filters: | releases-json: - 'packages/connect-data/files/firmware/t1b1/releases.json' - 'packages/connect-data/files/firmware/t2t1/releases.json' - name: "Checkout branches for Nx" if: steps.changes.outputs.releases-json == 'true' uses: ./.github/actions/nx-checkout - name: "Minimal yarn install" if: steps.changes.outputs.releases-json == 'true' uses: ./.github/actions/minimal-yarn-install with: disable-hardened-mode: "true" - name: Check releases.json revisions if: steps.changes.outputs.releases-json == 'true' run: yarn workspace @trezor/connect-data validate-releases.json