Skip to content

Commit db5f27b

Browse files
authored
Merge branch 'main' into az-linux-3
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
2 parents dc87cc0 + 6d4c3a8 commit db5f27b

Some content is hidden

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

55 files changed

+4119
-306
lines changed

.devcontainer/Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
git \
18+
gnupg \
19+
gnuplot \
20+
lsb-release \
21+
make \
22+
software-properties-common \
23+
sudo \
24+
wget
25+
26+
ARG LLVM_VERSION=17
27+
28+
# Install llvm
29+
RUN wget https://apt.llvm.org/llvm.sh \
30+
&& chmod +x ./llvm.sh \
31+
&& sudo ./llvm.sh ${LLVM_VERSION} all \
32+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang-cl /usr/bin/clang-cl \
33+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-lib /usr/bin/llvm-lib \
34+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/lld-link /usr/bin/lld-link \
35+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-ml /usr/bin/llvm-ml \
36+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/ld.lld /usr/bin/ld.lld \
37+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang /usr/bin/clang
38+
39+
FROM base AS dev
40+
41+
# Make sure the devcontainer user has sudo access
42+
RUN chown -R "${USER}:${GROUP}" /home/${USER} \
43+
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
44+
45+
# Persist bash hystory
46+
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
47+
&& mkdir /commandhistory \
48+
&& touch /commandhistory/.bash_history \
49+
&& chown -R "${USER}" /commandhistory \
50+
&& echo "$SNIPPET" >> "/home/${USER}/.bashrc"
51+
52+
USER $USER
53+
54+
ARG RUST_TOOLCHAIN=1.81.0
55+
56+
# Install rust
57+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
58+
&& rustup default ${RUST_TOOLCHAIN} \
59+
&& rustup target add x86_64-unknown-linux-gnu \
60+
&& rustup target add x86_64-unknown-none \
61+
&& rustup target add x86_64-pc-windows-msvc \
62+
&& rustup toolchain add nightly-x86_64-unknown-linux-gnu \
63+
&& cargo install just
64+

.devcontainer/devcontainer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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",
5+
6+
"image": "ghcr.io/hyperlight-dev/hyperlight-devcontainer:latest",
7+
8+
"containerUser": "vscode",
9+
// Environment for the container also used by the `postCreateCommand`
10+
"containerEnv": {
11+
"DEVICE": "/dev/kvm",
12+
"KVM_SHOULD_BE_PRESENT": "true",
13+
"REMOTE_USER": "vscode",
14+
"REMOTE_GROUP": "vscode"
15+
},
16+
17+
"runArgs": [
18+
"--device=/dev/kvm"
19+
],
20+
21+
// Use 'postCreateCommand' to run commands after the container is created
22+
"postCreateCommand": "bash .devcontainer/setup.sh",
23+
24+
"customizations": {
25+
"vscode": {
26+
"extensions": [
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+
}
36+
}
37+
}
38+
}

.devcontainer/setup.sh

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

.github/workflows/Benchmarks.yml

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,12 @@ jobs:
1717
strategy:
1818
fail-fast: true
1919
matrix:
20-
build: [
21-
windows-2022-release-amd,
22-
linux-kvm-release-amd,
23-
linux-hyperv-release-amd,
24-
windows-2022-release-intel,
25-
linux-kvm-release-intel,
26-
linux-hyperv-release-intel,
27-
]
28-
include:
29-
- build: windows-2022-release-amd
30-
os: [self-hosted, Windows, X64, "1ES.Pool=hld-win2022-amd"]
31-
hypervisor: hyperv
32-
arch: amd
33-
- build: linux-kvm-release-amd
34-
os: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"]
35-
hypervisor: kvm
36-
arch: amd
37-
- build: linux-hyperv-release-amd
38-
os: [self-hosted, Linux, X64, "1ES.Pool=hld-mshv-amd"]
39-
hypervisor: hyperv
40-
arch: amd
41-
- build: windows-2022-release-intel
42-
os: [self-hosted, Windows, X64, "1ES.Pool=hld-win2022-intel"]
43-
hypervisor: hyperv
44-
arch: intel
45-
- build: linux-kvm-release-intel
46-
os: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-intel"]
47-
hypervisor: kvm
48-
arch: intel
49-
- build: linux-hyperv-release-intel
50-
os: [self-hosted, Linux, X64, "1ES.Pool=hld-mshv-intel"]
51-
hypervisor: hyperv
52-
arch: intel
20+
hypervisor: [hyperv, mshv, kvm] # hyperv is windows, mshv and kvm are linux
21+
cpu: [amd, intel]
22+
config: [release] # don't want to benchmark debug-builds
5323

54-
runs-on: ${{ matrix.os }}
24+
runs-on: ${{ fromJson(format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-{2}"]', matrix.hypervisor == 'hyperv' && 'Windows' || 'Linux', matrix.hypervisor == 'hyperv' && 'win2022' || matrix.hypervisor, matrix.cpu)) }}
25+
5526
steps:
5627
### Setup ###
5728

@@ -90,7 +61,7 @@ jobs:
9061
run: git fetch --tags origin
9162

9263
- name: Download benchmarks from most recent release
93-
run: just bench-download ${{ runner.os }} ${{ matrix.hypervisor }} ${{ matrix.arch }} # skip tag parameter to compare to latest stable release
64+
run: just bench-download ${{ runner.os }} ${{ matrix.hypervisor }} ${{ matrix.cpu }} # skip tag parameter to compare to latest stable release
9465
continue-on-error: true
9566
env:
9667
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -100,6 +71,6 @@ jobs:
10071

10172
- uses: actions/upload-artifact@v4
10273
with:
103-
name: benchmarks_${{runner.os}}_${{matrix.hypervisor}}_${{ matrix.arch }}
74+
name: benchmarks_${{runner.os}}_${{matrix.hypervisor}}_${{ matrix.cpu }}
10475
path: ./target/criterion/
10576
if-no-files-found: error
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Create and publish devcontainer Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- ".devcontainer/Dockerfile"
9+
- ".github/workflows/CreateDevcontainerImage.yml"
10+
- "rust-toolchain.toml"
11+
12+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}-devcontainer
16+
USER: vscode
17+
GROUP: vscode
18+
LLVM_VERSION: 17
19+
RUST_TOOLCHAIN_DEFAULT: 1.81.0
20+
RUST_TOOLCHAIN_FILE: rust-toolchain.toml
21+
22+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
23+
jobs:
24+
build-and-push-image:
25+
runs-on: ubuntu-latest
26+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Read Rust toolchain version from ${{ env.RUST_TOOLCHAIN_FILE }}
36+
id: toolchain
37+
run: |
38+
version=$(cat ${{ env.RUST_TOOLCHAIN_FILE }} | sed -n '/\[toolchain\]/,/^\[/{/^\s*channel = /s/[^"]*"\([^"]*\)".*/\1/p}')
39+
cat ${{ env.RUST_TOOLCHAIN_FILE }} | grep $version &> /dev/null \
40+
&& echo "RUST_TOOLCHAIN=${version}" >> "$GITHUB_OUTPUT" \
41+
|| echo "RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN_FILE }}" >> "$GITHUB_OUTPUT"
42+
43+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
44+
- name: Log in to the Container registry
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Extract metadata (tags, labels) for Docker
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
56+
57+
- name: Build and push Docker image
58+
id: push
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: ./.devcontainer
62+
push: true
63+
tags: |
64+
${{ steps.meta.outputs.tags }}
65+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
66+
labels: ${{ steps.meta.outputs.labels }}
67+
build-args: |
68+
USER=${{ env.USER }}
69+
GROUP=${{ env.GROUP }}
70+
LLVM_VERSION=${{ env.LLVM_VERSION }}
71+
RUST_TOOLCHAIN=${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}

.github/workflows/PRLabelChecker.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- name: Check for specific labels
1616
run: |
17-
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
18-
LABELS_JSON=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
19-
REQUIRED_LABELS=("chore" "ignore" "breaking-change" "enhancement" "feature" "dependencies" "bug" "security" "performance" "refactor" "testing" "documentation" "github-actions")
20-
for REQUIRED_LABEL in "${REQUIRED_LABELS[@]}"; do
21-
if echo "$LABELS_JSON" | grep -q "$REQUIRED_LABEL"; then
22-
echo "One of the required labels is present"
17+
# Fetch repository labels from the GitHub API
18+
REPO_LABELS=$(gh api repos/${{ github.repository }}/labels --jq '.[].name')
19+
20+
# Fetch labels applied to the current PR
21+
PR_NUMBER=${{ github.event.pull_request.number }}
22+
PR_LABELS=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
23+
24+
# Check if any PR label matches a repository label
25+
for PR_LABEL in $PR_LABELS; do
26+
if echo "$REPO_LABELS" | grep -qw "$PR_LABEL"; then
27+
echo "Label '$PR_LABEL' matches a repository label."
2328
exit 0
2429
fi
2530
done
26-
echo "None of the required labels are present"
31+
32+
echo "None of the PR labels match repository labels."
2733
exit 1
2834
env:
29-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ValidatePullRequest.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
branches: [main, "release/**"]
88
merge_group:
99

10+
# Cancels old running job if a new one is triggered (e.g. by a push onto the same branch).
11+
# This will cancel dependent jobs as well, such as dep_rust and dep_fuzzing
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
1016
permissions:
1117
id-token: write
1218
contents: read
@@ -42,6 +48,7 @@ jobs:
4248
secrets: inherit
4349
with:
4450
docs_only: ${{needs.docs-pr.outputs.docs-only}}
51+
4552
fuzzing:
4653
needs:
4754
- docs-pr
@@ -51,6 +58,14 @@ jobs:
5158
docs_only: ${{needs.docs-pr.outputs.docs-only}}
5259
secrets: inherit
5360

61+
spelling:
62+
name: spell check with typos
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- name: Spell Check Repo
67+
uses: crate-ci/typos@master
68+
5469
#####
5570
# start build-on-windows
5671
#####

0 commit comments

Comments
 (0)