|
| 1 | +# yaml-language-server: $schema=https://json.schemastore.org/github-action.json |
| 2 | + |
| 3 | +name: "Hyperlight Workflow Setup" |
| 4 | +description: "Common setup steps for GitHub workflows in the Hyperlight project" |
| 5 | + |
| 6 | +inputs: |
| 7 | + rust-toolchain: |
| 8 | + description: "(Default: 1.74.0) Rust toolchain specification to install - see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification" |
| 9 | + required: false |
| 10 | + default: "1.74.0" |
| 11 | + |
| 12 | +runs: |
| 13 | + using: composite |
| 14 | + steps: |
| 15 | + |
| 16 | + - uses: dtolnay/rust-toolchain@master |
| 17 | + with: |
| 18 | + toolchain: ${{ inputs.rust-toolchain }} |
| 19 | + components: clippy, rustfmt |
| 20 | + |
| 21 | + - uses: extractions/setup-just@v1 |
| 22 | + with: |
| 23 | + just-version: "1.25.2" |
| 24 | + |
| 25 | + ### Linux setup ### |
| 26 | + |
| 27 | + - name: Cargo login |
| 28 | + if: ${{ runner.os == 'Linux' }} |
| 29 | + run: just cargo-login-ci |
| 30 | + shell: bash |
| 31 | + |
| 32 | + - name: Install clang-tools (Linux mariner) |
| 33 | + if: ${{ (runner.os == 'Linux') }} |
| 34 | + run: | |
| 35 | + if command -v dnf > /dev/null 2>&1; then |
| 36 | + sudo dnf remove clang -y|| true |
| 37 | + sudo dnf remove lld -y|| true |
| 38 | + sudo dnf install clang16 -y |
| 39 | + sudo dnf install clang16-tools-extra -y |
| 40 | + sudo dnf install lld16 -y |
| 41 | + fi |
| 42 | + shell: bash |
| 43 | + |
| 44 | + - name: Install clang-tools (Linux ubuntu) |
| 45 | + if: ${{ (runner.os == 'Linux') }} |
| 46 | + run: | |
| 47 | + if command -v apt > /dev/null 2>&1; then |
| 48 | + wget https://apt.llvm.org/llvm.sh |
| 49 | + chmod +x ./llvm.sh |
| 50 | + sudo ./llvm.sh 16 all |
| 51 | + sudo ln -s /usr/lib/llvm-16/bin/clang-cl /usr/bin/clang-cl |
| 52 | + sudo ln -s /usr/lib/llvm-16/bin/llvm-lib /usr/bin/llvm-lib |
| 53 | + sudo ln -s /usr/lib/llvm-16/bin/lld-link /usr/bin/lld-link |
| 54 | + sudo ln -s /usr/lib/llvm-16/bin/llvm-ml /usr/bin/llvm-ml |
| 55 | + fi |
| 56 | + shell: bash |
| 57 | + |
| 58 | + # This is needed to build the rust guests |
| 59 | + - name: Install x86_64-pc-windows-msvc target |
| 60 | + if: ${{ (runner.os == 'Linux') }} |
| 61 | + run: | |
| 62 | + rustup target add x86_64-pc-windows-msvc |
| 63 | + shell: bash |
| 64 | + |
| 65 | + - name: Set up env vars (Linux) |
| 66 | + if: ${{ (runner.os == 'Linux') }} |
| 67 | + run: | |
| 68 | + set -x |
| 69 | + if command -v dnf > /dev/null 2>&1; then |
| 70 | + echo "Detected mariner / hyperv" |
| 71 | + echo "HYPERV_SHOULD_BE_PRESENT=true" >> $GITHUB_ENV |
| 72 | + echo "HYPERV_SHOULD_HAVE_STABLE_API=false" >> $GITHUB_ENV |
| 73 | + ls -al /dev/mshv |
| 74 | + whoami |
| 75 | + else |
| 76 | + echo "Detected Ubuntu / kvm" |
| 77 | + echo "KVM_SHOULD_BE_PRESENT=true" >> $GITHUB_ENV |
| 78 | + sudo ls -al /dev/kvm |
| 79 | + sudo chgrp $(whoami) /dev/kvm |
| 80 | + sudo ls -al /dev/kvm |
| 81 | + fi |
| 82 | + echo "RUST_BACKTRACE=1" >> $GITHUB_ENV |
| 83 | + shell: bash |
| 84 | + |
| 85 | + ### Windows setup ### |
| 86 | + |
| 87 | + - name: Cargo login (Windows) |
| 88 | + if: ${{ (runner.os == 'Windows') }} |
| 89 | + run: just cargo-login-ci-windows |
| 90 | + shell: pwsh |
| 91 | + |
| 92 | + - name: Enable WHP on Windows |
| 93 | + if: ${{ (runner.os == 'Windows') }} |
| 94 | + run: Enable-WindowsOptionalFeature -Online -FeatureName HyperVisorPlatform |
| 95 | + shell: pwsh |
| 96 | + |
| 97 | + - name: Install x86_64-pc-windows-msvc target (Windows) |
| 98 | + if: ${{ (runner.os == 'Windows') }} |
| 99 | + run: | |
| 100 | + rustup target add x86_64-pc-windows-msvc |
| 101 | + shell: pwsh |
| 102 | + |
| 103 | + - name: Set up env vars (Windows) |
| 104 | + if: ${{ (runner.os == 'Windows') }} |
| 105 | + run: | |
| 106 | + echo "RUST_BACKTRACE=1" >> $GITHUB_ENV |
| 107 | + shell: pwsh |
0 commit comments