reshuffle #1717
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Gate | |
# This pipeline is the minimum bar a PR must pass before it can be merged. | |
# It is intended to be fast and lightweight to trigger automatically on every | |
# change in every PR and provide quick feedback without overloading the CI. | |
# Requirements for all jobs in this workflow: | |
# - A new job must cancel a previously scheduled/running job. | |
# PRs only care about the latest commit and multiple pushes may happen in quick succession. | |
# - End-to-end (excluding wait times for runners) must be less than 5mins. | |
# This includes the cost of checking out the code, preparing a runner, etc. | |
# - Individual test cases must be less than 1s. | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- afuller/tests-shift-left | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
branches: | |
- "main" | |
concurrency: | |
# Use github.run_id on main branch (or any protected branch) | |
# This ensure that no runs get cancelled on main | |
# Use github.event.pull_request.number on pull requests, so it's unique per pull request | |
# and will cancel obsolete runs | |
# Use github.ref on other branches, so it's unique per branch | |
# Possibly PRs can also just use `github.ref`, but for now just copy/pasting from | |
# https://www.meziantou.net/how-to-cancel-github-workflows-when-pushing-new-commits-on-a-branch.htm | |
group: ${{ github.workflow }}-${{ github.ref_protected && github.run_id || github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
pr-gate-build: | |
name: Build | |
if: github.event_name != 'pull_request' || !github.event.pull_request.draft | |
uses: ./.github/workflows/build-artifact.yaml | |
with: | |
version: "22.04" | |
metal-tests: | |
needs: pr-gate-build | |
runs-on: | |
- in-service | |
- cloud-virtual-machine | |
- BH | |
container: | |
image: ${{ needs.pr-gate-build.outputs.ci-build-docker-image || 'docker image unresolved!'}} | |
volumes: | |
- /work | |
- /dev/hugepages-1G:/dev/hugepages-1G | |
options: --device /dev/tenstorrent | |
defaults: | |
run: | |
shell: bash | |
working-directory: /work # https://github.com/actions/runner/issues/878 | |
steps: | |
- name: workaround | |
run: | | |
# The test-reporting action needs this set, and we can't seem to opt out of it. | |
git config --global --add safe.directory /__w/tt-metal/tt-metal | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.pr-gate-build.outputs.packages-artifact-name || 'packages artifact unresolved!' }} | |
path: /work/pkgs/ | |
- name: Install packages | |
run: | | |
apt install ./pkgs/tt-metalium_*.deb ./pkgs/tt-metalium-jit_*.deb ./pkgs/tt-metalium-validation_*.deb | |
- name: Run a test | |
id: test | |
timeout-minutes: 15 | |
env: | |
GTEST_COLOR: yes | |
GTEST_OUTPUT: xml:/work/test-reports/ | |
TT_METAL_HOME: /usr/libexec/tt-metalium # TODO: Need to get away from env vars! | |
# TT_METAL_SLOW_DISPATCH_MODE: true # TODO: burn this with fire | |
run: | | |
# FIXME: Make a single executable to gather up all tests within this scope | |
# /usr/libexec/tt-metalium/validation/unit_tests_device | |
/usr/libexec/tt-metalium/validation/tt-metalium-validation-smoke | |
/usr/libexec/tt-metalium/validation/unit_tests_stl | |
- name: Test Report | |
uses: phoenix-actions/test-reporting@v15 | |
if: ${{ !cancelled() }} | |
with: | |
name: Test Report | |
path: /work/test-reports/*.xml | |
reporter: jest-junit | |
- name: Check for slow tests | |
shell: python3 {0} | |
run: | | |
import os | |
import xml.etree.ElementTree as ET | |
import sys | |
# Find all XML files in the /work/test-reports directory | |
report_files = [os.path.join(root, file) for root, dirs, files in os.walk("/work/test-reports/") for file in files if file.endswith(".xml")] | |
if not report_files: | |
print("No test reports found.") | |
sys.exit(1) | |
slow_tests = [] | |
for report_file in report_files: | |
try: | |
tree = ET.parse(report_file) | |
root = tree.getroot() | |
for tc in root.findall(".//testcase"): | |
time = float(tc.get("time", 0)) | |
if time > 1.5: | |
slow_tests.append(f"{report_file}: {tc.get('classname', 'Unknown')}.{tc.get('name', 'Unknown')} ({time:.3f}s)") | |
except Exception as e: | |
print(f"Error parsing {report_file}: {e}") | |
sys.exit(2) | |
if slow_tests: | |
print("Some tests exceeded 1.5s:\n" + "\n".join(slow_tests)) | |
sys.exit(3) |