Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add cargo test reporting #56

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ jobs:

- name: kairos x86_64-linux
if: matrix.os == 'ubuntu-latest'
run: nix build -L --no-link --show-trace .#packages.x86_64-linux.kairos
run: nix build -L --out-link kairos-result --show-trace .#packages.x86_64-linux.kairos

- name: Create JUnit Kairos Test Report x86_64-linux
if: matrix.os == 'ubuntu-latest'
run: cat kairos-result/test-result.json | nix run nixpkgs#cargo2junit > kairos-test-result.xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using cargo2junit forces us to use nigthly toolchain 😞.

What about using cargo nextest instead of default cargo test runner? Nextest has JUnit output and it was designed for usage in CI.


- name: Publish Kairos Test Report
uses: mikepenz/action-junit-report@v4
if: matrix.os == 'ubuntu-latest' || success() || failure() # always run even if the previous step fails
with:
report_paths: '*test-result.xml'

- name: kairos x86_64-darwin
if: matrix.os == 'macos-latest'
Expand Down
7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
];
perSystem = { config, self', inputs', system, pkgs, lib, ... }:
let
rustToolchain = inputs'.fenix.packages.stable.toolchain;
rustToolchain = inputs'.fenix.packages.latest.toolchain;
Copy link
Contributor

@koxu1996 koxu1996 Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to avoid using nigthly toolchain.

craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolchain;

kairosNodeAttrs = {
Expand Down Expand Up @@ -83,6 +83,11 @@

kairos = craneLib.buildPackage (kairosNodeAttrs // {
cargoArtifacts = self'.packages.kairos-deps;
cargoTestExtraArgs = "-- -Z unstable-options --format json --report-time | tee test-output.json";
Copy link
Contributor

@koxu1996 koxu1996 Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cargoTestExtraArgs = "-- -Z unstable-options --format json --report-time | tee test-output.json";
cargoTestExtraArgs = "-- --format json --report-time | tee test-output.json";

Would this work?

Edit: Okay, I see cargo test has no structured output without unstable option to get JSON 😨 .

postCheck = ''
mkdir -p $out
cp test-output.json $out
'';
});

default = self'.packages.kairos;
Expand Down
3 changes: 1 addition & 2 deletions kairos-test-utils/src/cctl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod parsers;
use anyhow::anyhow;
use backoff::{self, backoff::Constant, future::retry};
use backoff::{backoff::Constant, future::retry};
use casper_client::{get_node_status, rpcs::results::ReactorState, Error, JsonRpcId, Verbosity};
use std::io::{self, Write};
use std::path::PathBuf;
Expand Down Expand Up @@ -133,7 +133,6 @@ impl Drop for CCTLNetwork {
#[cfg(test)]
mod tests {
use super::*;
use casper_client::{get_node_status, rpcs::results::ReactorState, JsonRpcId, Verbosity};
#[tokio::test]
async fn test_cctl_network_starts_and_terminates() {
let network = CCTLNetwork::run().await.unwrap();
Expand Down
Loading