From c910c6444ca85655704ee2c05bdc6f7ecc5a47c5 Mon Sep 17 00:00:00 2001 From: Thomas Schmelzer Date: Fri, 29 Nov 2024 13:24:35 +0400 Subject: [PATCH] deptry and sphinx for uv --- actions/uv/deptry/action.yml | 2 +- actions/uv/jupyter/action.yml | 60 +++++++++++++++++++++++++++++++++++ actions/uv/setup/action.yml | 44 +++++++++++++++++++++++++ actions/uv/sphinx/action.yml | 2 +- 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 actions/uv/jupyter/action.yml create mode 100644 actions/uv/setup/action.yml diff --git a/actions/uv/deptry/action.yml b/actions/uv/deptry/action.yml index 7dcf17c..9d4bca0 100644 --- a/actions/uv/deptry/action.yml +++ b/actions/uv/deptry/action.yml @@ -27,7 +27,7 @@ on: runs: using: "composite" steps: - - uses: cvxgrp/.github/actions/setup-environment-uv@main + - uses: cvxgrp/.github/actions/uv/setup@main - name: Install deptry shell: bash diff --git a/actions/uv/jupyter/action.yml b/actions/uv/jupyter/action.yml new file mode 100644 index 0000000..2490ce3 --- /dev/null +++ b/actions/uv/jupyter/action.yml @@ -0,0 +1,60 @@ +# Copyright 2023 Stanford University Convex Optimization Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: Build the Jupyter Book + +description: "Build jupyter book" + +on: + workflow_call: + inputs: + kernel: + description: 'Jupyter kernel' + type: string + required: false + default: 'cvx' + +runs: + using: "composite" + + steps: + #- name: Check out repository + #- uses: actions/checkout@v4 + + - uses: cvxgrp/.github/actions/uv/setup@main + + - name: Install jupyterbook + shell: bash + run: | + uv pip install jupyter-book + # There is no need to create the kernel if the jupyter book is installed within the same virtual environment as the package + # poetry run python -m ipykernel install --user --name=${{ inputs.kernel || 'cvx' }} + + # Build the book + - name: Build the book + shell: bash + run: | + uv run jupyter-book clean book + uv run jupyter-book build book + # Create this weird .nojekyll file + # We do this in the book action... This is the wrong place + # see https://jupyterbook.org/en/stable/publish/gh-pages.html#option-1-copy-and-paste-your-books-build-contents-into-a-new-folder + # touch book/_build/html/.nojekyll + + # Upload the book + - name: Archive book + uses: actions/upload-artifact@v4 + with: + name: book + path: book/_build/html/ + retention-days: 1 \ No newline at end of file diff --git a/actions/uv/setup/action.yml b/actions/uv/setup/action.yml new file mode 100644 index 0000000..532bfc0 --- /dev/null +++ b/actions/uv/setup/action.yml @@ -0,0 +1,44 @@ +# Copyright 2023 Stanford University Convex Optimization Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: Setup the Python Environment + +description: "Construct a Python environment for ci/cd using uv" + +on: + workflow_call: + inputs: + python-version: + description: 'Python version' + type: string + required: false + default: '3.12' + +runs: + using: "composite" + steps: + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + # Install a specific version of uv. + version: "0.5.4" + + - name: Set up Python ${{ inputs.python-version || '3.12' }} + shell: bash + run: | + uv python install ${{ inputs.python-version || '3.12' }} + + - name: Install the project + shell: bash + run: | + uv sync --all-extras --dev diff --git a/actions/uv/sphinx/action.yml b/actions/uv/sphinx/action.yml index 784e0a8..9e6b11e 100644 --- a/actions/uv/sphinx/action.yml +++ b/actions/uv/sphinx/action.yml @@ -28,7 +28,7 @@ runs: using: "composite" steps: - - uses: cvxgrp/.github/actions/setup-environment-uv@main + - uses: cvxgrp/.github/actions/uv/setup@main - name: Install sphinx shell: bash