|
1 |
| -name: Cirq Compatibility |
| 1 | +# Copyright 2024 The TensorFlow Quantum Authors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 16 | +# Summary: GitHub CI workflow for testing TFQ against Cirq releases |
| 17 | +# |
| 18 | +# This workflow is executed every night on a schedule. By default, this |
| 19 | +# workflow will save Bazel build artifacts if an error occurs during a run. |
| 20 | +# |
| 21 | +# For testing, this workflow can be invoked manually from the GitHub page at |
| 22 | +# https://github.com/tensorflow/quantum/actions/workflows/cirq_compatibility.yaml |
| 23 | +# Clicking the "Run workflow" button there will present a form interface with |
| 24 | +# options for overridding some of the parameters for the run. |
| 25 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 26 | + |
| 27 | +name: Cirq compatibility tests |
| 28 | + |
| 29 | +# Default values. These can be overridden when workflow dispatch is used. |
| 30 | +env: |
| 31 | + # Python version to test against. |
| 32 | + py_version: '3.10' |
| 33 | + # Bazel version. Note: this needs to match what is used in TF & TFQ. |
| 34 | + bazel_version: 6.5.0 |
| 35 | + # Machine architecture. |
| 36 | + arch: x64 |
| 37 | + # Additional .bazelrc options to use. |
| 38 | + bazelrc_additions: | |
| 39 | + common --announce_rc |
| 40 | + build --verbose_failures |
| 41 | + test --test_timeout=3000 |
2 | 42 |
|
3 | 43 | on:
|
| 44 | + # Nightly runs. |
4 | 45 | schedule:
|
5 |
| - - cron: "0 0 * * *" |
| 46 | + - cron: 0 0 * * * |
| 47 | + # Manual on-demand invocations. |
| 48 | + workflow_dispatch: |
| 49 | + inputs: |
| 50 | + py_version: |
| 51 | + description: Version of Python to use |
| 52 | + bazel_version: |
| 53 | + description: Version of Bazel Python to use |
| 54 | + arch: |
| 55 | + description: Computer architecture to use |
| 56 | + use_bazel_disk_cache: |
| 57 | + description: Use Bazel disk_cache between runs? |
| 58 | + type: boolean |
| 59 | + default: true |
| 60 | + cache_bazel_tests: |
| 61 | + description: Allow Bazel to cache test results? |
| 62 | + type: boolean |
| 63 | + default: true |
| 64 | + save_artifacts: |
| 65 | + description: Make Bazel build outputs downloadable? |
| 66 | + type: boolean |
| 67 | + default: true |
6 | 68 |
|
7 | 69 | jobs:
|
8 |
| - consistency: |
9 |
| - name: Nightly Compatibility |
10 |
| - runs-on: ubuntu-16.04 |
| 70 | + test-compatibility: |
| 71 | + name: Run TFQ tests |
| 72 | + runs-on: ubuntu-20.04 |
11 | 73 | steps:
|
12 |
| - - uses: actions/checkout@v1 |
13 |
| - - uses: actions/setup-python@v1 |
| 74 | + - name: Check out a copy of the TFQ git repository |
| 75 | + uses: actions/checkout@v4 |
| 76 | + |
| 77 | + - name: Set up Python |
| 78 | + id: python |
| 79 | + uses: actions/setup-python@v5 |
| 80 | + with: |
| 81 | + python-version: ${{github.event.inputs.py_version || env.py_version}} |
| 82 | + architecture: ${{github.event.inputs.arch || env.arch}} |
| 83 | + cache: pip |
| 84 | + |
| 85 | + - name: Install TensorFlow Quantum dependencies |
| 86 | + run: | |
| 87 | + pip install --upgrade pip setuptools wheel |
| 88 | + pip install -r requirements.txt |
| 89 | +
|
| 90 | + - name: Install the nightly build version of Cirq |
| 91 | + run: | |
| 92 | + pip install -U cirq --pre |
| 93 | +
|
| 94 | + - name: Configure Bazel options |
| 95 | + run: | |
| 96 | + # If we didn't get a cache hit on the installed Python environment, |
| 97 | + # something's changed, and we want to make sure to re-run all tests. |
| 98 | + if [[ "${{steps.python.outputs.cache-hit}}" == "true" |
| 99 | + && "${{github.event.inputs.cache_bazel_tests}}" != "false" ]]; then |
| 100 | + echo "cache_bazel_tests=auto" >> "$GITHUB_ENV" |
| 101 | + else |
| 102 | + echo "cache_bazel_tests=no" >> "$GITHUB_ENV" |
| 103 | + fi |
| 104 | + # Use the disk cache unless told not to. |
| 105 | + if [[ "${{github.event.inputs.use_bazel_disk_cache}}" != "false" ]]; then |
| 106 | + echo "use_bazel_disk_cache=true" >> "$GITHUB_ENV" |
| 107 | + else |
| 108 | + echo "use_bazel_disk_cache=false" >> "$GITHUB_ENV" |
| 109 | + fi |
| 110 | +
|
| 111 | + - name: Set up Bazel with caching |
| 112 | + if: env.use_bazel_disk_cache == 'true' |
| 113 | + uses: bazel-contrib/[email protected] |
| 114 | + env: |
| 115 | + USE_BAZEL_VERSION: ${{github.event.inputs.bazel_version || env.bazel_version}} |
| 116 | + with: |
| 117 | + disk-cache: ${{github.workflow}} |
| 118 | + bazelisk-cache: true |
| 119 | + external-cache: true |
| 120 | + repository-cache: true |
| 121 | + bazelrc: | |
| 122 | + ${{env.bazelrc_additions}} |
| 123 | + test --cache_test_results=${{env.cache_bazel_tests}} |
| 124 | +
|
| 125 | + - name: Set up Bazel without caching |
| 126 | + if: env.use_bazel_disk_cache == 'false' |
| 127 | + uses: bazel-contrib/[email protected] |
| 128 | + env: |
| 129 | + USE_BAZEL_VERSION: ${{github.event.inputs.bazel_version || env.bazel_version}} |
| 130 | + with: |
| 131 | + bazelrc: | |
| 132 | + ${{env.bazelrc_additions}} |
| 133 | + test --cache_test_results=${{env.cache_bazel_tests}} |
| 134 | +
|
| 135 | + - name: Configure TFQ |
| 136 | + run: | |
| 137 | + set -x -e |
| 138 | + # Save information to the run log, in case it's needed for debugging. |
| 139 | + which python |
| 140 | + python --version |
| 141 | + python -c 'import site; print(site.getsitepackages())' |
| 142 | + python -c 'import tensorflow; print(tensorflow.version.VERSION)' |
| 143 | + python -c 'import cirq; print(cirq.__version__)' |
| 144 | + # Run the TFQ configuration script. |
| 145 | + printf "Y\n" | ./configure.sh |
| 146 | +
|
| 147 | + - name: Run TFQ tests |
| 148 | + # TODO: when the msan tests are working again, replace the "touch" |
| 149 | + # line with ./scripts/msan_test.sh 2>&1 | tee msan-tests-output.log |
| 150 | + run: | |
| 151 | + set -x -e |
| 152 | + ./scripts/test_all.sh 2>&1 | tee main-tests-output.log |
| 153 | + touch msan-tests-output.log |
| 154 | +
|
| 155 | + - name: Make Bazel artifacts downloadable (if desired) |
| 156 | + if: >- |
| 157 | + github.event.inputs.save_artifacts == 'true' |
| 158 | + && (failure() || github.event_name == 'workflow_dispatch') |
| 159 | + uses: actions/upload-artifact@v4 |
14 | 160 | with:
|
15 |
| - python-version: '3.8' |
16 |
| - architecture: 'x64' |
17 |
| - - name: Install Bazel on CI |
18 |
| - run: ./scripts/ci_install.sh |
19 |
| - - name: Configure CI TF |
20 |
| - run: echo "Y\n" | ./configure.sh |
21 |
| - - name: Install Cirq nightly |
22 |
| - run: pip install -U cirq --pre |
23 |
| - - name: Nightly tests |
24 |
| - run: ./scripts/test_all.sh |
| 161 | + name: bazel-out |
| 162 | + retention-days: 7 |
| 163 | + include-hidden-files: true |
| 164 | + path: | |
| 165 | + main-tests-output.log |
| 166 | + msan-tests-output.log |
| 167 | + /home/runner/.bazel/execroot/__main__/bazel-out/ |
| 168 | + !/home/runner/.bazel/execroot/__main__/bazel-out/**/*.so |
| 169 | + !/home/runner/.bazel/execroot/__main__/bazel-out/**/*.o |
| 170 | + !/home/runner/.bazel/execroot/__main__/bazel-out/**/_objs |
| 171 | + !/home/runner/.bazel/execroot/__main__/bazel-out/**/_solib_k8 |
0 commit comments