Skip to content

Commit

Permalink
Add ignores and seed img generation
Browse files Browse the repository at this point in the history
  • Loading branch information
novafacing committed Jan 9, 2024
1 parent 1df37f9 commit 66a63cf
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logs
1 change: 1 addition & 0 deletions .github/rsrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.yml
Binary file added .github/rsrc/seed.img
Binary file not shown.
59 changes: 57 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ env:
CARGO_TERM_COLOR: always

jobs:
test_examples:
test_plugins_linux:
name: Build and Test Plugins (Linux)
runs-on: ubuntu-latest
container: ubuntu:22.04
steps:
Expand All @@ -23,8 +24,62 @@ jobs:
- name: Test QEMU Install
run: |
qemu-x86_64 --help
- name: Build
- name: Build and Test Tracer
run: |
cd plugins/tracer
cargo build -r || exit 0
cargo build -r
cargo run -r --bin tracer -- -a /bin/ls -- -lah
cd ../..
- name: Build and Test Tiny
run: |
cd plugins/tiny
cargo build -r || exit 0
cargo build -r
qemu-x86_64 -plugin ../../target/release/libtiny.so /bin/ls -lah
cd ../..
test_plugins_windows:
name: Build and Test Plugins (Windows)
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
env:
# QEMU 8.1.0
QEMU_URL: "https://qemu.weilnetz.de/w64/2023/qemu-w64-setup-20230822.exe"
RUSTUP_URL: "https://win.rustup.rs/x86_64"

steps:
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: git mingw-w64-ucrt-x86_64-gcc

- name: Download and Install Rust
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri ${{ env.RUSTUP_URL }} -OutFile rustup-init.exe
./rustup-init.exe --default-toolchain nightly --default-host x86_64-pc-windows-gnu -y
- name: Install QEMU
shell: msys2 {0}
run: |
pacman -Syu --noconfirm
pacman -Sy mingw-w64-ucrt-x86_64-qemu --noconfirm
- uses: actions/checkout@v4

- name: Download Ubuntu Cloud Image
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri "
- name: Build and Test Tiny
run: |
cd plugins/tiny
cargo build -r || exit 0
cargo build -r
qemu-system-x86_64.exe -plugin ../../target/release/libtiny.so
cd ../..
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
.env
.secrets
*~
2 changes: 1 addition & 1 deletion plugins/tracer/src/bin/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const PLUGIN: &[u8] = include_bytes!(concat!(
#[cfg(not(debug_assertions))]
const PLUGIN: &[u8] = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../target/release/libtracer.so"
"/../../target/release/libtracer.so"
));

fn tmp(prefix: &str, suffix: &str) -> PathBuf {
Expand Down
84 changes: 84 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

#Run workflows locally using act

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
WORKFLOW_FILE="${SCRIPT_DIR}/../.github/workflows/ci.yml"
SECRETS_FILE="${SCRIPT_DIR}/../.secrets"

if [ ! -f "${SECRETS_FILE}" ]; then
echo "No file '${SECRETS_FILE}' found. Please create one. It must have the following keys:
GITHUB_TOKEN" \
"You can find your GitHub token with 'gh auth token'"
exit 1
fi

if ! command -v act &>/dev/null; then
echo "act must be installed! Install at https://github.com/nektos/act"
exit 1
fi

if ! command -v unbuffer &>/dev/null; then
echo "unbuffer must be installed! Install 'expect' from your package manager"
exit 1
fi

populate_env_file() {
ENV_FILE="${1}"
echo "Attempting automatic configuration of proxy with ENV_FILE=${ENV_FILE}"

if [ -z "${HTTP_PROXY}" ] && [ -f ~/.docker/config.json ]; then
HTTP_PROXY=$(grep httpProxy ~/.docker/config.json | awk -F'\"[:space:]*:[:space:]*' '{split($2,a,"\""); print a[2]}')
echo "Exported docker config HTTP_PROXY=${HTTP_PROXY}"
elif [ -n "${HTTP_PROXY}" ]; then
echo "Exported docker config HTTP_PROXY=${HTTP_PROXY}"
fi
echo "HTTP_PROXY=${HTTP_PROXY}" >>"${ENV_FILE}"
echo "proxy=${HTTP_PROXY}" >>"${ENV_FILE}"

if [ -z "${HTTPS_PROXY}" ] && [ -f ~/.docker/config.json ]; then
HTTPS_PROXY=$(grep httpsProxy ~/.docker/config.json | awk -F'\"[:space:]*:[:space:]*' '{split($2,a,"\""); print a[2]}')
echo "Exported docker config HTTPS_PROXY=${HTTPS_PROXY}"
elif [ -n "${HTTPS_PROXY}" ]; then
echo "Exported docker config HTTPS_PROXY=${HTTPS_PROXY}"
fi
echo "HTTPS_PROXY=${HTTPS_PROXY}" >>"${ENV_FILE}"

if [ -z "${http_proxy}" ] && [ -f ~/.docker/config.json ]; then
http_proxy=$(grep httpProxy ~/.docker/config.json | awk -F'\"[:space:]*:[:space:]*' '{split($2,a,"\""); print a[2]}')
echo "Exported docker config http_proxy=${http_proxy}"
elif [ -n "${http_proxy}" ]; then
echo "Exported docker config http_proxy=${http_proxy}"
fi
echo "http_proxy=${http_proxy}" >>"${ENV_FILE}"

if [ -z "${https_proxy}" ] && [ -f ~/.docker/config.json ]; then
https_proxy=$(grep httpsProxy ~/.docker/config.json | awk -F'\"[:space:]*:[:space:]*' '{split($2,a,"\""); print a[2]}')
echo "Exported docker config https_proxy=${https_proxy}"
elif [ -n "${https_proxy}" ]; then
echo "Exported docker config https_proxy=${https_proxy}"
fi
echo "https_proxy=${https_proxy}" >>"${ENV_FILE}"

if [ -z "${NO_PROXY}" ] && [ -f ~/.docker/config.json ]; then
NO_PROXY=$(grep noProxy ~/.docker/config.json | awk -F'\"[:space:]*:[:space:]*' '{split($2,a,"\""); print a[2]}')
echo "Exported docker config NO_PROXY=${NO_PROXY}"
elif [ -n "${NO_PROXY}" ]; then
echo "Exported docker config NO_PROXY=${NO_PROXY}"
fi
echo "NO_PROXY=${NO_PROXY}" >>"${ENV_FILE}"

cat "${ENV_FILE}"
}

ENV_FILE=$(mktemp)
ARTIFACT_DIR=$(mktemp -d)
populate_env_file "${ENV_FILE}"
mkdir -p "${SCRIPT_DIR}/../.github/logs/"
unbuffer act -W "${WORKFLOW_FILE}" --env-file="${ENV_FILE}" --secret-file="${SECRETS_FILE}" \
--artifact-server-path "${ARTIFACT_DIR}" \
"$@" | tee "${SCRIPT_DIR}/../.github/logs/$(date '+%F-%T').log"
rm "${ENV_FILE}"
20 changes: 20 additions & 0 deletions scripts/mk-cloudinit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

# sudo -E dnf install -y cloud-utils

mkdir -p .github/rsrc/
# password is "password"
# mkpasswd --method=SHA-512 --rounds=4096
PASSWD="$6$rounds=4096$EhaOFVl.Hr626Zg2$mIqOEWTXg0U4cfIDDsYYLtqNMoCLRMVQfX4iZnlQTt.dnBoXetHdMzyGdY2MVOWGV18UowbFNSJowTHmBDb4z1"
cat <<EOF > .github/rsrc/user-data.yml
users:
- name: user
passwd: ${PASSWD}
lock_passwd: false
groups: [sudo]
shell: /bin/bash
EOF

cloud-localds .github/rsrc/seed.img .github/rsrc/user-data.yml

0 comments on commit 66a63cf

Please sign in to comment.