Skip to content

Commit 11289b7

Browse files
Combining cron-staging.yml and main.yml (#1598)
Summary - This PR consolidates the cron-staging.yml and main.yml GitHub Actions workflows into a single unified workflow (ci.yml). Details - Merges duplicated logic between cron and main workflows. - Uses conditional if: checks to distinguish between schedule runs and regular PR/merge queue runs. - Removes unnecessary push trigger (superseded by merge_group). - Keeps merge_group as the required status check for branch protection. Runs: - Normal py tests on PRs and merge queue. - qiskit-main tests and docs-qiskit-main build on scheduled cron runs. - Skips linting on cron runs to avoid redundant checks. - Unifies documentation build and artifact upload steps. Motivation - Simplifies CI by reducing duplication. - Aligns with new merge queue workflow. - Removes legacy testing on qiskit-ibmq-provider (now deprecated). ### PR checklist (delete when all criteria are met) - [x] I have referenced any relevant issue addressed by this change. - [x] I have read the contributing guide `CONTRIBUTING.md`. - [x] I have added the tests to cover my changes. - [ ] I have updated the documentation accordingly. - [ ] I have added a release note file using `reno` if this change needs to be documented in the release notes. Fixes #1073
1 parent 643c20a commit 11289b7

File tree

2 files changed

+53
-85
lines changed

2 files changed

+53
-85
lines changed

.github/workflows/main.yml renamed to .github/workflows/ci.yml

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
name: Tests
1+
name: CI
2+
23
on:
3-
push:
4-
branches: [ 'stable/*' ]
54
pull_request:
65
branches: [ main, 'stable/*' ]
76
merge_group:
87
branches: [ main ]
8+
schedule:
9+
- cron: "0 4 * * *"
10+
workflow_dispatch:
11+
912
concurrency:
1013
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
1114
cancel-in-progress: true
15+
16+
env:
17+
qiskitmain: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
18+
1219
jobs:
1320
tests:
1421
if: github.repository_owner == 'Qiskit-Community'
@@ -26,34 +33,56 @@ jobs:
2633
echo -e "\033[31;1;4mConcurrency Group\033[0m"
2734
echo -e "$CONCURRENCY_GROUP\n"
2835
shell: bash
36+
2937
- uses: actions/checkout@v5
38+
3039
- name: Set up Python ${{ matrix.python-version }}
3140
uses: actions/setup-python@v6
3241
with:
3342
python-version: ${{ matrix.python-version }}
43+
3444
- name: Set up uv
3545
uses: astral-sh/setup-uv@v6
3646
with:
3747
enable-cache: true
3848
cache-dependency-glob: |
3949
**/tox.ini
4050
**/pyproject.toml
41-
cache-suffix: tests
42-
- name: Stestr cache
43-
uses: actions/cache@v4
51+
cache-suffix: tests${{ env.qiskitmain == 'true' && '-qiskitmain' || '' }}
52+
53+
# Restore stestr cache (shared between Qiskit main and PR runs)
54+
- name: Restore stestr cache
55+
id: stestr-restore
56+
uses: actions/cache/restore@v4
4457
with:
4558
path: .stestr
4659
key: stestr-${{ runner.os }}-${{ matrix.python-version }}
4760
restore-keys: |
4861
stestr-${{ runner.os }}-
4962
stestr-
50-
- name: Install and Run Tests
63+
64+
- name: Install and Run Tests (Qiskit main run)
65+
if: env.qiskitmain == 'true'
66+
run: uvx --with tox-uv tox -e qiskit-main
67+
68+
- name: Install and Run Tests (normal PR run)
69+
if: env.qiskitmain != 'true'
5170
run: uvx --with tox-uv tox --override testenv.package=external run -e py
52-
- name: Clean up stestr cache
71+
72+
# Always prune history (avoid unbounded growth)
73+
- name: Prune stestr history
5374
run: uvx --with tox-uv tox exec -epy -- stestr history remove all
5475

76+
# Only save cache on normal PR runs (avoid growing Qiskit main cache)
77+
- name: Save stestr cache
78+
if: env.qiskitmain != 'true'
79+
uses: actions/cache/save@v4
80+
with:
81+
path: .stestr
82+
key: ${{ steps.stestr-restore.outputs.cache-primary-key }}
83+
5584
lint:
56-
if: github.repository_owner == 'Qiskit-Community'
85+
if: github.repository_owner == 'Qiskit-Community' && github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'
5786
name: lint
5887
runs-on: ubuntu-latest
5988
steps:
@@ -72,6 +101,7 @@ jobs:
72101
cache-suffix: lint
73102
- name: Run lint
74103
run: uvx --with tox-uv tox run -elint
104+
75105
docs:
76106
if: github.repository_owner == 'Qiskit-Community'
77107
name: docs
@@ -80,28 +110,38 @@ jobs:
80110
- uses: actions/checkout@v5
81111
with:
82112
fetch-depth: 0
113+
83114
- name: Set up Python 3.13
84115
uses: actions/setup-python@v6
85116
with:
86117
python-version: '3.13'
118+
87119
- name: Set up uv
88120
uses: astral-sh/setup-uv@v6
89121
with:
90122
enable-cache: true
91123
cache-dependency-glob: |
92124
**/tox.ini
93125
**/pyproject.toml
94-
cache-suffix: docstest
126+
cache-suffix: docs${{ env.qiskitmain == 'true' && '-qiskitmain' || '' }}
127+
95128
- name: Install Deps
96-
run: |
97-
sudo apt-get install -y pandoc graphviz
98-
- name: Build Docs
129+
run: sudo apt-get install -y pandoc graphviz
130+
131+
- name: Build Docs (Qiskit main run)
132+
if: env.qiskitmain == 'true'
133+
run: uvx --with tox-uv tox -edocs-qiskit-main
134+
135+
- name: Build Docs (normal PR run)
136+
if: env.qiskitmain != 'true'
99137
run: uvx --with tox-uv tox run -edocs-parallel
138+
100139
- name: Compress Artifacts
101140
run: |
102141
mkdir artifacts
103142
tar -Jcvf html_docs.tar.xz docs/_build/html
104143
mv html_docs.tar.xz artifacts/.
144+
105145
- uses: actions/upload-artifact@v4
106146
with:
107147
name: html_docs

.github/workflows/cron-staging.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)