-
Notifications
You must be signed in to change notification settings - Fork 141
207 lines (182 loc) · 5.92 KB
/
Copy pathci.yml
File metadata and controls
207 lines (182 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# SPDX-FileCopyrightText: Copyright (c) <2025> NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
name: CI
on:
push:
branches: [main, pull-request/1]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-changes:
name: Check for source changes
runs-on: ubuntu-latest
outputs:
source-changed: ${{ steps.changes.outputs.source == 'true' }}
docs-changed: ${{ steps.changes.outputs.docs == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
source:
- 'src/**'
- 'cext/**'
- 'test/**'
- 'samples/**'
- 'pyproject.toml'
- 'setup.py'
- 'CMakeLists.txt'
- 'ci/**'
- '.github/workflows/**'
- 'Dockerfile.ci'
docs:
- 'docs/**'
- '*.md'
build-ci-images:
name: Build CI Image (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 30
needs: check-changes
if: needs.check-changes.outputs.source-changed == 'true'
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /opt/hostedtoolcache/go
sudo rm -rf /opt/hostedtoolcache/node
docker system prune -af
df -h
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/nvidia/cutile-python/ci-py${{ matrix.python-version }}
tags: |
type=sha,prefix={{branch}}-
- name: Check disk space before build
run: df -h
- name: Build and push CI image
id: build
timeout-minutes: 20
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.ci
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=py${{ matrix.python-version }}
cache-to: type=gha,mode=max,scope=py${{ matrix.python-version }}
outputs: type=registry,compression=zstd
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
container:
image: python:3.10-slim
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install lint dependencies
env:
PIP_BREAK_SYSTEM_PACKAGES: 1
run: pip install --no-cache-dir flake8==7.3.0 reuse==5.1.0
- name: Run flake8
run: flake8
- name: Run cpplint
run: python ci/cpplint.py
- name: Check license headers (REUSE)
run: ci/scripts/check_license.sh
- name: Check inline samples are up to date
run: python test/tools/inline_samples.py --check
build-wheel:
name: Build wheel (Linux x86_64, Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: [check-changes, build-ci-images]
if: needs.check-changes.outputs.source-changed == 'true'
timeout-minutes: 30
container:
image: ghcr.io/nvidia/cutile-python/ci-py${{ matrix.python-version }}:${{ github.ref_name }}-${{ github.sha }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Build wheel
timeout-minutes: 15
run: |
python${{ matrix.python-version }} -m venv .venv
.venv/bin/pip install --upgrade pip build wheel setuptools
.venv/bin/python -m build --wheel --outdir dist/
- name: Upload wheel artifact
uses: actions/upload-artifact@v5
with:
name: wheel-linux-x86_64-py${{ matrix.python-version }}
path: dist/*.whl
retention-days: 7
build-docs:
name: Build docs
runs-on: ubuntu-latest
needs: [check-changes, build-ci-images, build-wheel]
if: always() && (needs.check-changes.outputs.source-changed == 'true' || needs.check-changes.outputs.docs-changed == 'true')
timeout-minutes: 15
container:
image: ghcr.io/nvidia/cutile-python/ci-py3.10:${{ github.ref_name }}-${{ github.sha }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download wheel artifact
uses: actions/download-artifact@v5
with:
name: wheel-linux-x86_64-py3.10
path: dist/
- name: Install dependencies
run: pip install dist/*.whl
- name: Build documentation
timeout-minutes: 10
run: |
cd docs
timeout 8m make html
- name: Upload documentation artifact
uses: actions/upload-artifact@v5
with:
name: docs-html
path: docs/build/html/
retention-days: 7