Skip to content
Draft
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
95 changes: 42 additions & 53 deletions .github/workflows/ci-nightly-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@

# Summary: TFQ nightly full build & test.
#
# This workflow compiles TFQ and runs all test cases, to verify everything
# works. Unlike the CI checks invoked on PRs and similar events, this workflow
# builds everything without caching and runs the full test suite, including
# "eternal" tests that take a long time to run. It is meant to guard against
# failures that might be missed when skipping the long-running tests or using
# caching to speed up the CI runs.
#
# Unlike the CI checks invoked on PRs and similar events, this workflow builds
# everything without caching and runs the full test suite, including "eternal"
# tests that take a long time to run. It is meant to guard against failures that
# might be missed when skipping long-running tests or using caches in CI runs.
# For efficiency, it checks if there have been any commits in the past 24 hrs
# and does not proceed if there have been none.
#
# This workflow also can be invoked manually via the "Run workflow" button at
# https://github.com/tensorflow/quantum/actions/workflows/ci-build-checks.yaml

# yamllint disable rule:line-length

name: CI nightly full test
run-name: Continuous integration nightly build & test
name: 'Nightly build & test'
run-name: 'Nightly full build and test (conditional on recent changes)'

on:
schedule:
- cron: "15 6 * * *"
- cron: '15 6 * * *'

workflow_dispatch:
inputs:
runner:
description: 'GitHub job runner to use:'
default: linux-x86-n2-32
py_version:
description: "Python version:"
description: 'Python version:'
type: string
default: "3.10.15"

default: '3.10.15'
save_artifacts:
description: Make Bazel artifacts downloadable
type: boolean
default: true
debug:
description: 'Run with debugging options'
type: boolean
default: true

env:
# Default Python version to use.
py_version: "3.10.15"
py_version: '3.10.15'

# Additional .bazelrc options to use.
bazelrc_additions: |
Expand All @@ -72,82 +72,71 @@ concurrency:
permissions: read-all

jobs:
Decision:
runs-on: ubuntu-24.04
check-recent:
name: '(Check for changes)'
runs-on: ubuntu-slim
timeout-minutes: 10
outputs:
run: ${{steps.commits.outputs.count > 0}}
have-changes: ${{steps.commits.outputs.count > 0}}
steps:
- name: Check out a sparse copy of the git repo for TFQ
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
sparse-checkout: .

- name: Get number of commits in the last 24 hrs
id: commits
run: |
set -x
count=$(git log --oneline --since '24 hours ago' | wc -l)
echo "count=$count" >> "$GITHUB_OUTPUT"

Nightly:
if: needs.Decision.outputs.run == 'true'
nightly:
if: needs.check-recent.outputs.have-changes == 'true'
name: Build and test
needs: Decision
runs-on: ubuntu-22.04
needs: check-recent
runs-on: ${{inputs.runner}}
timeout-minutes: 60
steps:
- name: Check out a copy of the TFQ git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

- name: Set up Python ${{inputs.py_version || env.py_version}}
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
with:
python-version: ${{inputs.py_version || env.py_version}}
cache: pip

- name: Set up Bazel
uses: bazel-contrib/setup-bazel@f3f50ea6791b9b0f4c4eeabba4507422426462f5 # 0.9.1
uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # v1
with:
bazelisk-cache: true
repository-cache: true
bazelrc: ${{env.bazelrc_additions}}

- name: Turn on debug tracing
if: inputs.debug || runner.debug
run: set -x

- name: Build wheel
run: |
set -x
pip install --upgrade pip setuptools wheel
# The next script does a pip install, configure, & bazel build.
./scripts/build_pip_package_test.sh
run: ./scripts/build_pip_package_test.sh

- name: Test wheel
run: |
set -x
./scripts/run_example.sh
run: ./scripts/run_example.sh

- name: Test rest of TFQ
run: |
set -x -o pipefail
./scripts/test_all.sh 2>&1 | tee test_all.log
run: ./scripts/test_all.sh

- name: Test tutorials
run: |
set -x -o pipefail
pip install jupyter
pip install nbclient==0.6.5 jupyter-client==6.1.12 ipython==7.22.0
pip install ipykernel==5.1.1
pip install gym==0.24.1
pip install seaborn==0.12.0
pip install -q git+https://github.com/tensorflow/docs
cd ..
python quantum/scripts/test_tutorials.py 2>&1 | \
tee quantum/test_tutorials.log
run: ./scripts/ci_validate_tutorials.sh

- if: failure() || inputs.save_artifacts == 'true'
name: Make artifacts downloadable
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: test-artifacts
retention-days: 7
include-hidden-files: true
path: |
test_all.log
test_tutorials.log
/home/runner/.bazel/execroot/__main__/bazel-out/
!/home/runner/.bazel/execroot/__main__/bazel-out/**/*.so
!/home/runner/.bazel/execroot/__main__/bazel-out/**/*.o
Expand Down
143 changes: 37 additions & 106 deletions .github/workflows/ci-nightly-cirq-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,33 @@
#
# This workflow is executed every night on a schedule. By default, this
# workflow will save Bazel build artifacts if an error occurs during a run.
# For testing, this workflow can be invoked manually from the GitHub page at
# https://github.com/tensorflow/quantum/actions/workflows/ci-nightly-cirq-test.yaml
# Clicking the "Run workflow" button there will present a form interface with
# options for overridding some of the parameters for the run.
# For testing, this workflow can be invoked manually.

# yamllint disable rule:line-length

name: CI nightly Cirq compatibility test
run-name: Continuous integration Cirq compatibility test
name: Nightly Cirq compatibility test
run-name: 'Nightly build and test against latest dev version of Cirq'

on:
schedule:
- cron: "10 7 * * *"
- cron: '10 7 * * *'

# Manual on-demand invocations.
workflow_dispatch:
inputs:
py_version:
description: Version of Python to use
type: string
default: "3.10.15"

bazel_version:
description: Version of Bazel Python to use
type: string

arch:
description: Computer architecture to use
type: string
default: "x64"

use_disk_cache:
description: Use Bazel disk_cache between runs
type: boolean
default: true

use_test_cache:
description: Allow Bazel to cache test results
runner:
description: 'GitHub job runner to use:'
default: linux-x86-n2-32
save_artifacts:
description: 'Make Bazel outputs downloadable:'
type: boolean
default: true

save_artifacts:
description: Make Bazel outputs downloadable
debug:
description: 'Run with debugging options'
type: boolean
default: true

env:
# Default Python version to use.
py_version: "3.10.15"

# Bazel version. Note: this needs to match what is used in TF & TFQ.
bazel_version: 6.5.0

# Machine architecture to use.
arch: x64

# Additional .bazelrc options to use.
bazelrc_additions: |
common --announce_rc
Expand All @@ -87,75 +58,43 @@ permissions: read-all

jobs:
test-compatibility:
name: Run TFQ tests
runs-on: ubuntu-22.04
name: Build and test with latest Cirq
runs-on: ${{inputs.runner}}
timeout-minutes: 60
steps:
- name: Check out a copy of the TFQ git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

- name: Set up Python ${{inputs.py_version || env.py_version}}
id: python
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
with:
python-version: ${{inputs.py_version || env.py_version}}
architecture: ${{inputs.arch || env.arch}}
python-version: '3.10.15'
cache: pip

- name: Set up Bazel
uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # v1
with:
bazelisk-cache: true
repository-cache: true
bazelrc: |
${{env.bazelrc_additions}}
test --cache_test_results=no

- name: Install TensorFlow Quantum dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
run: pip install -r requirements.txt

- name: Turn on debug tracing
if: inputs.debug || runner.debug
run: set -x

- name: Install the nightly build version of Cirq
run: |
echo 'numpy<2.0.0' > constraint.txt
export PIP_CONSTRAINT=constraint.txt
pip install --upgrade cirq~=1.0.dev

- name: Configure Bazel options
run: |
# If we didn't get a cache hit on the installed Python environment,
# something's changed, and we want to make sure to re-run all tests.
if [[ "${{steps.python.outputs.cache-hit}}" == "true"
&& "${{github.event.inputs.use_test_cache}}" != "false" ]]; then
echo "use_test_cache=auto" >> "$GITHUB_ENV"
else
echo "use_test_cache=no" >> "$GITHUB_ENV"
fi
# Use the disk cache unless told not to.
if [[ "${{github.event.inputs.use_disk_cache}}" != "false" ]]; then
echo "use_disk_cache=true" >> "$GITHUB_ENV"
else
echo "use_disk_cache=false" >> "$GITHUB_ENV"
fi

- name: Set up Bazel with caching
if: env.use_bazel_disk_cache == 'true'
uses: bazel-contrib/setup-bazel@529dbc2648ea79358c64f2bfa5f3ec98f07859e4 # 0.12.1
env:
USE_BAZEL_VERSION: ${{inputs.bazel_version || env.bazel_version}}
with:
disk-cache: ${{github.workflow}}
bazelisk-cache: true
external-cache: true
repository-cache: true
bazelrc: |
${{env.bazelrc_additions}}
test --cache_test_results=${{env.use_test_cache}}

- name: Set up Bazel without caching
if: env.use_bazel_disk_cache == 'false'
uses: bazel-contrib/setup-bazel@529dbc2648ea79358c64f2bfa5f3ec98f07859e4 # 0.12.1
env:
USE_BAZEL_VERSION: ${{inputs.bazel_version || env.bazel_version}}
with:
bazelrc: |
${{env.bazelrc_additions}}
test --cache_test_results=${{env.use_test_cache}}

- name: Configure TFQ
run: |
set -x
# Save information to the run log, in case it's needed for debugging.
which python
python --version
Expand All @@ -166,25 +105,17 @@ jobs:
printf "Y\n" | ./configure.sh

- name: Run TFQ tests
# TODO: when the msan tests are working again, replace the "touch"
# line with ./scripts/msan_test.sh 2>&1 | tee msan-tests-output.log
run: |
set -x -o pipefail
./scripts/test_all.sh 2>&1 | tee main-tests-output.log
touch msan-tests-output.log

- name: Make Bazel artifacts downloadable (if desired)
if: >-
github.event.inputs.save_artifacts == 'true'
&& (failure() || github.event_name == 'workflow_dispatch')
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
# TODO: when the msan tests work again, add ./scripts/msan_test.sh.
run: ./scripts/test_all.sh

- if: failure() || inputs.save_artifacts == 'true'
name: Make artifacts downloadable
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: bazel-out
retention-days: 7
include-hidden-files: true
path: |
main-tests-output.log
msan-tests-output.log
/home/runner/.bazel/execroot/__main__/bazel-out/
!/home/runner/.bazel/execroot/__main__/bazel-out/**/*.so
!/home/runner/.bazel/execroot/__main__/bazel-out/**/*.o
Expand Down
Loading