Skip to content
Closed

testing #1419

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/openvmm-docs-ci.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions .github/workflows/upload-petri-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Upload Petri Test Results

on:
workflow_run:
types:
- completed
workflows:
- '\[flowey\] OpenVMM CI'
- '\[flowey\] OpenVMM PR'

permissions:
id-token: write
contents: read
actions: read # Needed to download artifacts from other runs
pull-requests: write # Needed to create PR comments

jobs:
upload-logs:
runs-on: ubuntu-latest
env:
BASE_URL: https://openvmmghtestresults.blob.core.windows.net/results

steps:
- name: Authenticate to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.OPENVMM_TEST_RESULT_CLIENT_ID }}
tenant-id: ${{ secrets.OPENVMM_TENANT_ID }}
subscription-id: ${{ secrets.OPENVMM_SUBSCRIPTION_ID }}

- name: Download matching artifacts
run: |
if [ "$event" = "pull_request" ]; then
echo "UPLOAD_PATH=pr/$run_id" >> "$GITHUB_ENV"
else
echo "UPLOAD_PATH=ci/$head_branch/$run_id" >> "$GITHUB_ENV"
fi
mkdir -p results
gh run \
-R "$repo" \
download "$run_id" \
-p "*-vmm-tests-logs" \
-D results
FAIL_COUNT=$(find results -name petri.failed | wc -l)
echo "FAIL_COUNT=$FAIL_COUNT" >> $GITHUB_ENV
env:
event: ${{ github.event.workflow_run.event }}
repo: ${{ github.event.workflow_run.repository.full_name }}
run_id: ${{ github.event.workflow_run.id }}
head_branch: ${{ github.event.workflow_run.head_branch }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload to Azure Blob Storage
run: |
az storage blob upload-batch \
--destination "$BASE_URL" \
--destination-path "$UPLOAD_PATH" \
--source results \
--auth-mode login

# Store a metadata blob in a separate portion of the hierarchy so that
# it can be cheaply queried.
az storage blob upload \
--blob-url "$BASE_URL/runs/$UPLOAD_PATH" \
--file /dev/null \
--metadata petrifailed="$FAIL_COUNT" \
--auth-mode login
env:
run_id: ${{ github.event.workflow_run.id }}

- name: Report failing tests
if: ${{ github.event.workflow_run.event == 'pull_request' && env.FAIL_COUNT > 0 }}
run: |
gh pr comment \
-R "$repo" \
"$pr" \
-F - <<EOF
[At least one Petri test failed.](https://openvmm.dev/test-results/index.html?run=$UPLOAD_PATH)
EOF
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
repo: ${{ github.event.workflow_run.repository.full_name }}
pr: ${{ github.event.workflow_run.pull_requests[0].number }}
run_id: ${{ github.event.workflow_run.id }}
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3551,9 +3551,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"

[[package]]
name = "jiff"
version = "0.2.10"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a064218214dc6a10fbae5ec5fa888d80c45d611aba169222fc272072bf7aef6"
checksum = "a194df1107f33c79f4f93d02c80798520551949d59dfad22b6157048a88cca93"
dependencies = [
"jiff-static",
"jiff-tzdb-platform",
Expand All @@ -3566,9 +3566,9 @@ dependencies = [

[[package]]
name = "jiff-static"
version = "0.2.10"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "199b7932d97e325aff3a7030e141eafe7f2c6268e1d1b24859b753a627f45254"
checksum = "6c6e1db7ed32c6c71b759497fae34bf7933636f75a251b9e736555da426f6442"
dependencies = [
"proc-macro2",
"quote",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ igvm = {git = "https://github.com/microsoft/igvm", rev = "365065d7e31da0a0116e79
igvm_defs = {git = "https://github.com/microsoft/igvm", rev = "365065d7e31da0a0116e7934de3ecd85f00bab70", default-features = false, features = [ "unstable" ]}
image = { version = "0.25.1", default-features = false }
io-uring = "0.7.4"
jiff = "0.2"
jiff = "0.2.14"
kvm-bindings = "0.11.1"
# Use of these specific REPO will go away when changes are taken upstream.
landlock = "0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion flowey/flowey_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ log.workspace = true
parking_lot.workspace = true
petgraph.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
serde_json = { workspace = true, features = ["raw_value"] }
serde_yaml.workspace = true
toml_edit = { workspace = true, features = ["serde"] }
xshell.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion flowey/flowey_cli/src/cli/var_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl VarDb {
if is_secret {
// Remember that this environment variable is secret so that
// it cannot be easily laundered into a non-secret variable.
runtime_var_db.set_var(&env_source_name(&env), false, Vec::new());
runtime_var_db.set_var(&env_source_name(&env), false, "null".into());
}

match backend {
Expand Down
26 changes: 12 additions & 14 deletions flowey/flowey_cli/src/var_db/single_json_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use anyhow::Context;
use fs_err::File;
use serde::Deserialize;
use serde::Serialize;
use serde_json::value::RawValue;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::io::Seek;
use std::io::Write;
Expand All @@ -15,8 +17,8 @@ use std::path::Path;
/// On-disk format for the var db
#[derive(Serialize, Deserialize)]
#[serde(transparent)]
struct VarDb {
vars: BTreeMap<String, (bool, serde_json::Value)>,
struct VarDb<'a> {
vars: BTreeMap<String, (bool, Cow<'a, RawValue>)>,
}

/// Implements [`flowey_core::node::RuntimeVarDb`] backed by a JSON file.
Expand Down Expand Up @@ -47,7 +49,7 @@ impl SingleJsonFileVarDb {
Ok(Self { file })
}

fn load_db(&mut self) -> VarDb {
fn load_db(&mut self) -> VarDb<'static> {
self.file.rewind().unwrap();
serde_json::from_reader(&self.file).expect("corrupt runtime variable db")
}
Expand All @@ -57,30 +59,26 @@ impl flowey_core::node::RuntimeVarDb for SingleJsonFileVarDb {
fn try_get_var(&mut self, var_name: &str) -> Option<(Vec<u8>, bool)> {
let db = self.load_db();
let (is_secret, ref val) = *db.vars.get(var_name)?;
let val = val.to_string();
if is_secret {
log::debug!("[db] read var: {} = <secret>", var_name);
} else {
log::debug!("[db] read var: {} = {}", var_name, val);
}
Some((val.into(), is_secret))
Some((val.get().into(), is_secret))
}

fn set_var(&mut self, var_name: &str, is_secret: bool, value: Vec<u8>) {
let value: &RawValue = serde_json::from_slice(&value)
.unwrap_or_else(|err| panic!("invalid JSON for var {}: {}", var_name, err));
if is_secret {
log::debug!("[db] set var: {} = <secret>", var_name)
} else {
log::debug!(
"[db] set var: {} = {}",
var_name,
String::from_utf8_lossy(&value)
)
log::debug!("[db] set var: {} = {}", var_name, value)
};
let mut db = self.load_db();
let existing = db.vars.insert(
var_name.into(),
(is_secret, serde_json::from_slice(&value).unwrap()),
);
let existing = db
.vars
.insert(var_name.into(), (is_secret, Cow::Borrowed(value)));
assert!(existing.is_none()); // all vars are one-time-write
self.file.set_len(0).unwrap();
self.file.rewind().unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl SimpleFlowNode for Node {

fn imports(ctx: &mut ImportCtx<'_>) {
ctx.import::<flowey_lib_common::copy_to_artifact_dir::Node>();
ctx.import::<crate::git_checkout_openvmm_repo::Node>();
}

fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
Expand All @@ -42,14 +43,18 @@ impl SimpleFlowNode for Node {
output,
} = request;

let repo = ctx.reqv(crate::git_checkout_openvmm_repo::req::GetRepoDir);

let consolidated_html = ctx.emit_rust_stepv("generate consolidated gh pages html", |ctx| {
let rendered_guide = rendered_guide.claim(ctx);
let rustdoc_windows = rustdoc_windows.claim(ctx);
let rustdoc_linux = rustdoc_linux.claim(ctx);
let repo = repo.claim(ctx);
|rt| {
let rendered_guide = rt.read(rendered_guide);
let rustdoc_windows = rt.read(rustdoc_windows);
let rustdoc_linux = rt.read(rustdoc_linux);
let repo = rt.read(repo);

let consolidated_html = std::env::current_dir()?.join("out").absolute()?;
fs_err::create_dir(&consolidated_html)?;
Expand Down Expand Up @@ -78,6 +83,12 @@ impl SimpleFlowNode for Node {
consolidated_html.join("rustdoc/linux"),
)?;

// Make petri logview available under `openvmm.dev/test-results/`
flowey_lib_common::_util::copy_dir_all(
repo.join("petri/logview"),
consolidated_html.join("test-results"),
)?;

// as we do not currently have any form of "landing page",
// redirect `openvmm.dev` to `openvmm.dev/guide`
fs_err::write(consolidated_html.join("index.html"), REDIRECT)?;
Expand Down
Loading
Loading