Skip to content

Overhaul GitHub Actions workflows #747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
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
11 changes: 11 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# GitHub Actions workflows

Herea are some notes about the workflows in this directory:

Some workflows are reusable and are meant to called from other workflows
only, not invoked directly. As of mid-2025, GitHub's user interface for
Actions does not provide a way to hide, group, or otherwise distinguish these
kinds of reusable modular workflows from the main workflows. To make these
workflows more apparent in the user interface, we use the convention of
naming these workflows with a leading tilde (`~`) character; this makes them
appear last in the list of workflows on GitHub.
102 changes: 0 additions & 102 deletions .github/workflows/bazeltest.yml

This file was deleted.

132 changes: 132 additions & 0 deletions .github/workflows/ci_build_library.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Copyright 2025 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
#
# 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.

name: 'CI: build & test library and apps'
run-name: Build the library on different platforms and run tests

on:
push:
branches:
- master
- main

pull_request:
types: [opened, synchronize]

merge_group:
types:
- checks_requested

workflow_dispatch:
inputs:
trace:
description: 'Turn on shell script debugging'
type: boolean
default: true

permissions: read-all

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:
find-changes:
name: Find changed files
uses: ./.github/workflows/reusable_find_changes.yaml
secrets: inherit

build-wheels:
# For efficiency, skip this workflow if there were no code file changes.
if: needs.find-changes.outputs.code || github.event_name == 'workflow_dispatch'
name: ${{matrix.conf.os}}/${{matrix.conf.pyarch}}/py3${{matrix.conf.py}}
needs: find-changes
runs-on: ${{matrix.conf.os}}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# See the following page for a list of valid cibuildwheel arch values:
# https://cibuildwheel.pypa.io/en/stable/options/#archs
conf: [
{os: ubuntu-24.04, wh: manylinux, arch: x86_64, pyarch: x64, py: 10},
{os: ubuntu-24.04, wh: manylinux, arch: x86_64, pyarch: x64, py: 11},
{os: ubuntu-24.04, wh: manylinux, arch: x86_64, pyarch: x64, py: 12},
{os: ubuntu-24.04, wh: manylinux, arch: x86_64, pyarch: x64, py: 13},

{os: macos-13, wh: macosx, arch: x86_64, pyarch: x64, py: 10},
{os: macos-13, wh: macosx, arch: x86_64, pyarch: x64, py: 11},
{os: macos-13, wh: macosx, arch: x86_64, pyarch: x64, py: 12},
{os: macos-13, wh: macosx, arch: x86_64, pyarch: x64, py: 13},

{os: macos-14, wh: macosx, arch: arm64, pyarch: arm64, py: 10},
{os: macos-14, wh: macosx, arch: arm64, pyarch: arm64, py: 11},
{os: macos-14, wh: macosx, arch: arm64, pyarch: arm64, py: 12},
{os: macos-14, wh: macosx, arch: arm64, pyarch: arm64, py: 13},

{os: macos-15, wh: macosx, arch: arm64, pyarch: arm64, py: 10},
{os: macos-15, wh: macosx, arch: arm64, pyarch: arm64, py: 11},
{os: macos-15, wh: macosx, arch: arm64, pyarch: arm64, py: 12},
{os: macos-15, wh: macosx, arch: arm64, pyarch: arm64, py: 13},

{os: windows-2022, wh: win, arch: AMD64, pyarch: x64, py: 10},
{os: windows-2022, wh: win, arch: AMD64, pyarch: x64, py: 11},
{os: windows-2022, wh: win, arch: AMD64, pyarch: x64, py: 12},
# This fails with NumPy 1.x. TODO: uncomment when qsim supports np 2.
# {os: windows-2022, wh: win, arch: AMD64, pyarch: x64, py: 13},
]
steps:
- name: Check out a copy of the git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 1

- name: Set up Python with caching of pip dependencies
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
id: setup
with:
python-version: '3.${{matrix.conf.py}}'
architecture: ${{matrix.conf.pyarch}}
cache: pip
cache-dependency-path: requirements.txt

- name: Set up Bazel with caching
uses: bazel-contrib/setup-bazel@8d2cb86a3680a820c3e219597279ce3f80d17a47 # 0.15.0
with:
disk-cache: ${{github.workflow}}
bazelisk-cache: true
external-cache: true
repository-cache: true

- name: Install qsim dependencies
run: pip install -r requirements.txt

- if: matrix.conf.os != 'windows-2022'
name: Run the build and test script (Windows case)
env:
# SHELLOPTS is used by Bash. Add xtrace when doing manual debug runs.
SHELLOPTS: ${{inputs.trace && 'xtrace' || '' }}
run: dev_tools/test_libs.sh --config=verbose

- if: matrix.conf.os == 'windows-2022'
name: Run the build and test script (non-Windows)
env:
pyroot: 'C:\\hostedtoolcache\\windows\\Python'
pyexe: '${{steps.setup.outputs.python-version}}\\${{matrix.conf.pyarch}}\\python3.exe'
SHELLOPTS: ${{inputs.trace && 'xtrace' || '' }}
shell: cmd
run: >-
bash dev_tools/test_libs.sh --config=verbose
--action_env PYTHON_BIN_PATH=${{env.pyroot}}\\${{env.pyexe}}
57 changes: 57 additions & 0 deletions .github/workflows/ci_build_wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2025 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
#
# 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.

name: 'CI: build & verify Python wheels'
run-name: Build Python wheels and verify them

on:
push:
branches:
- master
- main

pull_request:
types: [opened, synchronize]

merge_group:
types:
- checks_requested

workflow_dispatch:
inputs:
trace:
description: 'Turn on shell script debugging'
type: boolean
default: true

permissions: read-all

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:
find-changes:
name: Find changed files
uses: ./.github/workflows/reusable_find_changes.yaml
secrets: inherit

build-wheels:
# For efficiency, skip this workflow if there were no code file changes.
if: needs.find-changes.outputs.code || github.event_name == 'workflow_dispatch'
name: Build & test wheels
needs: find-changes
uses: ./.github/workflows/reusable_build_wheels.yaml
secrets: inherit
85 changes: 85 additions & 0 deletions .github/workflows/ci_docker_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright 2025 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
#
# 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.

name: 'CI: build & test Docker images'
run-name: Build Docker images and test them

on:
push:
branches:
- master
- main

pull_request:
types: [opened, synchronize]

merge_group:
types:
- checks_requested

workflow_dispatch:
inputs:
trace:
description: 'Trace Docker build output'
type: boolean
default: true

permissions: read-all

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:
find-changes:
name: Find changed files
uses: ./.github/workflows/reusable_find_changes.yaml
secrets: inherit

build-and-test:
# For efficiency, skip this workflow if there were no code file changes.
if: needs.find-changes.outputs.code || github.event_name == 'workflow_dispatch'
name: Build and test Docker images
needs: find-changes
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
# The next environment variable is used by Docker.
BUILDKIT_PROGRESS: ${{inputs.trace && 'plain' || ''}}
steps:
- name: Check out a copy of the git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 1

- name: Check out git submodules
run: git submodule update --init --recursive

- name: Build Docker images
run: docker compose build

- name: Run C++ tests
run: docker run --rm qsim-cxx-tests:latest

- name: Run Python tests
run: docker run --rm qsim-py-tests:latest

- name: Run a sample simulation
run: docker run --rm qsim:latest -c /qsim/circuits/circuit_q24

- name: Test installation process
run: |
cd install/tests
docker compose build
Loading
Loading