coreutils 0.11.0

coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust
Documentation
# spell-checker:ignore wasip wasmtime oniguruma sysroot
name: WASI

# spell-checker:ignore TRIGGERPATH
on:
  pull_request:
  push:
    branches:
      - main

permissions:
  contents: read

# End the current execution if there is a new changeset in the PR.
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
  test_wasi:
    name: Tests
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        job:
          - { target: wasm32-wasip1, rust-flags: "--cfg wasi_runner" }
          - { target: wasm32-wasip2, rust-flags: "--cfg wasi_runner --cfg wasip2_runner"  }
    steps:
    - uses: actions/checkout@v7.0.1
      with:
        persist-credentials: false
    - uses: dtolnay/rust-toolchain@stable
      with:
        targets: ${{ matrix.job.target }}
    - uses: Swatinem/rust-cache@v2
      with:
        key: "${{ matrix.job.target }}"
    - name: Install WASI sysroot
      run: |
        # expr depends on oniguruma, a C library, so cross-compiling needs a WASI sysroot
        WASI_SDK=wasi-sdk-25.0-x86_64-linux
        curl -sSfL "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/${WASI_SDK}.tar.gz" | tar -xz -C "$HOME"
        for abi in wasip1 wasip2; do
          echo "CC_wasm32_${abi}=$HOME/${WASI_SDK}/bin/clang" >> $GITHUB_ENV
          echo "AR_wasm32_${abi}=$HOME/${WASI_SDK}/bin/llvm-ar" >> $GITHUB_ENV
        done
    - name: Install wasmtime
      run: |
        curl https://wasmtime.dev/install.sh -sSf | bash
        echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
    - name: Run unit tests
      env:
        CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime
        CARGO_TARGET_WASM32_WASIP2_RUNNER: wasmtime
      run: |
        # Get all utilities and exclude ones that don't compile for ${{ matrix.job.target }}
        EXCLUDE="df|du|env|more|tac"
        UTILS=$(./util/show-utils.sh | tr ' ' '\n' | grep -vE "^($EXCLUDE)$" | sed 's/^/-p uu_/' | tr '\n' ' ')
        cargo test --target ${{ matrix.job.target }} --no-default-features $UTILS
    - name: Run integration tests via wasmtime
      if:  matrix.job.target == 'wasm32-wasip1'
      env:
        RUSTFLAGS: ${{ matrix.job.rust-flags }}
      run: |
        # Build the WASI binary
        cargo build --target ${{ matrix.job.target }} --no-default-features --features feat_wasm
        # Run host-compiled integration tests against the WASI binary.
        # Tests incompatible with WASI are annotated with
        # #[cfg_attr(wasi_runner, ignore)] in the test source files.
        # The binary above is built without default features, so it has no
        # caret diagnostics; the host test crate does have them, hence the
        # not(wasi_runner) in the cfg guarding every `mod diagnostics`.
        # TODO: add integration tests for these tools as WASI support is extended:
        #   arch b2sum cksum csplit date dir dircolors fmt join
        #   ls md5sum mkdir mv nproc pathchk pr printenv ptx pwd readlink
        #   realpath rm rmdir seq sha1sum sha224sum sha256sum sha384sum
        #   sha512sum shred sleep sort split tail tsort uname uniq
        #   vdir
        UUTESTS_BINARY_PATH="$(pwd)/target/${{ matrix.job.target }}/debug/coreutils.wasm" \
        UUTESTS_WASM_RUNNER=wasmtime \
        cargo test --test tests -- \
          test_base32:: test_base64:: test_basenc:: test_basename:: \
          test_cp::test_cp_arg_symlink \
          test_cat:: test_comm:: test_cut:: test_dirname:: test_echo:: \
          test_expand:: test_expr:: test_factor:: test_false:: test_fold:: \
          test_head:: test_link:: test_ln:: test_nl:: test_numfmt:: \
          test_od:: test_paste:: test_printf:: test_shuf:: test_sum:: \
          test_tee:: test_test:: test_touch:: test_tr:: test_true:: \
          test_truncate:: \
          test_unexpand:: test_unlink:: test_wc:: test_yes::