diff --git a/.github/actions/criticalup-config/action.yml b/.github/actions/criticalup-config/action.yml new file mode 100644 index 00000000..c1845058 --- /dev/null +++ b/.github/actions/criticalup-config/action.yml @@ -0,0 +1,110 @@ +# SPDX-FileCopyrightText: The Ferrocene Developers +# SPDX-License-Identifier: MIT OR Apache-2.0 + +--- + +name: "Install criticalup" +description: "Configure repo for criticalup use" +inputs: + token: + description: The CriticalUp token to use (use a GHA Secret) + required: true + path: + description: The installation path + required: true + matrix: + description: Platforms to run on + required: true + runner: + description: OS to run + required: true + +runs: + using: composite + steps: + + - name: Establish paths inside composite action + shell: bash + run: | + echo "pwd $(pwd)" + echo "input path: ${{ inputs.path }}" + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: criticalup-${{ matrix.target }}.${{ runner.os == 'Windows' && 'zip' || 'tar.xz' }} + path: ${{ inputs.path }} + + - name: Unpack archive + shell: bash + if: ${{ runner.os == 'Windows' }} + working-directory: ${{ inputs.path }} + run: | + powershell -c "Expand-Archive criticalup-${{ matrix.target }}.zip" + echo "working-directory: ${{ github.workspace }}/${{ inputs.path }}" + mv criticalup-${{ matrix.target }}/criticalup.exe criticalup.exe + + - name: Unpack archive and make executable + shell: bash + if: ${{ runner.os != 'Windows' }} + working-directory: ${{ inputs.path }} + run: | + tar xvf criticalup-${{ matrix.target }}.tar.xz + mv criticalup-${{ matrix.target }}/criticalup criticalup + chmod +x ./criticalup + + - name: Auth Criticalup + shell: bash + working-directory: ${{ inputs.path }} + run: ./criticalup auth set $CRITICALUP_TOKEN + + - name: Install toolchain + shell: bash + working-directory: ${{ inputs.path }} + run: | + ./criticalup install + + - name: Create toolchain link + shell: bash + working-directory: ${{ inputs.path }} + run: | + ./criticalup link create + + - name: Run `criticalup run` test workflow + shell: bash + working-directory: ${{ inputs.path }} + run: | + # We cannot run cargo init, it is an existing project + ./criticalup run -- cargo build + ./criticalup run -- cargo run --bin criticalup help + ./criticalup which rustc + + # Windows allows the `.exe` or not at the users option. + - name: Run Windows exclusive commands + shell: bash + if: ${{ runner.os == 'Windows' }} + working-directory: ${{ inputs.path }} + run: | + ./criticalup.exe run -- cargo --version + ./criticalup run -- cargo.exe --version + ./criticalup.exe run -- cargo.exe --version + + - name: Run `cargo +ferrocene` test workflow + shell: bash + working-directory: ${{ inputs.path }} + run: | + cargo +ferrocene build + cargo +ferrocene run --bin criticalup help + + - name: Remove toolchain link + shell: bash + working-directory: ${{ inputs.path }} + run: | + ./criticalup link remove + + - name: Run test cleanup workflow + shell: bash + working-directory: ${{ inputs.path }} + run: | + ./criticalup remove + ./criticalup clean diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5f43821..f260756e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,74 +74,83 @@ jobs: ] EOF - - uses: actions/download-artifact@v4 - with: - name: criticalup-${{ matrix.target }}.${{ runner.os == 'Windows' && 'zip' || 'tar.xz' }} - path: crab-boil - - - name: Unpack archive - if: ${{ runner.os == 'Windows' }} - working-directory: crab-boil + - name: Establish paths inside workflow before calling action + shell: bash run: | - powershell -c "Expand-Archive criticalup-${{ matrix.target }}.zip" - mv criticalup-${{ matrix.target }}/criticalup.exe criticalup.exe - - - name: Unpack archive and make executable - if: ${{ runner.os != 'Windows' }} - working-directory: crab-boil - run: | - tar xvf criticalup-${{ matrix.target }}.tar.xz - mv criticalup-${{ matrix.target }}/criticalup criticalup - chmod +x ./criticalup - - - name: Auth Criticalup - working-directory: crab-boil - run: ./criticalup auth set $CRITICALUP_TOKEN + echo "pwd $(pwd)" + echo "github.workspace: ${{ github.workspace }}" + echo "runner.temp: ${{ runner.temp }}" + echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE" + echo "runner temp env variable $RUNNER_TEMP" - - name: Install toolchain - working-directory: crab-boil - run: | - ./criticalup install - - - name: Create toolchain link - working-directory: crab-boil - run: | - ./criticalup link create - - - name: Run `criticalup run` test workflow - working-directory: crab-boil - run: | - ./criticalup run -- cargo init - ./criticalup run -- cargo build - ./criticalup run -- cargo run - ./criticalup which rustc - - # Windows allows the `.exe` or not, at the users option. - - name: Run Windows exclusive commands - if: ${{ runner.os == 'Windows' }} - working-directory: crab-boil + - name: Configure directory + uses: ./.github/actions/criticalup-config + with: + token: ${{ secrets.CRITICALUP_TOKEN }} + path: crab-boil + matrix: ${{ toJSON(matrix) }} + runner: ${{ toJSON(runner) }} + + - name: Establish paths inside workflow after calling action + shell: bash run: | - ./criticalup.exe run -- cargo --version - ./criticalup run -- cargo.exe --version - ./criticalup.exe run -- cargo.exe --version + echo "pwd $(pwd)" + echo "github.workspace: ${{ github.workspace }}" + echo "runner.temp: ${{ runner.temp }}" + echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE" + echo "runner temp env variable $RUNNER_TEMP" - - name: Run `cargo +ferrocene` test workflow + - name: Test criticalup is still installed current dir working-directory: crab-boil + run: ./criticalup help + + - name: Change toolchain and dir to test RA installation + shell: bash # bash necessary for heredocs run: | - cargo +ferrocene build - cargo +ferrocene run + mkdir poor-ferris + cd poor-ferris + cat <<- EOF > criticalup.toml + manifest-version = 1 - - name: Remove toolchain link - working-directory: crab-boil + [products.ferrocene] + release = "nightly-2026-01-29" + packages = [ + "cargo-\${rustc-host}", + "rustc-\${rustc-host}", + "rust-std-\${rustc-host}", + "rust-analyzer-\${rustc-host}" + ] + EOF + - name: Rust-toolchain file + working-directory: poor-ferris + shell: bash run: | - ./criticalup link remove + cat <<- EOF > rust-toolchain.toml + [toolchain] + channel = "ferrocene" + components = ["cargo", "rustfmt", "clippy", "rust-analyzer"] + profile = "default" + EOF - - name: Run test cleanup workflow - working-directory: crab-boil + - name: Configure directory + uses: ./.github/actions/criticalup-config + with: + token: ${{ secrets.CRITICALUP_TOKEN }} + path: poor-ferris + matrix: ${{ toJSON(matrix) }} + runner: ${{ toJSON(runner) }} + + - name: Test RA installation + shell: bash # bash necessary for heredocs + working-directory: poor-ferris run: | - ./criticalup remove - ./criticalup clean + echo ${{ github.workspace }} + ./criticalup install --reinstall + ./criticalup link create # linking rust-analyzer + ./criticalup which rust-analyzer + which rust-analyzer + rust-analyzer --version package: secrets: inherit diff --git a/crates/criticalup-cli/tests/cli/binary_proxies.rs b/crates/criticalup-cli/tests/cli/binary_proxies.rs index 214f658a..e2550e21 100644 --- a/crates/criticalup-cli/tests/cli/binary_proxies.rs +++ b/crates/criticalup-cli/tests/cli/binary_proxies.rs @@ -3,7 +3,6 @@ use crate::assert_output; use crate::utils::TestEnvironment; -use std::env; use std::io::Write; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio};