-
Notifications
You must be signed in to change notification settings - Fork 3.8k
203 lines (176 loc) · 7.1 KB
/
Copy pathwheel.yml
File metadata and controls
203 lines (176 loc) · 7.1 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
# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
name: Build PIP Wheel
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
- develop
- 'release/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
pull-requests: read
jobs:
build-wheel:
name: Build Wheel
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Detect wheel-relevant changes
id: changes
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
EVENT_NAME: ${{ github.event_name }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
# Keep this workflow unconditionally triggered on PRs so required
# branch-protection checks are always reported. The build steps below
# run only when inputs that can affect the wheel have changed.
patterns=(
$'^apps/\tStandalone apps packaged in the wheel'
$'^pyproject\.toml$\tWheel dependency metadata and resolver overrides'
$'^VERSION$\tPackage version'
$'^source/\tPython packages'
$'^tools/wheel_builder/\tWheel build tooling'
$'^\.github/workflows/wheel\.yml$\tThis workflow file'
)
render_table() {
local files="$1" entry regex desc matched count sample
echo "| Pattern | What it covers | Matched files |"
echo "|---|---|---|"
for entry in "${patterns[@]}"; do
IFS=$'\t' read -r regex desc <<< "$entry"
# Feed grep/head from a here-string rather than `printf ... |` so that
# an early-closing reader (head) cannot SIGPIPE an upstream printf and
# trip `set -o pipefail` when the file list is large.
matched=$(grep -E "$regex" <<< "$files" || true)
if [ -n "$matched" ]; then
count=$(wc -l <<< "$matched")
sample=$(head -3 <<< "$matched" | paste -sd ', ' -)
[ "$count" -gt 3 ] && sample="$sample (and $((count - 3)) more)"
echo "| \`$regex\` | $desc | $sample |"
else
echo "| \`$regex\` | $desc | - |"
fi
done
}
any_match() {
local files="$1" entry regex
for entry in "${patterns[@]}"; do
IFS=$'\t' read -r regex _ <<< "$entry"
if grep -qE "$regex" <<< "$files"; then
return 0
fi
done
return 1
}
decide() {
local decision="$1" reason="$2" files="${3:-}"
echo "run_build=$decision" >> "$GITHUB_OUTPUT"
{
echo "## Wheel build gating"
echo ""
if [ "$decision" = "true" ]; then
echo "The wheel build will **run**: $reason."
else
echo "The wheel build will be **skipped**: $reason."
fi
if [ -n "$files" ]; then
echo ""
render_table "$files"
fi
} >> "$GITHUB_STEP_SUMMARY"
}
if [ "$EVENT_NAME" != "pull_request" ]; then
decide true "non-PR event ($EVENT_NAME)"
exit 0
fi
if ! changed_files="$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" --jq '.[].filename')"; then
echo "::warning::Could not list changed files; defaulting to building the wheel"
decide true "fail-safe (could not list changed files)"
exit 0
fi
if any_match "$changed_files"; then
decide true "wheel-relevant paths changed" "$changed_files"
else
decide false "no wheel-relevant paths changed" "$changed_files"
fi
- name: Skip wheel build
if: steps.changes.outputs.run_build == 'false'
run: echo "Skipping wheel build because this PR does not change wheel inputs."
- name: Checkout code
if: steps.changes.outputs.run_build == 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
lfs: true
- name: Setup Python
if: steps.changes.outputs.run_build == 'true'
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
architecture: x64
# Compose Docker-image-style metadata for the artifact. The artifact
# name is what QA sees in `gh run download`, so we make it scannable:
# isaaclab-<VERSION>-build<RUN_NUMBER>-<SHA7>. The wheel inside follows
# PEP 440 (VERSION+buildN.SHA7) since pip requires that format.
- name: Compute wheel metadata
if: steps.changes.outputs.run_build == 'true'
id: meta
run: |
set -euo pipefail
version=$(cat VERSION)
sha_slug="${GITHUB_SHA:0:7}"
echo "artifact_name=isaaclab-${version}-build${{ github.run_number }}-${sha_slug}" >> "$GITHUB_OUTPUT"
- name: Build wheel
if: steps.changes.outputs.run_build == 'true'
env:
WHEEL_BUILD_NUMBER: ${{ github.run_number }}
WHEEL_SHA: ${{ github.sha }}
run: bash tools/wheel_builder/build.sh
- name: Upload wheel artifact
if: steps.changes.outputs.run_build == 'true'
uses: actions/upload-artifact@v7
with:
name: ${{ steps.meta.outputs.artifact_name }}
path: tools/wheel_builder/build/dist/isaaclab-*.whl
if-no-files-found: error
retention-days: 30
- name: Download wheel artifact for install test
if: steps.changes.outputs.run_build == 'true'
uses: actions/download-artifact@v7
with:
name: ${{ steps.meta.outputs.artifact_name }}
path: /tmp/isaaclab-wheel-artifact
- name: Test wheel extras resolution
if: steps.changes.outputs.run_build == 'true'
run: |
set -euo pipefail
python -m pip install --user uv
export PATH="$HOME/.local/bin:$PATH"
overrides="$GITHUB_WORKSPACE/tools/wheel_builder/uv-overrides.txt"
cd /tmp
uv venv --python 3.12 /tmp/isaaclab-wheel-install
source /tmp/isaaclab-wheel-install/bin/activate
uv pip install --upgrade pip
wheel="$(find /tmp/isaaclab-wheel-artifact -name 'isaaclab-*.whl' -print -quit)"
if [ -z "$wheel" ]; then
echo "No isaaclab wheel found in downloaded artifact" >&2
exit 1
fi
uv pip install \
--dry-run \
--overrides "$overrides" \
--extra-index-url https://pypi.nvidia.com \
--index-strategy unsafe-best-match \
--prerelease=allow \
"${wheel}[isaacsim,all]"