From 5204a17bcfae5a32ac3496bf62a1a75a94d2974d Mon Sep 17 00:00:00 2001 From: mhucka Date: Mon, 20 Jan 2025 16:04:27 +0000 Subject: [PATCH 1/4] Add workflow for nightly full test This workflow does a plain TFQ build & test. It's scheduled to run every night. Its purpose is 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. --- .github/workflows/ci-nightly-check.yaml | 116 ++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/ci-nightly-check.yaml diff --git a/.github/workflows/ci-nightly-check.yaml b/.github/workflows/ci-nightly-check.yaml new file mode 100644 index 000000000..f20d841b4 --- /dev/null +++ b/.github/workflows/ci-nightly-check.yaml @@ -0,0 +1,116 @@ +# 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. +# +# This workflow also can be invoked manually via the "Run workflow" button at +# https://github.com/tensorflow/quantum/actions/workflows/ci-build-checks.yaml +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +name: CI nightly test +run-name: Continuous integration nightly build & test + +on: + schedule: + - cron: "15 6 * * *" + + workflow_dispatch: + inputs: + py_version: + description: "Python version:" + type: string + default: "3.10.15" + + save_artifacts: + description: Make Bazel build outputs downloadable + type: boolean + default: true + +env: + # Default Python version to use. + py_version: "3.10.15" + + # Additional .bazelrc options to use. + bazelrc_additions: | + common --announce_rc + build --subcommands + build --auto_output_filter=none + build --show_progress_rate_limit=1 + build --verbose_failures + test --test_output=errors + test --test_summary=detailed + test --test_timeout=6000 + test --test_verbose_timeout_warnings + +concurrency: + # Cancel any previously-started but still active runs on the same branch. + cancel-in-progress: true + group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}} + +jobs: + Nightly: + name: Build and test + runs-on: ubuntu-20.04 + steps: + - name: Check out a copy of the TFQ git repository + uses: actions/checkout@v4 + + - name: Set up Python ${{inputs.py_version || env.py_version}} + uses: actions/setup-python@v5 + with: + python-version: ${{inputs.py_version || env.py_version}} + + - name: Set up Bazel + uses: bazel-contrib/setup-bazel@0.9.1 + with: + bazelrc: ${{env.bazelrc_additions}} + + - 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 + + - name: Test wheel + run: | + set -x + ./scripts/run_example.sh + + - name: Test rest of TFQ + run: | + set -x -o pipefail + ./scripts/test_all.sh 2>&1 | tee test_all.log + + - 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 + + - if: failure() || inputs.save_artifacts == 'true' + name: Make artifacts downloadable + uses: actions/upload-artifact@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 + !/home/runner/.bazel/execroot/__main__/bazel-out/**/_objs + !/home/runner/.bazel/execroot/__main__/bazel-out/**/_solib_k8 From 04e0b837c31604759e2e122948d58cc996f7eead Mon Sep 17 00:00:00 2001 From: mhucka Date: Mon, 20 Jan 2025 22:16:46 +0000 Subject: [PATCH 2/4] Shorten title of a checkbox in workflow_dispatch Avoid wrapping the line in the GUI --- .github/workflows/ci-nightly-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-nightly-check.yaml b/.github/workflows/ci-nightly-check.yaml index f20d841b4..277e1c6e3 100644 --- a/.github/workflows/ci-nightly-check.yaml +++ b/.github/workflows/ci-nightly-check.yaml @@ -26,7 +26,7 @@ on: default: "3.10.15" save_artifacts: - description: Make Bazel build outputs downloadable + description: Make Bazel artifacts downloadable type: boolean default: true From ff7acaf0306e4a2e76d515b261f8cad836c4523a Mon Sep 17 00:00:00 2001 From: mhucka Date: Tue, 21 Jan 2025 00:27:40 +0000 Subject: [PATCH 3/4] Rename file to be more consistent with Cirq test file This is just an effort to have some regularity in the file names. --- .../{ci-nightly-check.yaml => ci-nightly-build-test.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci-nightly-check.yaml => ci-nightly-build-test.yaml} (100%) diff --git a/.github/workflows/ci-nightly-check.yaml b/.github/workflows/ci-nightly-build-test.yaml similarity index 100% rename from .github/workflows/ci-nightly-check.yaml rename to .github/workflows/ci-nightly-build-test.yaml From d8420a03f224f33fa9a8d2e416b55b71cc50a76e Mon Sep 17 00:00:00 2001 From: mhucka Date: Tue, 21 Jan 2025 01:27:02 +0000 Subject: [PATCH 4/4] Add condition of having > 0 commits in past 24hrs If there have been no changes in the past 24 hours, then it's pointless to run this full build and test. We can save resources by skipping it. --- .github/workflows/ci-nightly-build-test.yaml | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/ci-nightly-build-test.yaml b/.github/workflows/ci-nightly-build-test.yaml index 277e1c6e3..f8af19714 100644 --- a/.github/workflows/ci-nightly-build-test.yaml +++ b/.github/workflows/ci-nightly-build-test.yaml @@ -7,6 +7,9 @@ # failures that might be missed when skipping the long-running tests or using # caching to speed up the 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 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -52,8 +55,27 @@ concurrency: group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}} jobs: + Decision: + runs-on: ubuntu-24.04 + outputs: + run: ${{steps.commits.outputs.count > 0}} + steps: + - name: Check out a sparse copy of the git repo for TFQ + uses: actions/checkout@v4 + 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' name: Build and test + needs: Decision runs-on: ubuntu-20.04 steps: - name: Check out a copy of the TFQ git repository