Skip to content

Commit 683c93b

Browse files
committed
The initial hyperlight-wasm commit 🎉
Co-authored-by: Aaron Schlesinger <aaron@ecomaz.net> Co-authored-by: Mark Rossetti <marosset@microsoft.com> Co-authored-by: Simon Davies <simongdavies@users.noreply.github.com> Co-authored-by: Ludvig Liljenberg <lliljenberg@microsoft.com> Co-authored-by: Shyam Rajendran <rshyam.psg@gmail.com> Co-authored-by: David Justice <devigned@users.noreply.github.com> Co-authored-by: Dan Chiarlone <dchiarlone@microsoft.com> Co-authored-by: Pooja Trivedi <poojatrivedi@microsoft.com>
0 parents  commit 683c93b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+13023
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
## Dockerfile for devcontainer
2+
3+
FROM mcr.microsoft.com/devcontainers/base:debian AS base
4+
5+
ARG USER=vscode
6+
ARG GROUP=vscode
7+
8+
ENV HOME="/home/${USER}"
9+
ENV PATH="$HOME/.cargo/bin:$PATH"
10+
11+
# Install dependencies
12+
RUN apt-get update \
13+
&& apt-get -y install \
14+
build-essential \
15+
cmake \
16+
curl \
17+
gdb \
18+
git \
19+
gnupg \
20+
gnuplot \
21+
lsb-release \
22+
make \
23+
software-properties-common \
24+
sudo \
25+
wget \
26+
netcat-openbsd
27+
28+
ARG GCC_VERSION=12
29+
30+
RUN apt-get install -y g++-multilib \
31+
&& apt-get install -y libgcc-${GCC_VERSION}-dev \
32+
&& apt-get install -y lib32gcc-${GCC_VERSION}-dev
33+
34+
ARG LLVM_VERSION=17
35+
36+
# Install llvm
37+
RUN wget https://apt.llvm.org/llvm.sh \
38+
&& chmod +x ./llvm.sh \
39+
&& sudo ./llvm.sh ${LLVM_VERSION} all \
40+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang-cl /usr/bin/clang-cl \
41+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-lib /usr/bin/llvm-lib \
42+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/lld-link /usr/bin/lld-link \
43+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-ml /usr/bin/llvm-ml \
44+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/ld.lld /usr/bin/ld.lld \
45+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang /usr/bin/clang
46+
47+
FROM base AS dev
48+
49+
# Make sure the devcontainer user has sudo access
50+
RUN chown -R "${USER}:${GROUP}" /home/${USER} \
51+
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
52+
53+
# Persist bash history
54+
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
55+
&& mkdir /commandhistory \
56+
&& touch /commandhistory/.bash_history \
57+
&& chown -R "${USER}" /commandhistory \
58+
&& echo "$SNIPPET" >> "/home/${USER}/.bashrc"
59+
# Install python3
60+
ARG WASI_SDK_VERSION_FULL=20.0
61+
ARG WASI_SDK_VERSION_MAJOR=${WASI_SDK_VERSION_FULL%%.*}
62+
# Install wasi-sdk
63+
RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION_MAJOR}/wasi-sdk-${WASI_SDK_VERSION_FULL}-linux.tar.gz \
64+
&& tar xvf wasi-sdk-${WASI_SDK_VERSION_FULL}-linux.tar.gz \
65+
&& rm wasi-sdk-${WASI_SDK_VERSION_FULL}-linux.tar.gz \
66+
&& mv /wasi-sdk-${WASI_SDK_VERSION_FULL} /opt/wasi-sdk
67+
68+
USER $USER
69+
70+
ARG RUST_TOOLCHAIN=1.82.0
71+
72+
# Install rust
73+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
74+
&& rustup default ${RUST_TOOLCHAIN} \
75+
&& rustup target add x86_64-unknown-linux-gnu \
76+
&& rustup target add x86_64-unknown-none \
77+
&& rustup target add x86_64-pc-windows-msvc \
78+
&& rustup toolchain add nightly-x86_64-unknown-linux-gnu \
79+
&& cargo install just \
80+
&& cargo install --locked wasm-tools \
81+
&& cargo install wkg

.devcontainer/devcontainer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// For more info on the configuration below, check out the link:
2+
// https://code.visualstudio.com/docs/devcontainers/create-dev-container
3+
{
4+
"name": "Hyperlight-Wasm",
5+
"image": "ghcr.io/hyperlight-dev/hyperlight-wasm-devcontainer:latest",
6+
7+
"containerUser": "vscode",
8+
// Environment for the container also used by the `postCreateCommand`
9+
"containerEnv": {
10+
"DEVICE": "/dev/kvm",
11+
"REMOTE_USER": "vscode",
12+
"REMOTE_GROUP": "vscode"
13+
},
14+
15+
"runArgs": [
16+
"--device=/dev/kvm"
17+
],
18+
19+
// use `postStartCommand` for additional setup commands
20+
// this is run after the container is created and the user has been added
21+
"postStartCommand": "bash .devcontainer/setup.sh",
22+
23+
"customizations": {
24+
"vscode": {
25+
"extensions": [
26+
"ms-vscode.cpptools-extension-pack",
27+
"ms-vscode.cmake-tools",
28+
"rust-lang.rust-analyzer",
29+
"vadimcn.vscode-lldb"
30+
],
31+
"settings": {
32+
"rust-analyzer.rustfmt.extraArgs": [
33+
"+nightly" // required for rustfmt.toml which uses nightly features
34+
],
35+
// This is needed to allow tests to find files when running under the debugger
36+
"rust-analyzer.runnables.extraEnv": {
37+
"RUST_DIR_FOR_DEBUGGING_TESTS": "${workspaceFolder}/src/hyperlight_wasm"
38+
}
39+
}
40+
}
41+
}
42+
}
43+

.devcontainer/setup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Change device ownership
4+
sudo chown -R $REMOTE_USER:$REMOTE_GROUP $DEVICE

.editorconfig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Reference: https://github.com/dotnet/roslyn/blob/main/.editorconfig
2+
# EditorConfig is awesome: https://EditorConfig.org
3+
4+
# top-most EditorConfig file
5+
root = true
6+
[*]
7+
indent_style = space
8+
indent_size = 4
9+
insert_final_newline = true
10+
charset = utf-8
11+
12+
# JSON files
13+
[*.json]
14+
indent_size = 2
15+
16+
# YAML files
17+
[*.yml]
18+
indent_size = 2
19+
[*.yaml]
20+
indent_size = 2
21+
22+
# Powershell files
23+
[*.ps1]
24+
indent_size = 2
25+
26+
# Shell script files
27+
[*.sh]
28+
end_of_line = lf
29+
indent_size = 2

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
target-branch: "main"
8+
- package-ecosystem: "cargo"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"
12+
target-branch: "main"

.github/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# .github/release.yml
2+
3+
changelog:
4+
categories:
5+
- title: Full Changelog (excl. dependencies)
6+
labels:
7+
- "*"
8+
- title: Full Changelog (dependencies)
9+
labels:
10+
- kind/dependencies

.github/workflows/Benchmarks.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: Benchmarks
4+
5+
on:
6+
workflow_call: # this is called from CreateRelease.yml
7+
8+
# The reason for default shell bash is because on our self-hosted windows runners,
9+
# the default shell is powershell, which doesn't work correctly together with `just` commands.
10+
# Even if a command inside a just-recipe fails, github reports the step as successful.
11+
# The problem may or may not be related to our custom windows runner not applying the
12+
# powershell steps outlined here
13+
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
build-wasm-examples:
20+
uses: ./.github/workflows/dep_build_wasm_examples.yml
21+
22+
benchmark:
23+
needs:
24+
- build-wasm-examples
25+
strategy:
26+
fail-fast: true
27+
matrix:
28+
hypervisor: [hyperv, mshv, mshv3, kvm] # hyperv is windows, mshv and kvm are linux
29+
cpu: [amd, intel]
30+
config: [release] # don't want to benchmark debug-builds
31+
32+
runs-on: ${{ fromJson(format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-{2}"]', matrix.hypervisor == 'hyperv' && 'Windows' || 'Linux', matrix.hypervisor == 'hyperv' && 'win2022' || matrix.hypervisor == 'mshv3' && 'azlinux3-mshv' || matrix.hypervisor, matrix.cpu)) }}
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- uses: hyperlight-dev/ci-setup-workflow@v1.3.0
38+
with:
39+
rust-toolchain: "1.82.0"
40+
41+
- name: Build Wasm Runtime Binary
42+
working-directory: ./src/hyperlight_wasm
43+
run: just build-wasm-runtime ${{ matrix.config }}
44+
45+
- uses: dtolnay/rust-toolchain@1.82.0
46+
with:
47+
components: clippy, rustfmt
48+
49+
- name: Download Wasm Modules
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: guest-modules
53+
path: ./x64/${{ matrix.config }}
54+
55+
### Benchmarks ###
56+
57+
# Install GH cli (needed for just bench-download)
58+
- name: Install github-cli (Linux mariner)
59+
if: runner.os == 'Linux' && matrix.hypervisor == 'mshv' || matrix.hypervisor == 'mshv3'
60+
run: sudo dnf install gh -y
61+
62+
- name: Install github-cli (Linux ubuntu)
63+
if: runner.os == 'Linux' && matrix.hypervisor == 'kvm'
64+
run: sudo apt install gh -y
65+
66+
- name: Fetch tags
67+
run: |
68+
git fetch --tags origin
69+
70+
- name: Download benchmark from most recent release
71+
run: |
72+
just bench-download ${{ runner.os }} ${{ matrix.hypervisor }}
73+
continue-on-error: true
74+
working-directory: ./src/hyperlight_wasm
75+
env:
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Run Benchmarks
79+
run: |
80+
just bench-ci dev release
81+
working-directory: ./src/hyperlight_wasm
82+
83+
- name: Upload Benchmarks
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: benchmarks_${{runner.os}}_${{matrix.hypervisor}}
87+
path: ./target/criterion/
88+
if-no-files-found: error

.github/workflows/CargoAudit.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Audit cargo dependencies for security vulnerabilities
2+
on:
3+
schedule:
4+
- cron: "0 8 * * 1" # run at 8am every Monday
5+
workflow_dispatch: # allow manual triggering
6+
7+
permissions:
8+
issues: write # Creates issues for any vulnerabilities found
9+
contents: read
10+
checks: write # Needs to create check
11+
12+
jobs:
13+
audit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
# We are not using the common workflow here because it installs a lot of tools we don't need
19+
- uses: dtolnay/rust-toolchain@master
20+
with:
21+
toolchain: "1.82.0"
22+
23+
- uses: extractions/setup-just@v3
24+
with:
25+
just-version: "1.27"
26+
27+
- uses: rustsec/audit-check@v2.0.0
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/CleanUp.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
# This job cleans up old pre-releases and pre-releases packages retaining the last 40 versions
3+
4+
name: Clean up old pre-releases and packages
5+
on:
6+
schedule:
7+
- cron: '0 8 * * 1' # run at 8am every Monday
8+
workflow_dispatch: # allow manual triggering
9+
permissions:
10+
actions: write # required for reading & deleting github actions artifacts
11+
contents: write # required for reading releases
12+
jobs:
13+
cleanup:
14+
name: Clean up old pre-releases and packages
15+
runs-on: ubuntu-latest
16+
steps:
17+
# https://github.com/marketplace/actions/delete-releases
18+
- name: Delete old 'hyperlight-wasm' releases
19+
uses: sgpublic/delete-release-action@v1.2
20+
with:
21+
release-drop: false
22+
pre-release-drop: true
23+
pre-release-keep-count: 5
24+
pre-release-drop-tag: true
25+
draft-drop: false
26+
env:
27+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)