Skip to content

Add a job to CI workflow to print debug info if any job fails #1092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ jobs:
if: needs.changes.outputs.python == 'true'
name: (Python pytest matrix)
needs: [changes, setup]
runs-on: ${{ matrix.os }}
runs-on: ${{matrix.os}}
timeout-minutes: 15
strategy:
matrix:
Expand Down Expand Up @@ -594,3 +594,52 @@ jobs:
permissions: write-all
with:
reason: CI

print-debugging-info:
if: failure()
name: Print debugging info upon job failure
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Check out a copy of the git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Set up Python with caching of pip dependencies
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
architecture: 'x64'
cache: pip
cache-dependency-path: ${{env.python_dep_files}}

- name: Print contextual info
shell: bash
run: |
pwd
printf '%.s─' $(seq 1 ${COLUMNS:-$(tput cols)})
echo "The job_id is: $GITHUB_JOB"
echo "The id of this action is: $GITHUB_ACTION"
echo "The run id is: $GITHUB_RUN_ID"
echo "GitHub SHA: $GITHUB_SHA"
printf '%.s─' $(seq 1 ${COLUMNS:-$(tput cols)})
ls -la

- name: Print Python package versions
shell: bash
run: pip list

- name: Dump environment variables
shell: bash
run: env

- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{toJson(github)}}
shell: bash
run: echo "$GITHUB_CONTEXT"

- name: Dump runner context
env:
RUNNER_CONTEXT: ${{toJson(runner)}}
shell: bash
run: echo "${RUNNER_CONTEXT}"
71 changes: 47 additions & 24 deletions .github/workflows/nightly-pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ on:
# Allow manual invocation.
workflow_dispatch:

# Declare default permissions as read only.
# Declare default workflow permissions as read only.
permissions: read-all

jobs:
Expand All @@ -50,30 +50,27 @@ jobs:
# These Python versions were carefully selected by trial and error
# to be available on as many os/arch combos as possible, while also
# making all necessary Python dependencies available on those combos.
# TODO: add '3.13.1' once Cirq 1.5 is released.
python-version: ['3.10.11', '3.11.9', '3.12.7']
os: [ubuntu-22.04, ubuntu-22.04-arm, macos-14, windows-2022]
python-version: ['3.11.9', '3.12.7', '3.13.1']
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, macos-14, windows-2025]
arch: [x64, arm64]
exclude:
- os: ubuntu-24.04
arch: arm64

- os: ubuntu-24.04-arm
arch: x64

# MacOS 14 is only available for arm64.
- os: macos-14
arch: x64

# Windows is only available for x64.
- os: windows-2022
arch: arm64

# GitHub provides separate Ubuntu runners for ARM and x64.
# We have to exclude the incompatible combinations.
- os: ubuntu-22.04-arm
# MacOS 15 is only available for arm64.
- os: macos-15
arch: x64
- os: ubuntu-22.04
arch: arm64

# 2025-01-31 dependency h5py fails to build on this combo (only).
- os: ubuntu-22.04-arm
# Windows 2025 is only available for x64.
- os: windows-2025
arch: arm64
python-version: 3.12.7

steps:
- name: Check out a copy of the OpenFermion git repository
Expand All @@ -89,19 +86,45 @@ jobs:
cache-dependency-path: dev_tools/requirements/envs/pytest.env.txt

- name: Install OpenFermion Python requirements
run: |
pip install -r dev_tools/requirements/envs/pytest.env.txt
echo '::group::List of installed pip packages and their versions'
pip list
echo '::endgroup::'
run: pip install -r dev_tools/requirements/envs/pytest.env.txt

- name: Install cirq-core (current stable version)
run: |
pip install -U cirq-core ${{inputs.args}}
run: pip install -U cirq-core ${{inputs.args}}

- name: Set up Pytest output problem matcher
run: echo '::add-matcher::.github/problem-matchers/pytest.json'

- name: Run Pytest
run: check/pytest

- name: Print debugging info upon job failure
if: failure()
shell: bash
env:
GITHUB_CONTEXT: ${{toJson(github)}}
RUNNER_CONTEXT: ${{toJson(runner)}}
MATRIX_CONTEXT: ${{toJson(matrix)}}
STRATEGY_CONTEXT: ${{toJson(strategy)}}
run: |
check/pytest
echo '::group:: Shell environment'
env
echo '::endgroup::'
echo '::group:: Installed Python packages'
pip list
echo '::endgroup::'
echo '::group:: GitHub context'
echo "The job_id is: $GITHUB_JOB"
echo "The id of this action is: $GITHUB_ACTION"
echo "The run id is: $GITHUB_RUN_ID"
echo "GitHub SHA: $GITHUB_SHA"
echo "$GITHUB_CONTEXT"
echo '::endgroup::'
echo '::group:: GitHub runner context'
echo "$RUNNER_CONTEXT"
echo '::endgroup::'
echo '::group:: Matrix context'
echo "$MATRIX_CONTEXT"
echo '::endgroup::'
echo '::group:: Strategy context'
echo "$STRATEGY_CONTEXT"
echo '::endgroup::'
Loading