Skip to content

Commit

Permalink
adds test summary
Browse files Browse the repository at this point in the history
  • Loading branch information
reederc42 committed Apr 24, 2024
1 parent 0090972 commit 0dd1a63
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,10 @@ jobs:
- name: Run CI
run: ./target/debug/ci -v --github-logger --all

- name: Test Results
uses: dorny/test-reporter@v1
with:
name: Wiki CI
path: test_results/*.xml
if: always()
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
/test_results

# generated files
wiki/src/dist.rs
7 changes: 3 additions & 4 deletions ci/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const POSTGRES_IMAGE: &str = "postgres:16-alpine";

pub struct Docker {
pub context: Rc<Context>,
pub verbose: bool,
}

const CMD_HASH_LENGTH: usize = 7;
Expand Down Expand Up @@ -64,7 +63,7 @@ impl Builder for Docker {
]);

let mut finished_print = None;
if self.verbose {
if self.context.verbose {
finished_print = Some(print_command(cmd, false));
}

Expand Down Expand Up @@ -105,7 +104,7 @@ impl Runner for Docker {
let cmd = prog.args(args);

let mut finished_print = None;
if self.verbose {
if self.context.verbose {
finished_print = Some(print_command(cmd, false));
}

Expand Down Expand Up @@ -144,7 +143,7 @@ impl Runner for Docker {
let cmd = prog.args(args);

let mut finished_print = None;
if self.verbose {
if self.context.verbose {
finished_print = Some(print_command(cmd, true));
}

Expand Down
18 changes: 16 additions & 2 deletions ci/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::rc::Rc;
use std::{fs, rc::Rc};

use clap::Parser;

Expand All @@ -12,6 +12,8 @@ macro_rules! error {
};
}

const TEST_RESULTS_DIR: &str = "./test_results";

#[derive(Parser)]
#[command(version, about, long_about = None)]
pub struct Cli {
Expand Down Expand Up @@ -56,16 +58,27 @@ pub fn cmd(args: Cli) {
cwd: std::env::var("HOST_WORKDIR").unwrap_or(
String::from(std::env::current_dir().unwrap().to_str().unwrap())
),
verbose: args.verbose,
});
let docker = Rc::new(docker::Docker{
context: context.clone(),
verbose: args.verbose,
});
let config = Config {
runner: docker.clone(),
builder: docker.clone(),
};

match fs::remove_dir_all(TEST_RESULTS_DIR) {
Ok(_) => {},
Err(err) => {
match err.kind() {
std::io::ErrorKind::NotFound => {},
_ => panic!("{:?}", err),
}
},
}
fs::create_dir(TEST_RESULTS_DIR).unwrap();

let mut stages_run = 0;
let all_stages_len = all_stages.len();
for s in all_stages {
Expand Down Expand Up @@ -97,6 +110,7 @@ pub type Error = Box<dyn std::error::Error>;
pub struct Context {
pub id: String,
pub cwd: String,
pub verbose: bool,
}

pub struct Config {
Expand Down
15 changes: 10 additions & 5 deletions ci/src/stages/dev_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn node_dev_e2e(expiration: u32, config: &Config) -> Result<(), Error> {
&format!(r"
set -xe
{}
", make_cypress_script(expiration, &server.addr(), &BROWSERS))
", make_cypress_script(expiration, &server.addr(), "node-dev", &BROWSERS))
]
)
}
Expand Down Expand Up @@ -97,18 +97,23 @@ fn rust_dev_e2e(expiration: u32, config: &Config) -> Result<(), Error> {
&format!(r"
set -xe
{}
", make_cypress_script(expiration, &server.addr(), &BROWSERS)),
", make_cypress_script(expiration, &server.addr(), "rust-dev", &BROWSERS)),
],
)
}

fn make_cypress_script(expiration: u32, server_addr: &str, browsers: &[&str]) -> String {
fn make_cypress_script(expiration: u32, server_addr: &str, stage_name: &str, browsers: &[&str]) -> String {
format!(r"
ln -s /ci/node_modules ./ui/node_modules || true
cd ui
node tools/configure.js --user-expiration {0} --api-expiration {0}
for b in {1}; do
npx cypress run --browser $b --config baseUrl=http://{2}:8080
npx cypress run \
--browser $b \
--config baseUrl=http://{2}:8080 \
--reporter=cypress-multi-reporters \
--reporter-options=configFile=ci-cypress-reporter-config.json
mv e2e-test-tmp.xml ../test_results/{3}-$b-e2e.xml
done
", expiration, browsers.join(" "), server_addr)
", expiration, browsers.join(" "), server_addr, stage_name)
}
6 changes: 5 additions & 1 deletion ci/src/stages/nodejs_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ impl Stage for NodeJSChecks {
export ESLINT_USE_FLAT_CONFIG=false
cd ui
npm run lint
npm run test
npm run test -- \
--test-reporter=spec \
--test-reporter-destination=stdout \
--test-reporter=junit \
--test-reporter-destination=../test_results/nodejs-unit-test.xml
",
],
)
Expand Down
6 changes: 6 additions & 0 deletions ui/ci-cypress-reporter-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "./e2e-test-tmp.xml"
}
}
Loading

0 comments on commit 0dd1a63

Please sign in to comment.