From 5c0cadf670b1c7a6626b2f2ef073dbba0b364f14 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Tue, 15 Oct 2024 13:27:44 +0100 Subject: [PATCH] Update Rust and add setup-uv (#3) --- .github/actions/setup-rust/action.yml | 12 +++++++++- .github/actions/setup-uv/action.yml | 34 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/actions/setup-uv/action.yml diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml index 5b5e072..cdb91ed 100644 --- a/.github/actions/setup-rust/action.yml +++ b/.github/actions/setup-rust/action.yml @@ -6,6 +6,14 @@ inputs: description: Comma-separated list of components to be additionally installed for a new toolchain required: false default: clippy, rustfmt + targets: + description: Comma-separated list of targets to be additionally installed for a new toolchain + required: false + default: "" + sccache: + description: "Enable sccache" + required: false + default: "true" runs: using: "composite" @@ -22,6 +30,7 @@ runs: with: toolchain: "${{ steps.rust-version.outputs.version }}" components: ${{ inputs.components }} + targets: ${{ inputs.targets }} - name: Rust Dependency Cache uses: Swatinem/rust-cache@v2 @@ -31,10 +40,11 @@ runs: - name: Rust Compile Cache uses: mozilla-actions/sccache-action@v0.0.6 + if: ${{ inputs.sccache == 'true' }} - name: Rust Compile Cache Config shell: bash run: | echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + ${{ inputs.sccache == 'true' && 'echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV' || '' }} echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV diff --git a/.github/actions/setup-uv/action.yml b/.github/actions/setup-uv/action.yml new file mode 100644 index 0000000..9b57a08 --- /dev/null +++ b/.github/actions/setup-uv/action.yml @@ -0,0 +1,34 @@ +name: "Setup Python UV" +description: "Toolchain setup for Python UV" + +inputs: + sync: + description: "Sync the project" + required: false + default: "true" + +runs: + using: "composite" + steps: + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + version: "0.4.18" + enable-cache: true + + - name: "Setup up Python" + shell: bash + run: uv python install + + - name: Install the project + if: ${{ inputs.sync == 'true' }} + shell: bash + run: uv sync --all-extras --dev -v + env: + MATURIN_PEP517_USE_BASE_PYTHON: "true" + # Keep this constant to avoid pyo3 invalidating itself + PYO3_ENVIRONMENT_SIGNATURE: "cpython3" + + - name: Export Path + shell: bash + run: echo "PATH=$PATH" >> $GITHUB_ENV