Run CI checks for pull_request on 33/merge by @mhucka #230
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 2021 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 | |
| # | |
| # http://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 CI checks for ${{github.event_name}} on ${{github.ref_name}} by | |
| @${{github.actor}} ${{github.ref == 'refs/heads/main' && 'and make new dev release' || ''}} | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v* | |
| merge_group: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| debug: | |
| description: 'Run with debugging options' | |
| type: boolean | |
| default: true | |
| upload_to_pypi: | |
| description: 'Upload dev release to PyPI' | |
| type: boolean | |
| default: false | |
| permissions: read-all | |
| concurrency: | |
| cancel-in-progress: true | |
| group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}} | |
| jobs: | |
| build_dist: | |
| runs-on: ${{matrix.os}} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: [ | |
| {os: ubuntu-24.04, dist: cp310-manylinux_x86_64, arch: x86_64}, | |
| {os: ubuntu-24.04, dist: cp311-manylinux_x86_64, arch: x86_64}, | |
| {os: ubuntu-24.04, dist: cp312-manylinux_x86_64, arch: x86_64}, | |
| {os: ubuntu-24.04, dist: cp313-manylinux_x86_64, arch: x86_64}, | |
| {os: ubuntu-24.04, dist: cp314-manylinux_x86_64, arch: x86_64}, | |
| {os: ubuntu-24.04-arm, dist: cp310-manylinux_aarch64, arch: aarch64}, | |
| {os: ubuntu-24.04-arm, dist: cp311-manylinux_aarch64, arch: aarch64}, | |
| {os: ubuntu-24.04-arm, dist: cp312-manylinux_aarch64, arch: aarch64}, | |
| {os: ubuntu-24.04-arm, dist: cp313-manylinux_aarch64, arch: aarch64}, | |
| {os: ubuntu-24.04-arm, dist: cp314-manylinux_aarch64, arch: aarch64}, | |
| {os: macos-14, dist: cp310-macosx_arm64, arch: arm64, target: '11.0'}, | |
| {os: macos-14, dist: cp311-macosx_arm64, arch: arm64, target: '11.0'}, | |
| {os: macos-14, dist: cp312-macosx_arm64, arch: arm64, target: '11.0'}, | |
| {os: macos-14, dist: cp313-macosx_arm64, arch: arm64, target: '11.0'}, | |
| {os: macos-14, dist: cp314-macosx_arm64, arch: arm64, target: '11.0'}, | |
| {os: macos-15-intel, dist: cp310-macosx_x86_64, arch: x86_64, target: '11.0'}, | |
| {os: macos-15-intel, dist: cp311-macosx_x86_64, arch: x86_64, target: '11.0'}, | |
| {os: macos-15-intel, dist: cp312-macosx_x86_64, arch: x86_64, target: '11.0'}, | |
| {os: macos-15-intel, dist: cp313-macosx_x86_64, arch: x86_64, target: '11.0'}, | |
| {os: macos-15-intel, dist: cp314-macosx_x86_64, arch: x86_64, target: '11.0'}, | |
| {os: windows-2025, dist: cp310-win_amd64, arch: AMD64}, | |
| {os: windows-2025, dist: cp311-win_amd64, arch: AMD64}, | |
| {os: windows-2025, dist: cp312-win_amd64, arch: AMD64}, | |
| {os: windows-2025, dist: cp313-win_amd64, arch: AMD64}, | |
| {os: windows-2025, dist: cp314-win_amd64, arch: AMD64}, | |
| ] | |
| env: | |
| MACOSX_DEPLOYMENT_TARGET: ${{matrix.target}} | |
| CIBW_BUILD: ${{matrix.dist}} | |
| CIBW_ARCHS: ${{matrix.arch}} | |
| CIBW_PRERELEASE_PYTHONS: 1 | |
| CIBW_BUILD_VERBOSITY: ${{inputs.debug && 1 || ''}} | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| with: | |
| cache: pip | |
| python-version: '3.11' | |
| - run: python -m pip install cibuildwheel~=3.2.0 setuptools twine | |
| - run: python tools/overwrite_dev_versions_with_date.py | |
| - run: python -m cibuildwheel --print-build-identifiers | |
| - run: python -m cibuildwheel --output-dir dist | |
| - run: twine check ./dist/* | |
| shell: bash | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: "dist-chromobius-${{matrix.os}}-${{matrix.dist}}-${{matrix.arch}}" | |
| path: dist/* | |
| build_sdist: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| with: | |
| cache: pip | |
| python-version: '3.11' | |
| - run: python -m pip install setuptools pybind11~=2.11.1 ninja | |
| - run: python tools/overwrite_dev_versions_with_date.py | |
| - run: python setup.py sdist | |
| # Before going further, test that the result is installable. | |
| - run: pip install dist/*.tar.gz || exit 1 | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: dist-chromobius-sdist | |
| path: dist/*.tar.gz | |
| run_main: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - run: cmake . | |
| - run: make chromobius -j | |
| - run: out/chromobius --help | |
| build_bazel: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # v1 | |
| with: | |
| bazelisk-cache: true | |
| disk-cache: ${{ github.workflow }} | |
| repository-cache: true | |
| bazelisk-version: 1.x | |
| - run: bazel build :all | |
| - run: bazel test :chromobius_test | |
| build_clang: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - run: sudo apt-get update && sudo apt-get install --no-install-recommends -y clang | |
| - run: | | |
| cd .. | |
| git -c advice.detachedHead=false clone https://github.com/google/googletest.git -b release-1.12.1 | |
| mkdir googletest/build && cd googletest/build | |
| cmake .. -DBUILD_GMOCK=OFF | |
| make -j | |
| sudo make install | |
| - run: cmake . -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ | |
| - run: cmake --build . -j --target chromobius chromobius_test chromobius_perf | |
| - run: out/chromobius --help | |
| perf: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - run: cmake . | |
| - run: make chromobius_perf -j | |
| - run: out/chromobius_perf | |
| test: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - run: | | |
| cd .. | |
| git -c advice.detachedHead=false clone https://github.com/google/googletest.git -b release-1.12.1 | |
| mkdir googletest/build && cd googletest/build | |
| cmake .. -DBUILD_GMOCK=OFF | |
| make -j | |
| sudo make install | |
| - run: cmake . | |
| - run: make chromobius_test -j | |
| - run: out/chromobius_test | |
| test_o3: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - run: | | |
| cd .. | |
| git -c advice.detachedHead=false clone https://github.com/google/googletest.git -b release-1.12.1 | |
| mkdir googletest/build && cd googletest/build | |
| cmake .. -DBUILD_GMOCK=OFF | |
| make -j | |
| sudo make install | |
| - run: cmake . -DSIMD_WIDTH=256 | |
| - run: make chromobius_test_o3 -j | |
| - run: out/chromobius_test_o3 | |
| test_generated_docs_are_fresh: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| with: | |
| cache: pip | |
| python-version: '3.11' | |
| - uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # v1 | |
| with: | |
| disk-cache: ${{ github.workflow }} | |
| repository-cache: true | |
| bazelisk-version: 1.x | |
| - run: bazel build :chromobius_dev_wheel | |
| - run: pip install bazel-bin/chromobius-0.0.dev0-py3-none-any.whl | |
| - run: diff <(python tools/gen_chromobius_api_reference.py -dev) doc/chromobius_api_reference.md | |
| - run: diff <(python tools/gen_chromobius_stub_file.py -dev) doc/chromobius.pyi | |
| - run: python doc/chromobius.pyi | |
| test_generated_file_lists_are_fresh: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - run: tools/regen_file_lists.sh /tmp | |
| - run: diff /tmp/perf_files file_lists/perf_files | |
| - run: diff /tmp/pybind_files file_lists/pybind_files | |
| - run: diff /tmp/source_files_no_main file_lists/source_files_no_main | |
| - run: diff /tmp/test_files file_lists/test_files | |
| test_pybind: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| with: | |
| cache: pip | |
| python-version: '3.11' | |
| - uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # v1 | |
| with: | |
| bazelisk-cache: true | |
| disk-cache: ${{ github.workflow }} | |
| repository-cache: true | |
| bazelisk-version: 1.x | |
| - run: bazel build :chromobius_dev_wheel | |
| - run: pip install bazel-bin/chromobius-0.0.dev0-py3-none-any.whl | |
| - run: pip install pytest pytest-xdist stim~=1.15 sinter pygltflib | |
| - run: pytest -n auto src | |
| - run: tools/doctest_proper.py --module chromobius | |
| # The next job verifies that uploading wheels and pip-installing them from | |
| # PyPI servers succeeds. For efficiency, it only tests a subset of wheels. | |
| upload_to_testpypi: | |
| if: ${{github.ref == 'refs/heads/main' && github.repository_owner == 'quantumlib'}} | |
| needs: | |
| - build_bazel | |
| - build_clang | |
| - build_dist | |
| - build_sdist | |
| - run_main | |
| - test | |
| - test_generated_docs_are_fresh | |
| - test_o3 | |
| - test_pybind | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| # Setting these as env. variables lets us override the values when testing locally. | |
| testpypi_endpoint_url: https://test.pypi.org/legacy/ | |
| testpypi_index_url: https://test.pypi.org/simple | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | |
| with: | |
| sparse-checkout: setup.py | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| with: | |
| cache: pip | |
| python-version: '3.11' | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| path: dist-chromobius | |
| # For efficiency, test just one wheel for each platform. | |
| pattern: '*cp311*' | |
| merge-multiple: true | |
| - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1 | |
| with: | |
| repository-url: ${{env.testpypi_endpoint_url}} | |
| packages-dir: dist-chromobius/ | |
| user: ${{secrets.testpypi_user || '__token__'}} | |
| password: ${{secrets.testpypi_password}} | |
| verify-metadata: true | |
| verbose: true | |
| skip-existing: true | |
| attestations: false | |
| # Test that we can install what we released to test.pypi.org. The version | |
| # number code below emulates tools/overwrite_dev_versions_with_date.py | |
| - run: | | |
| set -x | |
| base_version=$(sed -E -n "s/^__version__ = '([0-9]+\.[0-9]+).*'/\1/p" setup.py) | |
| timestamp=$(git show -s --format=%ct HEAD) | |
| version=${base_version}.dev${timestamp} | |
| pip install chromobius=="${version}" --index-url ${{env.testpypi_index_url}} \ | |
| --extra-index-url https://pypi.org/simple | |
| - run: pip list | |
| if: ${{inputs.debug}} | |
| - run: python -c 'import chromobius; print(chromobius.__version__)' | |
| upload_to_pypi: | |
| if: >- | |
| ${{inputs.upload_to_pypi != 'false' | |
| && github.ref == 'refs/heads/main' && github.repository_owner == 'quantumlib'}} | |
| needs: upload_to_testpypi | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| id-token: write | |
| environment: | |
| name: PyPI | |
| url: https://pypi.org/project/chromobius | |
| steps: | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| path: dist-chromobius | |
| pattern: dist-chromobius-* | |
| merge-multiple: true | |
| - run: pwd && ls -lR dist-chromobius | |
| - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1 | |
| with: | |
| packages-dir: dist-chromobius/ | |
| verify-metadata: ${{inputs.debug}} | |
| verbose: ${{inputs.debug}} | |
| skip-existing: true |