Run continuous integration tests on push to gh-readonly-queue/main/pr-1360-e6af37852c9bf0391ceeb107620bc4c60f0b9430 by @mhucka #1041
Workflow file for this run
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. | |
| name: CI | |
| run-name: >- | |
| Run continuous integration tests on | |
| ${{github.event_name == 'pull_request' && format('PR #{0}', github.event.pull_request.number) | |
| || format('push to {0}', github.ref_name) }} | |
| by @${{github.actor}} | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize] | |
| branches: | |
| - main | |
| merge_group: | |
| types: | |
| - checks_requested | |
| workflow_dispatch: | |
| env: | |
| # Default Python version to use. Make sure to use full x.y.z number. | |
| python-version: '3.12.8' | |
| # Oldest Python version to use, for max_compat tests. | |
| python-compat-version: '3.11.9' | |
| # Files listing dependencies we install using pip in the various jobs below. | |
| # This is used by setup-python to check whether its cache needs updating. | |
| python-dep-files: >- | |
| dev_tools/requirements/envs/format.env.txt | |
| dev_tools/requirements/envs/mypy.env.txt | |
| dev_tools/requirements/envs/pylint.env.txt | |
| dev_tools/requirements/envs/pytest-extra.env.txt | |
| dev_tools/requirements/envs/pytest.env.txt | |
| dev_tools/requirements/max_compat/pytest-max-compat.env.txt | |
| concurrency: | |
| cancel-in-progress: true | |
| group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}} | |
| permissions: read-all | |
| jobs: | |
| python-checks: | |
| name: Python file checks | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python and restore cache | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{env.python-version}} | |
| cache: pip | |
| cache-dependency-path: ${{env.python-dep-files}} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install requirements | |
| run: | | |
| pip install -r dev_tools/requirements/envs/format.env.txt | |
| pip install -r dev_tools/requirements/envs/pylint.env.txt | |
| pip install -r dev_tools/requirements/envs/mypy.env.txt | |
| - name: Check format | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/black.json' | |
| check/format-incremental | |
| - name: Check lint | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/pylint.json' | |
| check/pylint -j 0 | |
| - name: Check type declarations | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/mypy.json' | |
| check/mypy | |
| pytest: | |
| name: Unit tests | |
| needs: python-checks | |
| runs-on: ${{matrix.os}} | |
| timeout-minutes: 15 | |
| strategy: | |
| matrix: | |
| os: [ ubuntu-24.04, macos-14, macos-15, windows-2022 ] | |
| fail-fast: false | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Set up Python and restore cache | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{env.python-version}} | |
| cache: pip | |
| cache-dependency-path: ${{env.python-dep-files}} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install requirements | |
| run: | | |
| pip install -r dev_tools/requirements/envs/pytest.env.txt | |
| - name: Run pytest | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/pytest.json' | |
| check/pytest -n auto -m "not slow" | |
| pytest-extra: | |
| name: Extra unit tests | |
| needs: python-checks | |
| runs-on: ${{matrix.os}} | |
| timeout-minutes: 15 | |
| strategy: | |
| matrix: | |
| os: [ubuntu-24.04, macos-14] | |
| fail-fast: false | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Set up Python and restore cache | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{env.python-version}} | |
| cache: pip | |
| cache-dependency-path: ${{env.python-dep-files}} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install requirements | |
| run: | | |
| pip install -r dev_tools/requirements/envs/pytest-extra.env.txt | |
| - name: Run pytest | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/pytest.json' | |
| check/pytest -n auto -m "not slow" src/openfermion/resource_estimates | |
| pytest-compat: | |
| name: Python compatibility tests | |
| needs: python-checks | |
| # Note: this is deliberately Ubuntu 22 because this is a compatibility test. | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| # Note: deliberately not using our Python cache here b/c this runs | |
| # a different version of Python. | |
| - name: Set up Python | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{env.python-compat-version}} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install requirements | |
| run: pip install -r dev_tools/requirements/max_compat/pytest-max-compat.env.txt | |
| - name: Run pytest | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/pytest.json' | |
| check/pytest -n auto -m "not slow" | |
| coverage: | |
| name: Python code coverage tests | |
| needs: python-checks | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python and restore cache | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{env.python-version}} | |
| cache: pip | |
| cache-dependency-path: ${{env.python-dep-files}} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install requirements | |
| run: pip install -r dev_tools/requirements/envs/pytest.env.txt | |
| - name: Run code coverage tests | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/pytest.json' | |
| check/pytest-and-incremental-coverage | |
| yaml-lint: | |
| name: YAML lint checks | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Install yamllint | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install --no-install-recommends -y yamllint | |
| - name: Run yamllint | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/yamllint.json' | |
| yamllint -f github . CITATION.cff | |
| docker-lint: | |
| name: Dockerfile lint checks | |
| if: github.repository_owner == 'quantumlib' | |
| # ubuntu-slim runners don't have docker installed. | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Run hadolint on Dockerfiles | |
| env: | |
| sha: 'sha256:e9dbf5113239ef2bf696d20c8f28d3019a47c26a38c98b89344d3e2846c4d5f8' | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/hadolint.json' | |
| shopt -s globstar | |
| files=(**/[Dd]ockerfile*) | |
| if [[ ${#files[@]} -gt 0 ]]; then | |
| docker run --rm -v "${PWD}:/app" -w /app \ | |
| ghcr.io/hadolint/hadolint@${{env.sha}} /bin/hadolint "${files[@]}" | |
| fi | |
| workflow-lint: | |
| name: GitHub workflow lint checks | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Run actionlint | |
| uses: raven-actions/actionlint@205b530c5d9fa8f44ae9ed59f341a0db994aa6f8 # v2.1.2 | |
| with: | |
| flags: ${{runner.debug && '-verbose'}} | |
| files: '.github/workflows/*.{yaml,yml}' | |
| pyflakes: false | |
| shell-script-lint: | |
| name: Shell script lint checks | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Run shellcheck on shell scripts | |
| run: | | |
| echo '::add-matcher::.github/problem-matchers/shellcheck.json' | |
| check/shellcheck | |
| notebook-checks: | |
| name: Notebook format checks | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Check out a copy of the git repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Set up Python and restore cache | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{env.python-version}} | |
| cache: pip | |
| cache-dependency-path: ${{env.python-dep-files}} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install requirements | |
| run: pip install -r dev_tools/requirements/envs/pytest.env.txt | |
| - name: Check notebook format | |
| run: check/nbformat | |
| report-results: | |
| name: CI | |
| if: always() | |
| needs: | |
| - coverage | |
| - docker-lint | |
| - notebook-checks | |
| - pytest | |
| - pytest-compat | |
| - pytest-extra | |
| - python-checks | |
| - shell-script-lint | |
| - workflow-lint | |
| - yaml-lint | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Report failure (if any occurred) | |
| if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | |
| run: | | |
| { | |
| echo ":x: CI checks failed" | |
| echo "One or more CI jobs failed. Please check the logs for details." | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| exit 1 |