Skip to content

Commit

Permalink
Add CI scripts
Browse files Browse the repository at this point in the history
Signed-off-by: James Sturtevant <[email protected]>
Signed-off-by: James Sturtevant <[email protected]>
  • Loading branch information
jsturtevant committed Aug 10, 2023
1 parent 818bf91 commit 8c1e606
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
sudo apt -y update
sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev
sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev libssl-dev
3 changes: 3 additions & 0 deletions .github/scripts/build-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
choco install -y wasmedge
choco install -y llvm
39 changes: 29 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,61 @@ env:

jobs:
fmt:
runs-on: "ubuntu-latest"
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile
- name: Setup OCI runtime build env
run: ${GITHUB_WORKSPACE}/.github/scripts/build.sh
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
${GITHUB_WORKSPACE}/.github/scripts/build-$os.sh
shell: bash
- name: Set environment variables for Windows
if: runner.os == 'Windows'
run: |
echo "WASMEDGE_LIB_DIR=C:\Program Files\WasmEdge\lib" >> $env:GITHUB_ENV
echo "WASMEDGE_INCLUDE_DIR=C:\Program Files\WasmEdge\include" >> $env:GITHUB_ENV
- name: Run checks
run: make check
build:
strategy:
matrix:
os: ["ubuntu-20.04", "ubuntu-22.04"]
os: ["ubuntu-20.04", "ubuntu-22.04", "windows-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: "check cgroup version"
run: "mount | grep cgroup"
if: runner.os == 'Linux'
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
env:
RUST_CACHE_KEY_OS: ${{ matrix.os }}
with:
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile
- name: Setup OCI runtime build env
run: ${GITHUB_WORKSPACE}/.github/scripts/build.sh
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
${GITHUB_WORKSPACE}/.github/scripts/build-$os.sh
shell: bash
- name: Set environment variables for Windows
if: runner.os == 'Windows'
run: |
echo "WASMEDGE_LIB_DIR=C:\Program Files\WasmEdge\lib" >> $env:GITHUB_ENV
echo "WASMEDGE_INCLUDE_DIR=C:\Program Files\WasmEdge\include" >> $env:GITHUB_ENV
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all --verbose
run: make build
- name: Validate docs
run: ./scripts/validate-docs.sh
- name: Run tests
run: |
make test
if: runner.os == 'Linux' #disable tests on windows until fully supported

e2e-wasmtime:
needs: [build]
Expand All @@ -62,7 +81,7 @@ jobs:
- name: setup rust-wasm target
run: rustup target add wasm32-wasi
- name: Setup OCI runtime build env
run: ${GITHUB_WORKSPACE}/.github/scripts/build.sh
run: ${GITHUB_WORKSPACE}/.github/scripts/build-linux.sh
shell: bash
- name: run
run: make test/k8s
Expand All @@ -89,7 +108,7 @@ jobs:
- name: setup rust-wasm target
run: rustup target add wasm32-wasi
- name: Setup OCI runtime build env
run: ${GITHUB_WORKSPACE}/.github/scripts/build.sh
run: ${GITHUB_WORKSPACE}/.github/scripts/build-linux.sh
shell: bash
- name: run
run: make test/k3s
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ build:
.PHONY: check
check:
cargo fmt --all -- --check
cargo clippy --all --all-targets -- $(WARNINGS)
cargo clippy $(FEATURES) --all --all-targets -- $(WARNINGS)

.PHONY: fix
fix:
Expand Down
28 changes: 28 additions & 0 deletions docs/windows-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,31 @@ After this, you can execute an example, like: `ctr run --rm --runtime=io.contain

> To kill the process from the example, you can run: `ctr task kill -s SIGKILL testwasm`.
## Building and developing on Windows

You need to install `wasmedge`, `llvm` and `make`. This can be done using `winget`, `choco` or manually. (note as of writing this `winget` doesn't have the latest package and will builds will fail). See `.github/scripts/build-windows.sh` for an example.

Once you have those dependencies you will need to set env:

```
$env:WASMEDGE_LIB_DIR="C:\Program Files\WasmEdge\lib"
$env:WASMEDGE_INCLUDE_DIR="C:\Program Files\WasmEdge\include"
```

Then you can run:

```
make build
```

### Using VS code
If you are using VS Code for development you can use the following `settings.json` in the `.vscode` folder of the project:

```
{
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.cargo.extraEnv": {
"WASMEDGE_LIB_DIR": "C:\\Program Files\\WasmEdge\\lib",
"WASMEDGE_INCLUDE_DIR": "C:\\Program Files\\WasmEdge\\include"
}
}
7 changes: 6 additions & 1 deletion scripts/validate-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

set -e

cargo build --all --verbose --features generate_doc
CARGO_FLAGS=""
if [[ $RUNNER_OS == "Windows" ]]; then
CARGO_FLAGS="--no-default-features"
fi

cargo build --all --verbose --features generate_doc $CARGO_FLAGS
git status --porcelain | grep README.md || exit 0

echo "README.md is not up to date. Please run 'cargo build --all --features generate_doc' and commit the changes." >&2
Expand Down

0 comments on commit 8c1e606

Please sign in to comment.