Skip to content

Commit f5da1e8

Browse files
authored
Initial commit for action.yml (#1)
* Initial commit for action.yml
1 parent 2a1e176 commit f5da1e8

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
# When a new Tag with the prefix v is pushed to the repository, this workflow will create a new release branch called release/<tag name>.
4+
5+
name: Create a Release Branch
6+
7+
on:
8+
push:
9+
tags:
10+
- "v*"
11+
12+
permissions:
13+
contents: write # needed to push the new branch
14+
15+
jobs:
16+
create-branch:
17+
runs-on: ubuntu-20.04
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Create Release Branch
23+
run: |
24+
git checkout -b release/${GITHUB_REF_NAME}
25+
git push --set-upstream origin release/${GITHUB_REF_NAME}
26+
shell: bash

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
11
# Hyperlight Workflow Setup
22

33
This github action performs common setup for running GitHub workflows for the [hyperlight](https://github.com/deislabs/hyperlight) project.
4+
5+
## Example Usage
6+
7+
```yaml
8+
jobs:
9+
setup:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- uses: deislabs/hyperlight-workflow-setup@dev
15+
with:
16+
rust-toolchain: "1.74.0"
17+
env:
18+
PAT: $ {{ secrets.ADO_CARGO_RO_PAT }}
19+
```
20+
21+
## Inputs
22+
23+
### Parameters
24+
25+
| Name | Description |
26+
| ---- | ----------- |
27+
| `rust-toolchain` | The rust toolchain version to use. |
28+
29+
### Environment Variables
30+
31+
| Name | Description |
32+
| ---- | ----------- |
33+
| `PAT` | The Personal Access Token to use for logging into the Hyperlight cargo feeds in Azure DevOps. |
34+
35+
## Overview
36+
37+
This action performs the following steps:
38+
39+
- Runs `cargo login` to log into the Hyperlight cargo feeds in Azure DevOps.
40+
- Installs the Rust tool chain at the specified version.
41+
- Installs additional rust components like clippy, rustfmt, ect
42+
- Installs Just
43+
- Sets up the clang toolchain on Linux machines (this should probably get moved into the hosted runner image setup...)
44+
- Installs the `x86_64-pc-windows-msvc` rust target for cross-compilation on Linux machines
45+
- Sets up environment variables needed to build / run tests based on the machine's configuration.

action.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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

Comments
 (0)