-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI workflows for quality checks, testing and publishing
* Add workflow for quality checks (all commits) * Add workflow for test execution (all commits) * Add workflow to test build package (PR and main) with basic functionality test on Linux * Add worflow to release package to PyPI (tags on main)
- Loading branch information
Showing
8 changed files
with
282 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Code Quality | ||
|
||
on: | ||
push: {} | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
code-quality-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ vars.CI_PYTHON_VERSION }} | ||
|
||
- name: Run pre-commit | ||
uses: pre-commit/action@v3.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Release Package | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
jobs: | ||
release-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Verify current tag is on main branch | ||
run: | | ||
# Exit with error if current tag is not on main | ||
git merge-base --is-ancestor ${{ github.sha }} origin/main || exit 1 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ vars.CI_PYTHON_VERSION }} | ||
|
||
- name: Install Poetry | ||
uses: abatilo/actions-poetry@v3 | ||
with: | ||
poetry-version: ${{ vars.CI_POETRY_VERSION }} | ||
|
||
- name: Install Poetry plugins | ||
run: | | ||
poetry self add "poetry-dynamic-versioning[plugin]" | ||
- name: Build package | ||
run: | | ||
poetry build | ||
ls -la dist/ | ||
- name: Upload distributions | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: release-dists | ||
path: dist/ | ||
retention-days: 1 | ||
|
||
pypi-publish: | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- release-build | ||
|
||
permissions: | ||
id-token: write | ||
|
||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/ipybox/ | ||
|
||
steps: | ||
- name: Retrieve release distributions | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: release-dists | ||
path: dist/ | ||
|
||
- name: Publish package distributions to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Tests | ||
|
||
on: | ||
push: {} | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Cache conda | ||
uses: actions/cache@v4 | ||
env: | ||
CACHE_NUMBER: 0 | ||
with: | ||
path: ~/conda_pkgs_dir | ||
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | ||
|
||
- name: Setup Conda | ||
uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
auto-update-conda: true | ||
environment-file: environment.yml | ||
|
||
- name: Install Poetry | ||
uses: abatilo/actions-poetry@v3 | ||
with: | ||
poetry-version: ${{ vars.CI_POETRY_VERSION }} | ||
|
||
- name: Install dependencies | ||
shell: bash -l {0} | ||
run: | | ||
poetry env info | ||
poetry install | ||
pip list | ||
- name: Run tests | ||
shell: bash -l {0} | ||
run: | | ||
poetry run pytest -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: Package Installation Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
package-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ vars.CI_PYTHON_VERSION }} | ||
|
||
- name: Install Poetry | ||
uses: abatilo/actions-poetry@v3 | ||
with: | ||
poetry-version: ${{ vars.CI_POETRY_VERSION }} | ||
|
||
- name: Install Poetry plugins | ||
run: | | ||
poetry self add "poetry-dynamic-versioning[plugin]" | ||
- name: Build package | ||
run: | | ||
poetry build | ||
- name: Upload dist artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ | ||
retention-days: 1 | ||
|
||
package-test: | ||
needs: package-build | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: ['3.11', '3.12'] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Download package | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Test wheel installation (Windows) | ||
if: runner.os == 'Windows' | ||
shell: pwsh | ||
run: | | ||
$wheel = Get-ChildItem dist/*.whl | Select-Object -First 1 | ||
pip install $wheel | ||
python -c "import ipybox" | ||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
pip uninstall -y ipybox | ||
- name: Test wheel installation (Unix) | ||
if: runner.os != 'Windows' | ||
run: | | ||
pip install dist/*.whl | ||
python -c "import ipybox" | ||
pip uninstall -y ipybox | ||
- name: Test tarball installation (Windows) | ||
if: runner.os == 'Windows' | ||
shell: pwsh | ||
run: | | ||
$tarball = Get-ChildItem dist/*.tar.gz | Select-Object -First 1 | ||
pip install $tarball | ||
python -c "import ipybox" | ||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
pip uninstall -y ipybox | ||
- name: Test tarball installation (Unix) | ||
if: runner.os != 'Windows' | ||
run: | | ||
pip install dist/*.tar.gz | ||
python -c "import ipybox" | ||
pip uninstall -y ipybox | ||
- name: Run smoke test (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
pip install dist/*.whl | ||
pip install pytest pytest-asyncio | ||
pytest tests/test_basic.py | ||
pip uninstall -y ipybox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import tempfile | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def workspace(): | ||
with tempfile.TemporaryDirectory() as temp_dir: | ||
yield temp_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
|
||
from ipybox import ExecutionClient, ExecutionContainer | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def executor(workspace: str): | ||
async with ExecutionContainer( | ||
tag="ghcr.io/gradion-ai/ipybox:minimal", | ||
binds={workspace: "workspace"}, | ||
) as container: | ||
async with ExecutionClient(host="localhost", port=container.port) as client: | ||
yield client | ||
|
||
|
||
@pytest.mark.asyncio(loop_scope="module") | ||
async def test_basic_functionality(executor): | ||
result = await executor.execute("print('Hello, world!')") | ||
assert result.text == "Hello, world!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters