cargo-hyperlight 0.1.12

cargo subcommand to build hyperlight guest binaries
Documentation
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json

name: CI
permissions:
  contents: read

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_call:

# Cancels old running job if a new one is triggered (e.g. by a push onto the same branch).
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always

jobs:
  run-tests:
    name: Run tests on ${{ matrix.environment }} ${{ matrix.os }}
    strategy:
      matrix:
        os: [ "ubuntu-latest", "windows-latest" ]
        environment: [ "HL", "GH" ]
    runs-on: ${{ fromJson(
        matrix.environment == 'HL' &&
          format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-amd", "JobId=cargo-hyperlight-{2}-{3}-{4}"]',
            matrix.os == 'windows-latest' && 'Windows' || 'Linux',
            matrix.os == 'windows-latest' && 'win2025' || 'kvm',
            github.run_id,
            github.run_number,
            github.run_attempt)
        || format('["{0}"]', matrix.os) ) }}
    steps:
    - uses: actions/checkout@v7
    - uses: actions-rust-lang/setup-rust-toolchain@v1
    - uses: Swatinem/rust-cache@v2
    - uses: extractions/setup-just@v4
    - name: Enable kvm
      if: runner.os == 'Linux' && runner.arch == 'X64' && matrix.environment == 'GH'
      run: |
        echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
        sudo udevadm control --reload-rules
        sudo udevadm trigger --name-match=kvm
    - name: Install cargo-hyperlight
      shell: bash
      run: just install
    - name: Build guest example
      shell: bash
      run: just build-guest
    - name: Run example
      if: runner.arch == 'X64'
      shell: bash
      run: just run-guest
    - name: Build C guest example
      shell: bash
      run: just build-c-guest
    - name: Run C guest example
      shell: bash
      run: just run-c-guest
    - name: Run other tests
      shell: bash
      run: just test

  spelling:
    name: Spell check with typos
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v7
    - name: Spell Check Repo
      uses: crate-ci/typos@master
  
  check:
    name: Lint on ${{ matrix.os }}
    strategy:
      matrix:
        os: ["ubuntu-latest", "windows-latest"]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v7
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rustfmt, clippy
      - uses: extractions/setup-just@v4
      - name: Setup nightly toolchain
        shell: bash
        run: rustup toolchain install nightly --component rustfmt # needed to run rustfmt in nightly toolchain
      - name: Install cargo-hyperlight
        shell: bash
        run: just install
      - name: Check formatting
        shell: bash
        run: just fmt
      - name: Check clippy
        shell: bash
        run: just clippy