diff --git a/.github/actions/get-msrv/action.yml b/.github/actions/get-msrv/action.yml index f0b03e2777..6e8816f983 100644 --- a/.github/actions/get-msrv/action.yml +++ b/.github/actions/get-msrv/action.yml @@ -29,7 +29,4 @@ runs: - name: Get MSRV id: get-msrv shell: bash - run: | - msrv=$(grep '^rust-version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/') - echo "msrv=$msrv" >> $GITHUB_OUTPUT - echo "MSRV is $msrv" + run: bash "$GITHUB_ACTION_PATH/run.sh" diff --git a/.github/actions/get-msrv/run.sh b/.github/actions/get-msrv/run.sh new file mode 100644 index 0000000000..bbf593e39c --- /dev/null +++ b/.github/actions/get-msrv/run.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +set -euo pipefail + +msrv=$(grep '^rust-version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/') +echo "msrv=$msrv" >> "$GITHUB_OUTPUT" +echo "MSRV is $msrv" diff --git a/.github/actions/overwrite-package-version/action.yml b/.github/actions/overwrite-package-version/action.yml index 9131171d9d..dbb7f7fb32 100644 --- a/.github/actions/overwrite-package-version/action.yml +++ b/.github/actions/overwrite-package-version/action.yml @@ -24,18 +24,8 @@ inputs: runs: using: "composite" steps: - - name: Install toml-cli - # Avoid `--locked` as its lock file is not recently updated, - # and its dependencies at the time rely on unstable nightly features since removed. - run: cargo install toml-cli - shell: bash - - - name: Set pyproject version + - name: Update package version shell: bash env: VERSION: ${{ inputs.version }} - run: | - echo "Setting pyproject version to: ${VERSION}" - PYPROJECT="bindings/python/pyproject.toml" - toml set "$PYPROJECT" project.version "${VERSION}" > tmp.toml && mv tmp.toml "$PYPROJECT" - sed 's/dynamic = \["version"\]/dynamic = []/' "$PYPROJECT" > tmp.toml && mv tmp.toml "$PYPROJECT" + run: bash "$GITHUB_ACTION_PATH/run.sh" diff --git a/.github/actions/overwrite-package-version/run.sh b/.github/actions/overwrite-package-version/run.sh new file mode 100644 index 0000000000..b7add60f05 --- /dev/null +++ b/.github/actions/overwrite-package-version/run.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +set -euo pipefail + +# Avoid `--locked` as toml-cli's lock file is not recently updated, +# and its dependencies at the time rely on removed nightly features. +cargo install toml-cli + +echo "Setting pyproject version to: ${VERSION}" +pyproject="bindings/python/pyproject.toml" +toml set "$pyproject" project.version "${VERSION}" > tmp.toml +mv tmp.toml "$pyproject" +sed 's/dynamic = \["version"\]/dynamic = []/' "$pyproject" > tmp.toml +mv tmp.toml "$pyproject" diff --git a/.github/actions/setup-builder/action.yml b/.github/actions/setup-builder/action.yml index e961ed6335..53c38e4271 100644 --- a/.github/actions/setup-builder/action.yml +++ b/.github/actions/setup-builder/action.yml @@ -25,24 +25,8 @@ inputs: runs: using: "composite" steps: - - name: Setup specified Rust toolchain - if: ${{ inputs.rust-version != '' }} + - name: Setup Rust toolchain shell: bash env: RUST_VERSION: ${{ inputs.rust-version }} - run: | - echo "Installing ${RUST_VERSION}" - rustup toolchain install ${RUST_VERSION} - rustup override set ${RUST_VERSION} - rustup component add rustfmt clippy - - name: Setup Rust toolchain according to rust-toolchain.toml - shell: bash - if: ${{ inputs.rust-version == '' }} - run: | - echo "Installing toolchain according to rust-toolchain.toml" - rustup show - rustup component add rustfmt clippy - - name: Fixup git permissions - # https://github.com/actions/checkout/issues/766 - shell: bash - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" \ No newline at end of file + run: bash "$GITHUB_ACTION_PATH/run.sh" diff --git a/.github/actions/setup-builder/run.sh b/.github/actions/setup-builder/run.sh new file mode 100644 index 0000000000..fc05debb46 --- /dev/null +++ b/.github/actions/setup-builder/run.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +set -euo pipefail + +if [[ -n "${RUST_VERSION:-}" ]]; then + echo "Installing ${RUST_VERSION}" + rustup toolchain install "${RUST_VERSION}" + rustup override set "${RUST_VERSION}" +else + echo "Installing toolchain according to rust-toolchain.toml" + rustup show +fi + +rustup component add rustfmt clippy + +# https://github.com/actions/checkout/issues/766 +git config --global --add safe.directory "$GITHUB_WORKSPACE" diff --git a/.github/workflows/asf-allowlist-check.yml b/.github/workflows/asf-allowlist-check.yml index 5380bcfd17..3844789995 100644 --- a/.github/workflows/asf-allowlist-check.yml +++ b/.github/workflows/asf-allowlist-check.yml @@ -39,9 +39,4 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - # The allowlist checker recognizes ./, but not $/, as a local action prefix. - # Normalize its disposable checkout while preserving $/ in source workflows. - - name: Normalize self-repository references for the allowlist checker - run: | - find .github -type f -name '*.yml' -exec sed -i 's#uses: \$/#uses: ./#g' {} + - uses: apache/infrastructure-actions/allowlist-check@61dcea11f19e2bbe1263f14d72235e8da17d3ad0 # allowlist-check/v1.0.0 diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index c53d4af475..7e07eea8ff 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -53,9 +53,10 @@ jobs: with: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder - with: - rust-version: stable + shell: bash + env: + RUST_VERSION: stable + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/bindings_python_ci.yml b/.github/workflows/bindings_python_ci.yml index 375521d0f2..c3c96a5b28 100644 --- a/.github/workflows/bindings_python_ci.yml +++ b/.github/workflows/bindings_python_ci.yml @@ -85,7 +85,8 @@ jobs: # Linux maturin builds may run inside manylinux Docker, so host Rust caches only help Windows/macOS. - name: Setup Rust toolchain if: runner.os != 'Linux' - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Cache Rust artifacts if: runner.os != 'Linux' uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc380ab18c..283b71f680 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,8 @@ jobs: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Install lint tools # Keep versions in sync with the local install targets in Makefile. @@ -93,7 +94,8 @@ jobs: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Cargo clippy run: make check-clippy @@ -117,7 +119,8 @@ jobs: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Cache Rust artifacts uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 @@ -138,7 +141,8 @@ jobs: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Cache Rust artifacts uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 @@ -173,7 +177,8 @@ jobs: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Cache Rust artifacts uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 @@ -202,7 +207,8 @@ jobs: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Cache Rust artifacts uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 @@ -249,12 +255,15 @@ jobs: persist-credentials: false - name: Get MSRV id: get-msrv - uses: $/.github/actions/get-msrv + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/get-msrv/run.sh" - name: Setup MSRV Rust toolchain - uses: $/.github/actions/setup-builder - with: - rust-version: ${{ steps.get-msrv.outputs.msrv }} + shell: bash + env: + RUST_VERSION: ${{ steps.get-msrv.outputs.msrv }} + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Setup Nightly Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Check MSRV run: make check-msrv diff --git a/.github/workflows/public-api.yml b/.github/workflows/public-api.yml index a3af719a40..42d733110a 100644 --- a/.github/workflows/public-api.yml +++ b/.github/workflows/public-api.yml @@ -41,7 +41,8 @@ jobs: persist-credentials: false - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - name: Cache Rust artifacts uses: swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 863222a2d4..ff99074cd6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -43,12 +43,14 @@ jobs: - name: Get MSRV id: get-msrv - uses: $/.github/actions/get-msrv + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/get-msrv/run.sh" - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder - with: - rust-version: ${{ steps.get-msrv.outputs.msrv }} + shell: bash + env: + RUST_VERSION: ${{ steps.get-msrv.outputs.msrv }} + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 id: auth diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index 758bdff21b..53b564e35a 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -120,10 +120,12 @@ jobs: # Convert semver RC (0.9.0-rc.1) to PEP 440 (0.9.0rc1) echo "pep440=$(echo "$CARGO_VERSION" | sed 's/-rc\.\([0-9]*\)/rc\1/')" >> $GITHUB_OUTPUT - - uses: $/.github/actions/overwrite-package-version + - name: Overwrite package version if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }} - with: - version: ${{ steps.version.outputs.pep440 }} + shell: bash + env: + VERSION: ${{ steps.version.outputs.pep440 }} + run: bash "$GITHUB_WORKSPACE/.github/actions/overwrite-package-version/run.sh" - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 with: @@ -167,22 +169,26 @@ jobs: # Convert semver RC (0.9.0-rc.1) to PEP 440 (0.9.0rc1) echo "pep440=$(echo "$CARGO_VERSION" | sed 's/-rc\.\([0-9]*\)/rc\1/')" >> $GITHUB_OUTPUT - - uses: $/.github/actions/overwrite-package-version + - name: Overwrite package version if: ${{ needs.validate-release-tag.outputs.is-rc == 'true' }} - with: - version: ${{ steps.version.outputs.pep440 }} + shell: bash + env: + VERSION: ${{ steps.version.outputs.pep440 }} + run: bash "$GITHUB_WORKSPACE/.github/actions/overwrite-package-version/run.sh" - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: 3.12 - name: Get MSRV id: get-msrv - uses: $/.github/actions/get-msrv + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/get-msrv/run.sh" - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder - with: - rust-version: ${{ steps.get-msrv.outputs.msrv }} + shell: bash + env: + RUST_VERSION: ${{ steps.get-msrv.outputs.msrv }} + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 with: target: ${{ matrix.target }} diff --git a/.github/workflows/release_python_nightly.yml b/.github/workflows/release_python_nightly.yml index ab2b2ff9c1..21ac410c29 100644 --- a/.github/workflows/release_python_nightly.yml +++ b/.github/workflows/release_python_nightly.yml @@ -53,9 +53,11 @@ jobs: CURRENT=$(cargo metadata --format-version 1 --no-deps -q | jq -r '.packages[0].version') echo "pep440=${CURRENT}.dev${TIMESTAMP}" >> $GITHUB_OUTPUT - - uses: $/.github/actions/overwrite-package-version - with: - version: ${{ steps.version.outputs.pep440 }} + - name: Overwrite package version + shell: bash + env: + VERSION: ${{ steps.version.outputs.pep440 }} + run: bash "$GITHUB_WORKSPACE/.github/actions/overwrite-package-version/run.sh" - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 with: @@ -99,9 +101,11 @@ jobs: CURRENT=$(cargo metadata --format-version 1 --no-deps -q | jq -r '.packages[0].version') echo "pep440=${CURRENT}.dev${TIMESTAMP}" >> $GITHUB_OUTPUT - - uses: $/.github/actions/overwrite-package-version - with: - version: ${{ steps.version.outputs.pep440 }} + - name: Overwrite package version + shell: bash + env: + VERSION: ${{ steps.version.outputs.pep440 }} + run: bash "$GITHUB_WORKSPACE/.github/actions/overwrite-package-version/run.sh" - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: @@ -109,12 +113,14 @@ jobs: - name: Get MSRV id: get-msrv - uses: $/.github/actions/get-msrv + shell: bash + run: bash "$GITHUB_WORKSPACE/.github/actions/get-msrv/run.sh" - name: Setup Rust toolchain - uses: $/.github/actions/setup-builder - with: - rust-version: ${{ steps.get-msrv.outputs.msrv }} + shell: bash + env: + RUST_VERSION: ${{ steps.get-msrv.outputs.msrv }} + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-builder/run.sh" - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 with: