Skip to content

Commit 4d623f1

Browse files
Create ci.yml
1 parent 643c20a commit 4d623f1

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

.github/workflows/ci.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main, 'stable/*' ]
6+
merge_group:
7+
branches: [ main ]
8+
schedule:
9+
- cron: "0 4 * * *"
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
tests:
18+
if: github.repository_owner == 'Qiskit-Community'
19+
name: tests-python${{ matrix.python-version }}-${{ matrix.os }}
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
matrix:
23+
python-version: [3.9, "3.13"]
24+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
25+
steps:
26+
- name: Print Concurrency Group
27+
env:
28+
CONCURRENCY_GROUP: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
29+
run: |
30+
echo -e "\033[31;1;4mConcurrency Group\033[0m"
31+
echo -e "$CONCURRENCY_GROUP\n"
32+
shell: bash
33+
- uses: actions/checkout@v5
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v6
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
- name: Set up uv
39+
uses: astral-sh/setup-uv@v6
40+
with:
41+
enable-cache: true
42+
cache-dependency-glob: |
43+
**/tox.ini
44+
**/pyproject.toml
45+
cache-suffix: tests
46+
- name: Stestr cache
47+
uses: actions/cache@v4
48+
with:
49+
path: .stestr
50+
key: stestr-${{ runner.os }}-${{ matrix.python-version }}
51+
restore-keys: |
52+
stestr-${{ runner.os }}-
53+
stestr-
54+
- name: Install and Run Tests
55+
run: |
56+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
57+
uvx --with tox-uv tox -e qiskit-main
58+
else
59+
uvx --with tox-uv tox --override testenv.package=external run -e py
60+
fi
61+
- name: Clean up stestr cache
62+
if: ${{ github.event_name != 'schedule' }}
63+
run: uvx --with tox-uv tox exec -epy -- stestr history remove all
64+
65+
lint:
66+
if: github.repository_owner == 'Qiskit-Community' && github.event_name != 'schedule'
67+
name: lint
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v5
71+
- name: Set up Python 3.13
72+
uses: actions/setup-python@v6
73+
with:
74+
python-version: '3.13'
75+
- name: Set up uv
76+
uses: astral-sh/setup-uv@v6
77+
with:
78+
enable-cache: true
79+
cache-dependency-glob: |
80+
**/tox.ini
81+
**/pyproject.toml
82+
cache-suffix: lint
83+
- name: Run lint
84+
run: uvx --with tox-uv tox run -elint
85+
86+
docs:
87+
if: github.repository_owner == 'Qiskit-Community'
88+
name: docs
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v5
92+
with:
93+
fetch-depth: 0
94+
- name: Set up Python ${{ github.event_name == 'schedule' && '3.12' || '3.13' }}
95+
uses: actions/setup-python@v6
96+
with:
97+
python-version: ${{ github.event_name == 'schedule' && '3.12' || '3.13' }}
98+
- name: Set up uv
99+
uses: astral-sh/setup-uv@v6
100+
with:
101+
enable-cache: true
102+
cache-dependency-glob: |
103+
**/tox.ini
104+
**/pyproject.toml
105+
cache-suffix: docs
106+
- name: Install Deps
107+
run: |
108+
sudo apt-get install -y pandoc graphviz
109+
- name: Build Docs
110+
run: |
111+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
112+
uvx --with tox-uv tox -edocs-qiskit-main
113+
else
114+
uvx --with tox-uv tox run -edocs-parallel
115+
fi
116+
- name: Compress Artifacts
117+
run: |
118+
mkdir artifacts
119+
tar -Jcvf html_docs.tar.xz docs/_build/html
120+
mv html_docs.tar.xz artifacts/.
121+
- uses: actions/upload-artifact@v4
122+
with:
123+
name: html_docs
124+
path: artifacts

0 commit comments

Comments
 (0)