Run nightly Pytest #1
This file contains hidden or 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
| # 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. | |
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| # Reusable workflow called by nightly.yaml. | |
| # This workflow expects input values passed by nightly.yml. | |
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| name: 'Nightly tests & scans – Pytest matrix' | |
| run-name: Run nightly Pytest | |
| on: | |
| workflow_call: | |
| inputs: | |
| # CLI argument string to pass to pytest. | |
| args: | |
| type: string | |
| required: false | |
| # Why is this workflow being called? | |
| reason: | |
| type: string | |
| required: false | |
| # Allow manual invocation. | |
| workflow_dispatch: | |
| # Declare default permissions as read only. | |
| permissions: read-all | |
| jobs: | |
| Pytest: | |
| # Try to fit as much info as possible into the GHA sidebar at run-time. | |
| name: Py ${{matrix.python-version}} + ${{matrix.os}}/${{matrix.arch}} | |
| runs-on: ${{matrix.os}} | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # 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] | |
| arch: [x64, arm64] | |
| exclude: | |
| # 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 | |
| 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 | |
| arch: arm64 | |
| python-version: 3.12.7 | |
| steps: | |
| - name: Check out a copy of the OpenFermion git repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Set up Python ${{matrix.python-version}} | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| id: cache | |
| with: | |
| python-version: ${{matrix.python-version}} | |
| architecture: ${{matrix.arch}} | |
| cache: pip | |
| 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::' | |
| - name: Install cirq-core (current stable version) | |
| 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 |