diff --git a/.github/workflows/crates-io.yml b/.github/workflows/crates-io.yml new file mode 100644 index 0000000..99fb64f --- /dev/null +++ b/.github/workflows/crates-io.yml @@ -0,0 +1,111 @@ +name: "Crates.io setup test" + +on: + push: + branches: [ "main" ] + + pull_request: + branches: [ "main" ] + + schedule: + - cron: "0 17 * * 6" # Every Saturday at 17:00 UTC + + workflow_dispatch: {} + +env: + CARGO_TERM_COLOR: always + +permissions: + contents: read + +jobs: + build-and-test: + name: build-and-test (${{ matrix.install }}) + runs-on: ["oneapi-rs", "Linux"] + + strategy: + fail-fast: false + matrix: + install: [vendored, crates-io] + exclude: + # Do not test crates-io on push or pull request events + - install: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') && 'crates-io' || '' }} + + steps: + - name: Checkout repository + if: matrix.install == 'vendored' + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + + - name: Check if oneAPI is already installed + id: check-oneapi + run: | + if [ -f /home/test-user/intel/oneapi/setvars.sh ]; then + echo "installed=true" >> $GITHUB_OUTPUT + source /home/test-user/intel/oneapi/setvars.sh + printenv | grep -E '^(PATH|LD_LIBRARY_PATH|LIBRARY_PATH|CPATH|C_INCLUDE_PATH|CPLUS_INCLUDE_PATH)=' >> $GITHUB_ENV + else + echo "installed=false" >> $GITHUB_OUTPUT + fi + + - name: Setup oneAPI + if: steps.check-oneapi.outputs.installed != 'true' + run: | + installer="intel-oneapi-toolkit-2026.1.0.192_offline.sh" + checksum="9d969de9cafbb698bf50f088c4b5174b50fc816f504049e685d6f6d198e10dbc17ef2cd4cfb0bc2b3d2179644a8d77d1" + curl --fail --location --retry 3 --silent --show-error --output "$installer" \ + "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/33cb2a22-ddf1-4aa9-8d68-1f5a118acaf2/intel-oneapi-toolkit-2026.1.0.192_offline.sh" + echo "$checksum $installer" | sha384sum --check + sh "./$installer" -a --silent --cli --eula accept + + source /home/test-user/intel/oneapi/setvars.sh + printenv | grep -E '^(PATH|LD_LIBRARY_PATH|LIBRARY_PATH|CPATH|C_INCLUDE_PATH|CPLUS_INCLUDE_PATH)=' >> $GITHUB_ENV + + - name: Create vendored source from current checkout + if: matrix.install == 'vendored' + run: | + cargo init --bin "$RUNNER_TEMP/vendor-seed" + cd "$RUNNER_TEMP/vendor-seed" + cargo add sycl-rs --git "file://$GITHUB_WORKSPACE" + cargo vendor --versioned-dirs "$RUNNER_TEMP/vendor" > "$RUNNER_TEMP/vendor-config.toml" + + - name: Query latest version on crates.io + if: matrix.install == 'crates-io' + id: latest + run: | + version=$(cargo search sycl-rs --limit 10 --color never | sed -nE 's/^sycl-rs = "([^"]+)".*/\1/p') + if [ -z "$version" ]; then + echo "::error::Could not find sycl-rs on crates.io" + exit 1 + fi + echo "Latest sycl-rs version: $version" + echo "version=$version" >> "$GITHUB_OUTPUT" + + - name: Create hello world project + env: + VERSION: ${{ steps.latest.outputs.version }} + run: | + cargo init --bin "$RUNNER_TEMP/crates-io-test" + cd "$RUNNER_TEMP/crates-io-test" + if [ -n "$VERSION" ]; then + cargo add "sycl-rs@=$VERSION" + else + mkdir .cargo + cp "$RUNNER_TEMP/vendor-config.toml" .cargo/config.toml + cargo add sycl-rs + fi + cat > src/main.rs <<'RS' + use sycl_rs::prelude::*; + + fn main() { + let platform_count = Platform::get_platforms().len(); + println!("Hello from oneAPI-rs! Found {platform_count} SYCL platform(s)."); + } + RS + + - name: Build + working-directory: ${{ runner.temp }}/crates-io-test + run: cargo build --verbose + + - name: Run hello world + working-directory: ${{ runner.temp }}/crates-io-test + run: cargo run --verbose diff --git a/oneapi-rs/README.md b/oneapi-rs/README.md index ed34465..08c5f90 100644 --- a/oneapi-rs/README.md +++ b/oneapi-rs/README.md @@ -1,5 +1,9 @@ # oneAPI-rs +[![Basic](https://github.com/oneapi-src/oneapi-rs/actions/workflows/basic.yml/badge.svg?event=schedule)](https://github.com/oneapi-src/oneapi-rs/actions/workflows/basic.yml?query=event%3Aschedule) +[![CodeQL](https://github.com/oneapi-src/oneapi-rs/actions/workflows/codeql.yml/badge.svg?event=schedule)](https://github.com/oneapi-src/oneapi-rs/actions/workflows/codeql.yml?query=event%3Aschedule) +[![Crates.io](https://github.com/oneapi-src/oneapi-rs/actions/workflows/crates-io.yml/badge.svg?event=schedule)](https://github.com/oneapi-src/oneapi-rs/actions/workflows/crates-io.yml?query=event%3Aschedule) + Rust bindings for SYCL and the Intel oneAPI programming environment. > [!WARNING]