krnl 0.1.1

Safe, portable, high performance compute (GPGPU) kernels.
Documentation
name: CI
on:
  push:
    branches:
      - main
    paths-ignore:
      - '**.md'
  pull_request:
    paths-ignore:
      - '**.md'
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true
env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  CARGO_INCREMENTAL: 0
jobs:
  test:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 20
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: windows-latest
            target: x86_64-pc-windows-msvc
          - os: macos-latest
            target: x86_64-apple-darwin
    steps:
    - uses: actions/checkout@v4
    - name: install toolchains
      run: |
        rustup set profile minimal
        rustup toolchain install stable --component rust-docs --no-self-update
        rustup toolchain install nightly --component miri --no-self-update
        rustup toolchain install nightly-2023-05-27 --component rust-src  rustc-dev  llvm-tools-preview --no-self-update
    - name: build
      run: cargo build --workspace --features serde --all-targets -v
    - name: test
      run: |
        cargo test --workspace --no-default-features --features serde -v
        cargo test -p compute-benches --benches --no-default-features -v
    - name: miri test
      run: |
        cargo update half@2 --precise 2.2.0 # miri doesn't support asm!
        cargo +nightly miri test --tests --no-default-features --features serde -v
        cargo update half@2
    - name: install wasm-pack
      run: cargo install wasm-pack -vv
    - name: wasm test safari
      if: ${{ runner.os == 'macOS' }}
      run: wasm-pack test --headless --safari -- --no-default-features --features serde -vv
      env:
        RUSTFLAGS: --cfg run_in_browser
    - name: wasm test
      run: wasm-pack test --headless --firefox -- --no-default-features --features serde -vv
      env:
        RUSTFLAGS: --cfg run_in_browser
      continue-on-error: ${{ runner.os == 'macOS' }}
  krnlc:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 20
    env:
      # spirv tools install copied from https://github.com/EmbarkStudios/rust-gpu/blob/main/.github/workflows/ci.yaml
      spirv_tools_version: "20221024"
      # NOTE(eddyb) do not forget to update both the above date and below links!
      # FIXME(eddyb) automate this somewhat by taking advantage of the bucket APIs,
      # and look for the first build with the date in `spirv_tools_version`.
      spirv_tools_linux_url: "https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1863/20221024-094528/install.tgz"
      spirv_tools_macos_url: "https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/macos-clang-release/continuous/1875/20221024-094531/install.tgz"
      spirv_tools_windows_url: "https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-release/continuous/1851/20221024-094908/install.zip"
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: windows-latest
            target: x86_64-pc-windows-msvc
          - os: macos-latest
            target: x86_64-apple-darwin
    # spirv tools install copied from https://github.com/EmbarkStudios/rust-gpu/blob/main/.github/workflows/ci.yaml
    steps:
    - uses: actions/checkout@v4
    - name: install toolchains
      run: |
        rustup set profile minimal
        rustup toolchain install stable nightly --no-self-update
        rustup toolchain install nightly-2023-05-27 --component rust-src  rustc-dev  llvm-tools-preview --no-self-update
    - if: ${{ runner.os == 'Linux' }}
      name: Linux - Install native dependencies and spirv-tools
      run: |
        sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
        mkdir "${HOME}/spirv-tools"
        curl -fL "$spirv_tools_linux_url" | tar -xz -C "${HOME}/spirv-tools"
        echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
    - if: ${{ runner.os == 'macOS' }}
      name: Mac - Install spirv-tools
      # FIXME(eddyb) deduplicate with Linux (and maybe even Windows?).
      run: |
        mkdir "${HOME}/spirv-tools"
        curl -fL "$spirv_tools_macos_url" | tar -xz -C "${HOME}/spirv-tools"
        echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
    - if: ${{ runner.os == 'Windows' }}
      name: Windows - Install spirv-tools
      shell: bash
      run: |
        tmparch=$(mktemp)
        mkdir "${HOME}/spirv-tools"
        curl -fL -o "$tmparch" "$spirv_tools_windows_url"
        unzip "$tmparch" -d "${HOME}/spirv-tools"
    - if: ${{ runner.os == 'Windows' }}
      # Runs separately to add spir-v tools to Powershell's Path.
      run: echo "$HOME/spirv-tools/install/bin" >> $env:GITHUB_PATH
    # end install spirv-tools
    - uses: actions/checkout@v4
    - name: check krnlc
      run: cargo +nightly-2023-05-27 -Zunstable-options -C=krnlc check --locked --no-default-features --features use-installed-tools -vv
    - name: install krnlc
      run: cargo +nightly-2023-05-27 install --path krnlc --root . --locked --no-default-features --features use-installed-tools -vv --debug
    - name: krnlc check
      run: ./bin/krnlc --check -p krnl -p krnlc-tests -p compute-benchmarks -v
  lint:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
    - uses: actions/checkout@v4
    - name: install toolchains
      run: |
        rustup set profile minimal
        rustup toolchain install stable --component rustfmt clippy rust-docs --no-self-update
        rustup toolchain install nightly 1.70.0 --no-self-update
        rustup toolchain install nightly-2023-05-27 --component rustfmt clippy rust-src rustc-dev llvm-tools-preview --no-self-update
    - name: fmt
      run: cargo fmt --check
    - name: krnlc fmt
      run: cargo +nightly-2023-05-27 fmt --check --manifest-path krnlc/Cargo.toml
    - name: install cargo-hack
      run: cargo install cargo-hack
    - name: clippy
      env:
        CARGO_ALIAS_CLIPPYALL: clippy --workspace
      run: cargo hack --feature-powerset --skip default clippyall --all-targets -v -- -D warnings -A unexpected_cfgs
    - name: krnlc clippy
      run: cargo +nightly-2023-05-27 clippy --manifest-path krnlc/Cargo.toml --no-default-features --features use-installed-tools -v -- -D warnings
    - name: rustdoc
      run: |
        cargo hack -p krnl -p krnl-macros -p krnl-core --feature-powerset --skip default rustdoc -v -- --D warnings -A unexpected_cfgs
        cargo +nightly hack -p krnl -p krnl-core  rustdoc --all-features -v -- --cfg doc_cfg --D warnings -A unexpected_cfgs
    - name: msrv
      run: |
        cargo +nightly generate-lockfile -Zmsrv-policy --config "resolver.something-like-precedence='something-like-rust-version'"
        cat Cargo.lock
        cargo +1.70.0 check --workspace --features serde --all-targets -v
  deny:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
    - uses: actions/checkout@v4
    - uses: EmbarkStudios/cargo-deny-action@v1
    - uses: EmbarkStudios/cargo-deny-action@v1
      with:
        manifest-path: "krnlc/Cargo.toml"