Skip to content

Use larger runners for nightly jobs #324

Use larger runners for nightly jobs

Use larger runners for nightly jobs #324

# Copyright 2025 The TensorFlow Quantum Authors

Check failure on line 1 in .github/workflows/ci-nightly-build-test.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci-nightly-build-test.yaml

Invalid workflow file

(Line: 100, Col: 14): Unexpected symbol: '"linux-x86-n2-32"'. Located at position 18 within expression: inputs.runner || "linux-x86-n2-32"
#
# 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.
# Summary: TFQ nightly full build & test.
#
# 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.
# yamllint disable rule:line-length
name: "Nightly build & test"
run-name: "Nightly full build and test (conditional on recent changes)"
on:
schedule:
- cron: "15 6 * * *"
workflow_dispatch:
inputs:
runner:
description: "GitHub job runner to use:"
default: "linux-x86-n2-32"
py_version:
description: "Python version:"
type: string
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"
# 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
# Equivalent to doing "set -x" in shell scripts.
SHELLOPTS: ${{inputs.debug && 'xtrace'}}
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}}
permissions: read-all
jobs:
check-recent:
name: "(Check for changes)"
runs-on: ubuntu-slim
timeout-minutes: 10
outputs:
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
with:
sparse-checkout: .
- name: Get number of commits in the last 24 hrs
id: commits
run: |
count=$(git log --oneline --since '24 hours ago' | wc -l)
echo "count=$count" >> "$GITHUB_OUTPUT"
nightly:
if: needs.check-recent.outputs.have-changes == 'true'
name: Build and test
needs: check-recent
runs-on: ${{inputs.runner || "linux-x86-n2-32"}}
timeout-minutes: 60
steps:
- name: Check out a copy of the TFQ git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- 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
with:
bazelisk-cache: true
repository-cache: true
bazelrc: ${{env.bazelrc_additions}}
- name: Build wheel
run: ./scripts/build_pip_package_test.sh
- name: Test wheel
run: ./scripts/run_example.sh
- name: Test rest of TFQ
run: ./scripts/test_all.sh
- name: Test tutorials
run: ./scripts/ci_validate_tutorials.sh
- if: failure() || inputs.save_artifacts == 'true'
name: Make artifacts downloadable
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
with:
name: test-artifacts
retention-days: 7
include-hidden-files: true
path: |
/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