Skip to content
Latchkey

facebook/metro/build-test-and-deploy workflow (react/metro)

The facebook/metro/build-test-and-deploy workflow from react/metro, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: react/metro.github/workflows/build-test-and-deploy.ymlLicense MITView source

What it does

This is the facebook/metro/build-test-and-deploy workflow from the react/metro repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: facebook/metro/build-test-and-deploy
on:
  pull_request:
    types: [opened, synchronize]
  push:
    tags:
# The job is triggered for any tag push. Tag format validation will be done
# as part of the deploy job for clearer error reporting for bad tag formatting
      - '**'

# ref us unique per PR (refs/pull/<pr_number>/merge)
# and per pushed tag (refs/tags/<tag_name>)
# So this makes sure that previous CI for the same PR/tag
# are cancelled when a newer one is triggered
concurrency:
  group: "build-test-and-deploy-${{ github.ref }}"
  cancel-in-progress: true

defaults:
  run:
    shell: bash

permissions:
  contents: read

jobs:
  run-js-checks:
    runs-on: ubuntu-latest
    name: "Type check, lint, smoke test"
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/yarn-install
      - run: yarn typecheck
      - run: yarn typecheck-ts
      - run: yarn lint
      - run: yarn test-smoke

  test-with-coverage:
    runs-on: ubuntu-latest
    name: "Tests with coverage"
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/yarn-install
      - run: yarn test-coverage
      - run: "./.github/scripts/install_codecov.sh"
      - run: "./codecov -t ${{ secrets.CODECOV_TOKEN }} -f ./coverage/coverage-final.json"

  test:
    strategy:
      fail-fast: false
      matrix:
        runs-on: ['ubuntu-latest', 'windows-latest', 'macos-latest']
        # Sync with nightly-tests.yml
        node-version: [
          '22.13.0', # minimum supported
          'lts/*',   # latest lts
          'latest'   # latest node version
        ]
    uses: ./.github/workflows/test.yml
    with:
      node-version: ${{ matrix.node-version }}
      runs-on: ${{ matrix.runs-on }}

  deploy:
    # runs only on tag pushes
    if: ${{ github.ref_type == 'tag' }}
    runs-on: ubuntu-latest
    name: "Deploy"
    needs: [run-js-checks, test]
    permissions:
      contents: read
      id-token: write  # Required for npm provenance / OIDC trusted publishing
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/yarn-install
      - run: "./.github/scripts/publish.sh"
        env:
          RAW_TAG_NAME: ${{ github.ref_name }}
          NPM_CONFIG_PROVENANCE: true

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: facebook/metro/build-test-and-deploy
on:
  pull_request:
    types: [opened, synchronize]
  push:
    tags:
# The job is triggered for any tag push. Tag format validation will be done
# as part of the deploy job for clearer error reporting for bad tag formatting
      - '**'
 
# ref us unique per PR (refs/pull/<pr_number>/merge)
# and per pushed tag (refs/tags/<tag_name>)
# So this makes sure that previous CI for the same PR/tag
# are cancelled when a newer one is triggered
concurrency:
  group: "build-test-and-deploy-${{ github.ref }}"
  cancel-in-progress: true
 
defaults:
  run:
    shell: bash
 
permissions:
  contents: read
 
jobs:
  run-js-checks:
    timeout-minutes: 30
    runs-on: latchkey-small
    name: "Type check, lint, smoke test"
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/yarn-install
      - run: yarn typecheck
      - run: yarn typecheck-ts
      - run: yarn lint
      - run: yarn test-smoke
 
  test-with-coverage:
    timeout-minutes: 30
    runs-on: latchkey-small
    name: "Tests with coverage"
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/yarn-install
      - run: yarn test-coverage
      - run: "./.github/scripts/install_codecov.sh"
      - run: "./codecov -t ${{ secrets.CODECOV_TOKEN }} -f ./coverage/coverage-final.json"
 
  test:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        runs-on: ['ubuntu-latest', 'windows-latest', 'macos-latest']
        # Sync with nightly-tests.yml
        node-version: [
          '22.13.0', # minimum supported
          'lts/*',   # latest lts
          'latest'   # latest node version
        ]
    uses: ./.github/workflows/test.yml
    with:
      node-version: ${{ matrix.node-version }}
      runs-on: ${{ matrix.runs-on }}
 
  deploy:
    timeout-minutes: 30
    # runs only on tag pushes
    if: ${{ github.ref_type == 'tag' }}
    runs-on: latchkey-small
    name: "Deploy"
    needs: [run-js-checks, test]
    permissions:
      contents: read
      id-token: write  # Required for npm provenance / OIDC trusted publishing
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/yarn-install
      - run: "./.github/scripts/publish.sh"
        env:
          RAW_TAG_NAME: ${{ github.ref_name }}
          NPM_CONFIG_PROVENANCE: true
 

What changed

This workflow runs 4 jobs (12 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow