Skip to content

Commit 1859351

Browse files
authored
chore: release-please integration (#443)
* chore: release-please integration * chore: PyPI publishing using OIDC * fix: modernize end-to-end workflow and remove deprecated features * ci: improve performance * fix: `raise RuntimeError('Event loop is closed')` * chore: use uv for all python actions
1 parent bc6b99e commit 1859351

File tree

11 files changed

+89
-81
lines changed

11 files changed

+89
-81
lines changed

.github/workflows/CD-publish_to_pypi.yml

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,65 @@
11
name: CD | Publish Python 🐍 distributions 📦 to PyPI
22

33
on:
4-
release:
5-
types: [published]
6-
4+
push:
5+
branches:
6+
- main
77
workflow_dispatch:
88

9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
actions: write
13+
914
jobs:
15+
release-please:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
release_created: ${{ steps.release.outputs.release_created }}
19+
tag_name: ${{ steps.release.outputs.tag_name }}
20+
steps:
21+
- uses: google-github-actions/release-please-action@v3
22+
id: release
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
release-type: python
26+
package-name: runpod
27+
1028
build-n-publish:
1129
name: Build and publish Python 🐍 distributions 📦 to PyPI
30+
needs: release-please
31+
if: ${{ needs.release-please.outputs.release_created }}
1232
runs-on: ubuntu-latest
33+
environment: release
34+
permissions:
35+
contents: read
36+
id-token: write # Required for OIDC
1337

1438
steps:
1539
- uses: actions/checkout@v4
16-
- name: Set up Python 3.11.10
17-
uses: actions/setup-python@v5
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v6
1842
with:
19-
python-version: 3.11.10
43+
enable-cache: true
2044

21-
- name: Install pypa/build
22-
run: >-
23-
python -m
24-
pip install
25-
build
26-
--user
45+
- name: Set up Python 3.11.10
46+
run: uv python install 3.11.10
2747

28-
- name: Build a binary wheel and a source tarball
29-
run: >-
30-
python -m
31-
build
32-
--sdist
33-
--wheel
34-
--outdir dist/
35-
.
48+
- name: Build package
49+
run: uv build
3650

3751
- name: Publish distribution 📦 to Test PyPI
3852
uses: pypa/gh-action-pypi-publish@release/v1
3953
with:
40-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
41-
repository_url: https://test.pypi.org/legacy/
54+
repository-url: https://test.pypi.org/legacy/
4255

4356
- name: Publish distribution 📦 to PyPI
44-
# if: startsWith(github.ref, 'refs/tags')
4557
uses: pypa/gh-action-pypi-publish@release/v1
46-
with:
47-
password: ${{ secrets.PYPI_API_TOKEN }}
4858

4959
notify-runpod-workers:
5060
name: Notify workers
51-
needs: build-n-publish
61+
needs: [release-please, build-n-publish]
62+
if: ${{ needs.release-please.outputs.release_created }}
5263
strategy:
5364
matrix:
5465
repo:
@@ -75,7 +86,7 @@ jobs:
7586
runs-on: ubuntu-latest
7687

7788
steps:
78-
- name: Wait for propegation
89+
- name: Wait for propagation
7990
run: sleep 300s
8091
shell: bash
8192

.github/workflows/CD-test_publish_to_pypi.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,25 @@ jobs:
1111
build-n-publish:
1212
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
1313
runs-on: ubuntu-latest
14+
environment: test-release
15+
permissions:
16+
contents: read
17+
id-token: write # Required for OIDC
1418

1519
steps:
1620
- uses: actions/checkout@v4
17-
- name: Set up Python 3.11.10
18-
uses: actions/setup-python@v5
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
1923
with:
20-
python-version: 3.11.10
24+
enable-cache: true
2125

22-
- name: Install pypa/build
23-
run: >-
24-
python -m
25-
pip install
26-
build
27-
--user
26+
- name: Set up Python 3.11.10
27+
run: uv python install 3.11.10
2828

29-
- name: Build a binary wheel and a source tarball
30-
run: >-
31-
python -m
32-
build
33-
--sdist
34-
--wheel
35-
--outdir dist/
36-
.
29+
- name: Build package
30+
run: uv build
3731

3832
- name: Publish distribution 📦 to Test PyPI
3933
uses: pypa/gh-action-pypi-publish@release/v1
4034
with:
41-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
42-
repository_url: https://test.pypi.org/legacy/
35+
repository-url: https://test.pypi.org/legacy/

.github/workflows/CI-codeql.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ jobs:
4545
uses: github/codeql-action/init@v3
4646
with:
4747
languages: ${{ matrix.language }}
48-
# If you wish to specify custom queries, you can do so here or in a config file.
49-
# By default, queries listed here will override any specified in a config file.
50-
# Prefix the list here with "+" to use these queries and those in the config file.
51-
52-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53-
# queries: security-extended,security-and-quality
48+
queries: security-extended,security-and-quality
5449

5550
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
5651
# If this step fails, then you should remove it and run the build manually (see below)

.github/workflows/CI-e2e.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ jobs:
5252
5353
- name: Set Docker Tag as Output
5454
id: output_docker_tag
55-
run: echo "::set-output name=docker_tag::${{ env.DOCKER_TAG }}"
55+
run: echo "docker_tag=${{ env.DOCKER_TAG }}" >> $GITHUB_OUTPUT
5656

5757
- name: Build and push Docker image
58-
env:
59-
DOCKERHUB_REPO: ${{ vars.DOCKERHUB_REPO }}
60-
DOCKERHUB_IMG: ${{ vars.DOCKERHUB_IMG }}
61-
run: |
62-
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
63-
docker build -t $DOCKERHUB_REPO/$DOCKERHUB_IMG:${{ env.DOCKER_TAG }} -f mock-worker/Dockerfile mock-worker
64-
docker push $DOCKERHUB_REPO/$DOCKERHUB_IMG:${{ env.DOCKER_TAG }}
58+
uses: docker/build-push-action@v6
59+
with:
60+
context: ./mock-worker
61+
file: ./mock-worker/Dockerfile
62+
push: true
63+
tags: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:${{ env.DOCKER_TAG }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
6566

6667
test:
6768
name: Run End-to-End Tests

.github/workflows/CI-pytests.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v5
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
2626
with:
27-
python-version: ${{ matrix.python-version }}
27+
enable-cache: true
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
run: uv python install ${{ matrix.python-version }}
2831

2932
- name: Install Dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install '.[test]'
33+
run: uv sync --group test
3334

3435
- name: Run Tests
35-
run: pytest
36+
run: uv run pytest

.github/workflows/vhs.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414

15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v6
17+
with:
18+
enable-cache: true
19+
20+
- name: Set up Python 3.11
21+
run: uv python install 3.11
22+
1523
- name: Install runpod
16-
run: |
17-
pip install .
24+
run: uv sync
1825

1926
# runpod --help
2027
- uses: charmbracelet/vhs-action@v2

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Here is a quick guide on how to contribute code to this project:
3535
6. Run tests to ensure that your changes do not break any existing functionality. You can run tests using the following command:
3636

3737
```bash
38+
# Using uv (recommended - faster)
39+
uv sync --group test
40+
uv run pytest
41+
42+
# Or using pip
3843
pip install '.[test]'
3944
pytest
4045
```

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
[![CI | End-to-End Runpod Python Tests](https://github.com/runpod/runpod-python/actions/workflows/CI-e2e.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-e2e.yml)
99

10-
[![CI | Code Quality](https://github.com/runpod/runpod-python/actions/workflows/CI-pylint.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-pylint.yml)
11-
 
1210
[![CI | Unit Tests](https://github.com/runpod/runpod-python/actions/workflows/CI-pytests.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-pytests.yml)
1311
 
1412
[![CI | CodeQL](https://github.com/runpod/runpod-python/actions/workflows/CI-codeql.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-codeql.yml)
@@ -36,10 +34,14 @@ Welcome to the official Python library for Runpod API & SDK.
3634
# Install the latest release version
3735
pip install runpod
3836

39-
# or
37+
# Using uv (faster alternative)
38+
uv add runpod
4039

4140
# Install the latest development version (main branch)
4241
pip install git+https://github.com/runpod/runpod-python.git
42+
43+
# Or with uv
44+
uv add git+https://github.com/runpod/runpod-python.git
4345
```
4446

4547
*Python 3.8 or higher is required to use the latest version of this package.*

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ version_file = "runpod/_version.py"
4949
runpod = "runpod.cli.entry:runpod_cli"
5050

5151

52-
[project.optional-dependencies]
52+
[dependency-groups]
5353
test = [
5454
"asynctest",
5555
"nest_asyncio",

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
addopts = --durations=10 --cov-config=.coveragerc --timeout=120 --timeout_method=thread --cov=runpod --cov-report=xml --cov-report=term-missing --cov-fail-under=90 -W error -p no:cacheprovider -p no:unraisableexception
33
python_files = tests.py test_*.py *_test.py
44
norecursedirs = venv *.egg-info .git build
5+
asyncio_mode = auto

0 commit comments

Comments
 (0)