Tunix Package Tests workflow (google/tunix)
The Tunix Package Tests workflow from google/tunix, 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.
What it does
This is the Tunix Package Tests workflow from the google/tunix 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)
# Copyright 2025 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow will build tunix python package and run tests.
name: Tunix Package Tests
# Trigger the workflow only when code is merging to the 'main' branch.
on:
pull_request: # Automatically trigger on pull requests affecting this file
branches:
- main
workflow_dispatch:
schedule:
# Run the job every 4 hours
- cron: '0 */4 * * *'
concurrency:
# Dedup pull requests (canceling previous runs of the same workflow for same PR), and scheduled runs but nothing else
group: >
${{
github.event_name == 'pull_request' && format('{0}-pr-{1}', github.workflow, github.event.pull_request.number) ||
github.event_name == 'schedule' && format('{0}-schedule', github.workflow) ||
github.run_id
}}
cancel-in-progress: true
permissions:
contents: read
jobs:
build_tunix_package:
name: Build tunix package
uses: ./.github/workflows/build_package.yml
tunix_cpu_unit_tests:
needs: build_tunix_package
uses: ./.github/workflows/cpu-tests.yml
tunix_tpu_unit_tests:
needs: build_tunix_package
uses: ./.github/workflows/tpu-tests.yml
secrets:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
notify_failure:
name: Notify failed build # creates an issue or modifies last open existing issue for failed build
needs: [build_tunix_package,tunix_cpu_unit_tests, tunix_tpu_unit_tests]
if: ${{ always() }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Check whether one of the jobs failed
if: ${{ contains(needs.*.result, 'failure') && github.event.pull_request == null && github.event_name != 'workflow_dispatch' }}
uses: jayqi/failed-build-issue-action@1a893bbf43ef1c2a8705e2b115cd4f0fe3c5649b # v1.2.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
# Copyright 2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This workflow will build tunix python package and run tests. name: Tunix Package Tests # Trigger the workflow only when code is merging to the 'main' branch. on: pull_request: # Automatically trigger on pull requests affecting this file branches: - main workflow_dispatch: schedule: # Run the job every 4 hours - cron: '0 */4 * * *' concurrency: # Dedup pull requests (canceling previous runs of the same workflow for same PR), and scheduled runs but nothing else group: > ${{ github.event_name == 'pull_request' && format('{0}-pr-{1}', github.workflow, github.event.pull_request.number) || github.event_name == 'schedule' && format('{0}-schedule', github.workflow) || github.run_id }} cancel-in-progress: true permissions: contents: read jobs: build_tunix_package: timeout-minutes: 30 name: Build tunix package uses: ./.github/workflows/build_package.yml tunix_cpu_unit_tests: timeout-minutes: 30 needs: build_tunix_package uses: ./.github/workflows/cpu-tests.yml tunix_tpu_unit_tests: timeout-minutes: 30 needs: build_tunix_package uses: ./.github/workflows/tpu-tests.yml secrets: HF_TOKEN: ${{ secrets.HF_TOKEN }} KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }} KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }} notify_failure: timeout-minutes: 30 name: Notify failed build # creates an issue or modifies last open existing issue for failed build needs: [build_tunix_package,tunix_cpu_unit_tests, tunix_tpu_unit_tests] if: ${{ always() }} runs-on: latchkey-small permissions: issues: write steps: - name: Check whether one of the jobs failed if: ${{ contains(needs.*.result, 'failure') && github.event.pull_request == null && github.event_name != 'workflow_dispatch' }} uses: jayqi/failed-build-issue-action@1a893bbf43ef1c2a8705e2b115cd4f0fe3c5649b # v1.2.0 with: github-token: ${{ secrets.GITHUB_TOKEN }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.