Skip to content

Commit bcc54b2

Browse files
authored
Overhaul GitHub Actions workflows (#747)
1 parent aa6a2c7 commit bcc54b2

16 files changed

Lines changed: 934 additions & 339 deletions

.github/workflows/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# GitHub Actions workflows
2+
3+
Herea are some notes about the workflows in this directory:
4+
5+
Some workflows are reusable and are meant to called from other workflows
6+
only, not invoked directly. As of mid-2025, GitHub's user interface for
7+
Actions does not provide a way to hide, group, or otherwise distinguish these
8+
kinds of reusable modular workflows from the main workflows. To make these
9+
workflows more apparent in the user interface, we use the convention of
10+
naming these workflows with a leading tilde (`~`) character; this makes them
11+
appear last in the list of workflows on GitHub.

.github/workflows/bazeltest.yml

Lines changed: 0 additions & 102 deletions
This file was deleted.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Copyright 2025 Google LLC
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+
# https://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+
name: 'CI: build & test library and apps'
16+
run-name: Build the library on different platforms and run tests
17+
18+
on:
19+
push:
20+
branches:
21+
- master
22+
- main
23+
24+
pull_request:
25+
types: [opened, synchronize]
26+
27+
merge_group:
28+
types:
29+
- checks_requested
30+
31+
workflow_dispatch:
32+
inputs:
33+
debug:
34+
description: 'Run with debugging options'
35+
type: boolean
36+
default: true
37+
38+
permissions: read-all
39+
40+
concurrency:
41+
# Cancel any previously-started but still active runs on the same branch.
42+
cancel-in-progress: true
43+
group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}}
44+
45+
jobs:
46+
find-changes:
47+
name: Find changed files
48+
uses: ./.github/workflows/reusable_find_changes.yaml
49+
secrets: inherit
50+
51+
build-wheels:
52+
# For efficiency, skip this workflow if there were no code file changes.
53+
if: needs.find-changes.outputs.code || github.event_name == 'workflow_dispatch'
54+
name: ${{matrix.conf.os}}/${{matrix.conf.pyarch}}/py3${{matrix.conf.py}}
55+
needs: find-changes
56+
runs-on: ${{matrix.conf.os}}
57+
timeout-minutes: 30
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
conf: [
62+
{os: ubuntu-24.04, pyarch: x64, py: 10},
63+
{os: ubuntu-24.04, pyarch: x64, py: 11},
64+
{os: ubuntu-24.04, pyarch: x64, py: 12},
65+
{os: ubuntu-24.04, pyarch: x64, py: 13},
66+
67+
{os: macos-13, pyarch: x64, py: 10},
68+
{os: macos-13, pyarch: x64, py: 11},
69+
{os: macos-13, pyarch: x64, py: 12},
70+
{os: macos-13, pyarch: x64, py: 13},
71+
72+
{os: macos-14, pyarch: arm64, py: 10},
73+
{os: macos-14, pyarch: arm64, py: 11},
74+
{os: macos-14, pyarch: arm64, py: 12},
75+
{os: macos-14, pyarch: arm64, py: 13},
76+
77+
{os: macos-15, pyarch: arm64, py: 10},
78+
{os: macos-15, pyarch: arm64, py: 11},
79+
{os: macos-15, pyarch: arm64, py: 12},
80+
{os: macos-15, pyarch: arm64, py: 13},
81+
82+
{os: windows-2022, pyarch: x64, py: 10},
83+
{os: windows-2022, pyarch: x64, py: 11},
84+
{os: windows-2022, pyarch: x64, py: 12},
85+
{os: windows-2022, pyarch: x64, py: 13},
86+
]
87+
steps:
88+
- name: Check out a copy of the git repository
89+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
90+
with:
91+
fetch-depth: 1
92+
submodules: recursive
93+
94+
- name: Set up Python with caching of pip dependencies
95+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
96+
id: setup
97+
with:
98+
python-version: '3.${{matrix.conf.py}}'
99+
architecture: ${{matrix.conf.pyarch}}
100+
cache: pip
101+
cache-dependency-path: |
102+
requirements.txt
103+
dev-requirements.txt
104+
105+
- name: Set up Bazel with caching
106+
uses: bazel-contrib/setup-bazel@8d2cb86a3680a820c3e219597279ce3f80d17a47 # 0.15.0
107+
with:
108+
disk-cache: ${{github.workflow}}
109+
bazelisk-cache: true
110+
external-cache: true
111+
repository-cache: true
112+
113+
- name: Install qsim development dependencies
114+
run: |
115+
pip install -r requirements.txt
116+
pip install -r dev-requirements.txt
117+
118+
- if: matrix.conf.os != 'windows-2022'
119+
name: Run the build and test script (non-Windows case)
120+
env:
121+
# SHELLOPTS is used by Bash. Add xtrace when doing manual debug runs.
122+
SHELLOPTS: ${{inputs.debug && 'xtrace' || '' }}
123+
run: dev_tools/test_libs.sh --config=verbose
124+
125+
- if: matrix.conf.os == 'windows-2022'
126+
name: Run the build and test script (Windows case)
127+
# On GitHub Windows runners, Bazel ends up finding a different
128+
# "python3" binary than what's installed by setup-python unless we tell
129+
# Bazel what to use. Here we do that by setting PYTHON_BIN_PATH.
130+
env:
131+
pyroot: 'C:\\hostedtoolcache\\windows\\Python'
132+
pyexe: '${{steps.setup.outputs.python-version}}\\${{matrix.conf.pyarch}}\\python3.exe'
133+
SHELLOPTS: ${{inputs.debug && 'xtrace' || '' }}
134+
shell: cmd
135+
run: >-
136+
bash -x dev_tools/test_libs.sh --config=verbose
137+
--action_env PYTHON_BIN_PATH=${{env.pyroot}}\\${{env.pyexe}}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2025 Google LLC
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+
# https://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+
name: 'CI: build & verify Python wheels'
16+
run-name: Build Python wheels and verify them
17+
18+
on:
19+
push:
20+
branches:
21+
- master
22+
- main
23+
24+
pull_request:
25+
types: [opened, synchronize]
26+
27+
merge_group:
28+
types:
29+
- checks_requested
30+
31+
workflow_dispatch:
32+
inputs:
33+
debug:
34+
description: 'Run with debugging options'
35+
type: boolean
36+
default: true
37+
38+
permissions: read-all
39+
40+
concurrency:
41+
# Cancel any previously-started but still active runs on the same branch.
42+
cancel-in-progress: true
43+
group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}}
44+
45+
jobs:
46+
find-changes:
47+
name: Find changed files
48+
uses: ./.github/workflows/reusable_find_changes.yaml
49+
secrets: inherit
50+
51+
build-wheels:
52+
# For efficiency, skip this workflow if there were no code file changes.
53+
if: needs.find-changes.outputs.code || github.event_name == 'workflow_dispatch'
54+
name: Build & test wheels
55+
needs: find-changes
56+
uses: ./.github/workflows/reusable_build_wheels.yaml
57+
secrets: inherit
58+
with:
59+
debug: ${{inputs.debug == true}}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright 2025 Google LLC
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+
# https://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+
name: 'CI: build & test Docker images'
16+
run-name: Build Docker images and test them
17+
18+
on:
19+
push:
20+
branches:
21+
- master
22+
- main
23+
24+
pull_request:
25+
types: [opened, synchronize]
26+
27+
merge_group:
28+
types:
29+
- checks_requested
30+
31+
workflow_dispatch:
32+
inputs:
33+
debug:
34+
description: 'Run with debugging options'
35+
type: boolean
36+
default: true
37+
38+
permissions: read-all
39+
40+
concurrency:
41+
# Cancel any previously-started but still active runs on the same branch.
42+
cancel-in-progress: true
43+
group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}}
44+
45+
jobs:
46+
find-changes:
47+
name: Find changed files
48+
uses: ./.github/workflows/reusable_find_changes.yaml
49+
secrets: inherit
50+
51+
build-and-test:
52+
# For efficiency, skip this workflow if there were no code file changes.
53+
if: needs.find-changes.outputs.code || github.event_name == 'workflow_dispatch'
54+
name: Build and test Docker images
55+
needs: find-changes
56+
runs-on: ubuntu-24.04
57+
timeout-minutes: 30
58+
env:
59+
# The next environment variable is used by Docker.
60+
BUILDKIT_PROGRESS: ${{inputs.debug && 'plain' || ''}}
61+
steps:
62+
- name: Check out a copy of the git repository
63+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
64+
with:
65+
fetch-depth: 1
66+
submodules: recursive
67+
68+
- name: Build Docker images
69+
run: docker compose build
70+
71+
- name: Run C++ tests
72+
run: docker run --rm qsim-cxx-tests:latest
73+
74+
- name: Run Python tests
75+
run: docker run --rm qsim-py-tests:latest
76+
77+
- name: Run a sample simulation
78+
run: docker run --rm qsim:latest -c /qsim/circuits/circuit_q24
79+
80+
- name: Test installation process
81+
run: |
82+
cd install/tests
83+
docker compose build

0 commit comments

Comments
 (0)