Skip to content
Latchkey

build workflow (google-research/t5x)

The build workflow from google-research/t5x, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, 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: google-research/t5x.github/workflows/build.yamlLicense Apache-2.0View source

What it does

This is the build workflow from the google-research/t5x repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

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

The workflow

workflow (.yml)
name: build

on: [push, workflow_dispatch]
permissions:
  statuses: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.11.x'
        cache: 'pip'
        cache-dependency-path: setup.py
    - name: Install dependencies
      run: |
        pip install -e .[test] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
    - name: Test with pytest
      run: |
        pytest
    # The below step just reports the success or failure of tests as a "commit status".
    # This is needed for copybara integration.
    - name: Report success or failure as github status
      if: always()
      shell: bash
      run: |
        status="${{ job.status }}"
        lowercase_status=$(echo $status | tr '[:upper:]' '[:lower:]')
        curl -sS --request POST \
        --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
        --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
        --header 'content-type: application/json' \
        --data '{
            "state": "'$lowercase_status'",
            "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
            "description": "'$status'",
            "context": "github-actions/build"
            }'

The same workflow, on Latchkey

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

name: build
 
on: [push, workflow_dispatch]
permissions:
  statuses: write
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.11.x'
        cache: 'pip'
        cache-dependency-path: setup.py
    - name: Install dependencies
      run: |
        pip install -e .[test] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
    - name: Test with pytest
      run: |
        pytest
    # The below step just reports the success or failure of tests as a "commit status".
    # This is needed for copybara integration.
    - name: Report success or failure as github status
      if: always()
      shell: bash
      run: |
        status="${{ job.status }}"
        lowercase_status=$(echo $status | tr '[:upper:]' '[:lower:]')
        curl -sS --request POST \
        --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
        --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
        --header 'content-type: application/json' \
        --data '{
            "state": "'$lowercase_status'",
            "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
            "description": "'$status'",
            "context": "github-actions/build"
            }'
 

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow