Skip to content

Commit 42a38e3

Browse files
Adds release packaging pipeline
Adds a release packaging pipeline which will build and deploy the documentation and push wheels to a GitHub release when a matching tag is pushed. This change also updates L1 to no longer push documentation. This ensures that the published documentation is always aligned with the latest wheel.
1 parent 86fb4e3 commit 42a38e3

File tree

6 files changed

+186
-22
lines changed

6 files changed

+186
-22
lines changed

.github/workflows/tripy-l1.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Perform L1 test, build and deploy docs
1+
# Ensure that documentation builds and run L1 tests.
22
name: Tripy L1
33

44
on:
@@ -9,12 +9,6 @@ on:
99
# Allows you to run this workflow manually from the Actions tab
1010
workflow_dispatch:
1111

12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13-
permissions:
14-
contents: read
15-
pages: write
16-
id-token: write
17-
1812
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
1913
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2014
concurrency:
@@ -24,31 +18,19 @@ concurrency:
2418
jobs:
2519
l1-test:
2620
runs-on: tripy-self-hosted
27-
environment:
28-
name: github-pages
29-
url: ${{ steps.deployment.outputs.page_url }}
3021
container:
3122
image: ghcr.io/nvidia/tensorrt-incubator/tripy:latest
3223
volumes:
3324
- ${{ github.workspace }}/tripy:/tripy
3425
options: --gpus all
3526
steps:
3627
- uses: actions/checkout@v4
37-
- uses: actions/configure-pages@v5
3828

3929
- name: build-docs
4030
run: |
4131
cd /tripy/
4232
python3 docs/generate_rsts.py
4333
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W -n
44-
cp docs/packages.html build/docs/
45-
46-
- uses: actions/upload-pages-artifact@v3
47-
with:
48-
path: "/tripy/build/docs"
49-
- name: Deploy to GitHub Pages
50-
id: deployment
51-
uses: actions/deploy-pages@v4
5234
5335
- name: l1-test
5436
run: |
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Builds Tripy wheels and documentation and deploys them to GitHub releases and pages respectively.
2+
name: Tripy Release Pipeline
3+
4+
on:
5+
push:
6+
tags:
7+
- "tripy-v*.*.*"
8+
9+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
16+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17+
concurrency:
18+
group: "pages"
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build-and-release:
23+
runs-on: tripy-self-hosted
24+
environment:
25+
name: github-pages
26+
url: ${{ steps.deployment.outputs.page_url }}
27+
container:
28+
image: ghcr.io/nvidia/tensorrt-incubator/tripy:latest
29+
volumes:
30+
- ${{ github.workspace }}/tripy:/tripy
31+
options: --gpus all
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/configure-pages@v5
35+
36+
- name: build-docs
37+
run: |
38+
cd /tripy/
39+
python3 docs/generate_rsts.py
40+
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W -n
41+
cp docs/packages.html build/docs/
42+
43+
- uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: "/tripy/build/docs"
46+
- name: Deploy to GitHub Pages
47+
id: deployment
48+
uses: actions/deploy-pages@v4
49+
50+
- name: build-package
51+
run: |
52+
cd /tripy/
53+
python3 -m build .
54+
55+
- name: Release
56+
uses: softprops/action-gh-release@v2
57+
with:
58+
generate_release_notes: true
59+
files: /tripy/dist/tripy-*.whl

tripy/README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,43 @@ user experience without compromising performance. Some of the features of Tripy
2020

2121
## Installation
2222

23+
<!-- Tripy: DOC: OMIT Start -->
24+
### Installing Prebuilt Wheels
25+
<!-- Tripy: DOC: OMIT End -->
26+
2327
```bash
2428
python3 -m pip install --no-index -f https://nvidia.github.io/TensorRT-Incubator/packages.html tripy --no-deps
2529
python3 -m pip install -f https://nvidia.github.io/TensorRT-Incubator/packages.html tripy
2630
```
2731

32+
***Important:** There is another package named `tripy` on PyPI.*
33+
*Note that it is **not** the package from this repository.*
34+
*Please use the instructions above to ensure you install the correct package.*
35+
2836
<!-- Tripy: DOC: OMIT Start -->
29-
If you want to build from source, please follow the instructions in [CONTRIBUTING.md](./CONTRIBUTING.md).
37+
### Building Wheels From Source
38+
39+
To get the latest changes in the repository, you can build Tripy wheels from source.
40+
41+
1. Make sure `build` is installed:
42+
43+
```bash
44+
python3 -m pip install build
45+
```
46+
47+
2. From the [`tripy` root directory](.), run:
48+
49+
```bash
50+
python3 -m build .
51+
```
52+
53+
3. Install the wheel, which should have been created in the `dist/` directory.
54+
From the [`tripy` root directory](.), run:
55+
56+
```bash
57+
python3 -m pip install -f https://nvidia.github.io/TensorRT-Incubator/packages.html dist/tripy-*.whl
58+
```
59+
3060
<!-- Tripy: DOC: OMIT End -->
3161

3262
## Quickstart

tripy/RELEASE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Releasing Tripy
2+
3+
This document explains how to release a new version of Tripy.
4+
5+
1. Update version numbers in [`pyproject.toml`](./pyproject.toml) and
6+
[`__init__.py`](./tripy/__init__.py) (make sure they match!).
7+
8+
2. Add a new entry to [`packages.html`](./docs/packages.html).
9+
This ensures that we will be able to `pip install` Tripy.
10+
11+
3. If there were any other functional changes since the most recent
12+
L1, make sure to run L1 testing locally.
13+
14+
4. Create a PR with the above two changes.
15+
16+
5. Once the PR created in (4) is merged, create a new tag with:
17+
```bash
18+
git tag tripy-vX.Y.Z
19+
```
20+
replacing `X.Y.Z` with the version number and push it to the repository.
21+
22+
This should trigger our release pipeline, which will build and deploy
23+
the documentation and create a GitHub release with the wheel.

tripy/tests/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ def __init__(
311311
@staticmethod
312312
def from_name(name: str) -> "Marker":
313313
return Marker(
314-
matches_start_func=lambda line: line == f"<!-- Tripy: {name} Start -->",
315-
matches_end_func=lambda line: line == f"<!-- Tripy: {name} End -->",
314+
matches_start_func=lambda line: f"Tripy: {name} Start" in line,
315+
matches_end_func=lambda line: f"Tripy: {name} End" in line,
316316
)
317317

318318

tripy/tests/test_packaging.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
from tests import helper
16+
import tempfile
17+
import glob
18+
import os
19+
import tripy as tp
20+
import pytest
21+
22+
23+
@pytest.mark.l1
24+
def test_wheel_packaging_and_install(virtualenv):
25+
with helper.raises(Exception, "returned non-zero exit status"):
26+
virtualenv.run([virtualenv.python, "-c", "import tripy"])
27+
28+
virtualenv.install_package("build")
29+
30+
with tempfile.TemporaryDirectory() as tmp:
31+
virtualenv.run([virtualenv.python, "-m", "build", ".", "-o", tmp], cwd=helper.ROOT_DIR)
32+
33+
wheel_paths = glob.glob(os.path.join(tmp, "*.whl"))
34+
assert len(wheel_paths) == 1, "Expected exactly one wheel file."
35+
36+
wheel_path = wheel_paths[0]
37+
assert os.path.basename(wheel_path) == f"tripy-{tp.__version__}-py3-none-any.whl"
38+
39+
virtualenv.run(
40+
[
41+
virtualenv.python,
42+
"-m",
43+
"pip",
44+
"install",
45+
wheel_path,
46+
# Needed to install MLIR-TRT:
47+
"-f",
48+
"https://nvidia.github.io/TensorRT-Incubator/packages.html",
49+
# For some reason, using the cache causes pip not to correctly install TRT
50+
# if this test is run multiple times in succession.
51+
"--no-cache-dir",
52+
]
53+
)
54+
55+
assert "tripy" in virtualenv.installed_packages()
56+
tripy_pkg = virtualenv.installed_packages()["tripy"]
57+
assert tripy_pkg.version == tp.__version__
58+
59+
# Check that we only package things we actually want.
60+
# If tests are packaged, they'll end up in a higher-level directory.
61+
assert not os.path.exists(os.path.join(tripy_pkg.source_path, "tests"))
62+
63+
# Lastly check we can actually import it and run a simple sanity test:
64+
virtualenv.run(
65+
[
66+
virtualenv.python,
67+
"-c",
68+
"import tripy as tp; x = tp.ones((5,), dtype=tp.int32); assert x.tolist() == [1] * 5",
69+
]
70+
)

0 commit comments

Comments
 (0)