Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/uv #1155

Merged
merged 9 commits into from
Oct 11, 2024
Merged

Dev/uv #1155

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 13 additions & 40 deletions .github/actions/init-all/action.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,28 @@
name: 'Initialization Action'
description: 'Common initialization steps for CI jobs'
inputs:
python-version:
description: 'Python version to setup'
required: true
python-version-file:
description: 'Python version file to setup'
required: false
node-version-file:
description: 'Node version file to setup'
required: true
runs:
using: "composite"
steps:
## Set up Python and Poetry environment
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
## Set up Python
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
shell: bash

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
shell: bash

- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
shell: bash

- name: Configure poetry
run: poetry config virtualenvs.in-project false
shell: bash
python-version-file: ${{ inputs.python-version-file }}

- name: Set up cache
uses: actions/cache@v4
id: cache
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('requirements*.txt') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
shell: bash

- name: Create virtualenv
run: python -m venv .venv
shell: bash
version: "latest"
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/uv.lock

## Set up Node environment
- uses: actions/setup-node@v4
Expand Down
42 changes: 10 additions & 32 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
target: ["mountable"]

env:
python-version: "3.12.1"
# To avoid an error like "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory".
# See https://github.com/actions/virtual-environments/issues/70#issuecomment-653886422
# The Linux VM has 7GB RAM (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources),
Expand All @@ -35,40 +34,19 @@ jobs:
with:
submodules: true

## Set up Python and Poetry environment
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v5
## Set up Python
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
python-version-file: ".python-version"

# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y

- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Configure poetry
run: poetry config virtualenvs.in-project false

- name: Set up cache
uses: actions/cache@v4
id: cache
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('requirements*.txt') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv

- name: Create virtualenv
run: python -m venv .venv
version: "latest"
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/uv.lock

## Set up Node environment
- uses: actions/setup-node@v4
Expand Down
53 changes: 27 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

env:
python-version: "3.12.1"
python-version-file: ".python-version"
node-version-file: ".nvmrc"
# To avoid an error like "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory".
# See https://github.com/actions/virtual-environments/issues/70#issuecomment-653886422
# The Linux VM has 7GB RAM (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources),
Expand Down Expand Up @@ -75,7 +76,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Lint
Expand All @@ -102,8 +103,8 @@ jobs:

- uses: ./.github/actions/init-all
with:
python-version: ${{ env.python-version }}
node-version-file: .nvmrc
python-version: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

- name: Lint
run: |
Expand All @@ -126,15 +127,15 @@ jobs:

- uses: ./.github/actions/init-all
with:
python-version: ${{ env.python-version }}
node-version-file: .nvmrc
python-version: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

- name: Install dependencies
shell: bash
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-lib
poetry install
uv sync

- name: Set up Streamlit and build proto
run: |
Expand All @@ -145,21 +146,21 @@ jobs:
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-lib
poetry run ruff check --output-format=github .
poetry run ruff format . --check
uv run ruff check --output-format=github .
uv run ruff format . --check

- name: Run pyright
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-lib
poetry run pyright
uv run pyright

- name: Run pytest
shell: bash
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-lib
poetry run python -m pytest -v
uv run pytest -v

test-mountable:
needs: changes
Expand All @@ -177,7 +178,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Lint
Expand All @@ -202,7 +203,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: make sharing-common
Expand All @@ -229,7 +230,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Lint
Expand Down Expand Up @@ -259,7 +260,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
- run: yarn config set network-timeout 600000 # `yarn install` often takes so long time on in the Windows env.
- run: yarn install --frozen-lockfile
Expand Down Expand Up @@ -289,8 +290,8 @@ jobs:

- uses: ./.github/actions/init-all
with:
python-version: ${{ env.python-version }}
node-version-file: .nvmrc
python-version: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

## Build and deploy @stlite/mountable
# PUBLIC_URL here is set as a relative path, which is possible to the trick introduced at https://github.com/whitphx/stlite/pull/143.
Expand Down Expand Up @@ -369,7 +370,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
scope: '@stlite'
Expand Down Expand Up @@ -406,8 +407,8 @@ jobs:

- uses: ./.github/actions/init-all
with:
python-version: ${{ env.python-version }}
node-version-file: .nvmrc
python-version: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

## Build and upload @stlite/sharing
- name: Set EDITOR_APP_ORIGIN (preview)
Expand Down Expand Up @@ -477,7 +478,7 @@ jobs:
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Set SHARING_APP_URL (preview)
Expand Down Expand Up @@ -540,8 +541,8 @@ jobs:

- uses: ./.github/actions/init-all
with:
python-version: ${{ env.python-version }}
node-version-file: .nvmrc
python-version: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

## Build and deploy @stlite/desktop
- name: Build @stlite/desktop
Expand Down Expand Up @@ -593,7 +594,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}

- run: cp -r packages/desktop/samples/basic ${{ runner.temp }}/sample_app

Expand Down Expand Up @@ -634,7 +635,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
scope: '@stlite'
Expand Down Expand Up @@ -670,7 +671,7 @@ jobs:
submodules: true
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version-file: ${{ env.node-version-file }}
cache: 'yarn'
- run: yarn config set network-timeout 300000 # https://github.com/yarnpkg/yarn/issues/8242
- run: yarn install --frozen-lockfile
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.1
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ NODE_MODULES := ./node_modules

.PHONY: venv
venv: requirements.dev.txt streamlit/lib/dev-requirements.txt
[ -d $(VENV) ] || python -m venv $(VENV)
. $(VENV)/bin/activate && python -m pip install -U pip && python -m pip install -r requirements.dev.txt -r streamlit/lib/dev-requirements.txt
[ -d $(VENV) ] || uv venv $(VENV)
. $(VENV)/bin/activate && uv pip install -r requirements.dev.txt -r streamlit/lib/dev-requirements.txt
@echo "\nPython virtualenv has been set up. Run the command below to activate.\n\n. $(VENV)/bin/activate"

.PHONY: yarn_install
Expand Down Expand Up @@ -111,7 +111,7 @@ stlite-lib-wheel: $(stlite-lib-wheel)
$(stlite-lib-wheel): venv packages/kernel/py/stlite-lib/stlite_lib/*.py
. $(VENV)/bin/activate && \
cd packages/kernel/py/stlite-lib && \
poetry build
uv build
@touch $@

.PHONY: streamlit-proto
Expand Down
Loading
Loading