Skip to content
Latchkey

facebook/metro/nightly-tests workflow (react/metro)

The facebook/metro/nightly-tests 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/nightly-tests.ymlLicense MITView source

What it does

This is the facebook/metro/nightly-tests 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)
# In order to be updated when nightlies fail, please subscribe for updates on PR:
# ---> https://github.com/facebook/metro/pull/1314 <---
# where comments will be published on fail.

# This is a bit of a workaround tackling the lack of an organic way
# to notify certain people when a Github workflow fails:
# https://github.com/orgs/community/discussions/18039

name: facebook/metro/nightly-tests
on:
  schedule:
    # Daily at at 5:00 UTC
    - cron:  '0 5 * * *'

permissions:
  contents: read

jobs:
  test:
    strategy:
      max-parallel: 1 # reduces the flakiness of these tests
      fail-fast: false
      matrix:
        runs-on: ['ubuntu-latest', 'windows-latest', 'macos-latest']
        # Sync with build-test-and-deploy.yml
        node-version: [  # https://github.com/nodejs/release#release-schedule
          '22.13.0', # minimum supported
          'lts/*',   # latest lts
          'latest'   # latest node version
        ]
        no-lockfile: ['false', 'true']
    uses: ./.github/workflows/test.yml
    with:
      node-version: ${{ matrix.node-version }}
      runs-on: ${{ matrix.runs-on }}
      no-lockfile: ${{ matrix.no-lockfile }}

  comment-on-pr-for-failures:
    runs-on: ubuntu-latest
    needs: [test]
    if: ${{ always() && needs.test.result == 'failure' }}
    permissions:
      contents: read
      issues: write
    steps:
      - uses: actions/github-script@v8
        with:
          script: |
            github.rest.issues.createComment({
              // see https://github.com/facebook/metro/pull/1314
              issue_number: 1314,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: 'The nightly workflow `${{ github.workflow }}` failed in [run ${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})!',
            });

The same workflow, on Latchkey

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

# In order to be updated when nightlies fail, please subscribe for updates on PR:
# ---> https://github.com/facebook/metro/pull/1314 <---
# where comments will be published on fail.
 
# This is a bit of a workaround tackling the lack of an organic way
# to notify certain people when a Github workflow fails:
# https://github.com/orgs/community/discussions/18039
 
name: facebook/metro/nightly-tests
on:
  schedule:
    # Daily at at 5:00 UTC
    - cron:  '0 5 * * *'
 
permissions:
  contents: read
 
jobs:
  test:
    timeout-minutes: 30
    strategy:
      max-parallel: 1 # reduces the flakiness of these tests
      fail-fast: false
      matrix:
        runs-on: ['ubuntu-latest', 'windows-latest', 'macos-latest']
        # Sync with build-test-and-deploy.yml
        node-version: [  # https://github.com/nodejs/release#release-schedule
          '22.13.0', # minimum supported
          'lts/*',   # latest lts
          'latest'   # latest node version
        ]
        no-lockfile: ['false', 'true']
    uses: ./.github/workflows/test.yml
    with:
      node-version: ${{ matrix.node-version }}
      runs-on: ${{ matrix.runs-on }}
      no-lockfile: ${{ matrix.no-lockfile }}
 
  comment-on-pr-for-failures:
    timeout-minutes: 30
    runs-on: latchkey-small
    needs: [test]
    if: ${{ always() && needs.test.result == 'failure' }}
    permissions:
      contents: read
      issues: write
    steps:
      - uses: actions/github-script@v8
        with:
          script: |
            github.rest.issues.createComment({
              // see https://github.com/facebook/metro/pull/1314
              issue_number: 1314,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: 'The nightly workflow `${{ github.workflow }}` failed in [run ${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})!',
            });
 

What changed

This workflow runs 2 jobs (19 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