Skip to content

Commit

Permalink
docker_smoke_test
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Jun 15, 2024
1 parent 262ae7d commit 5bdd836
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 26 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/bencher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,25 +274,34 @@ jobs:
fail-fast: false
matrix:
include:
# This will not work on release as it tries to pull the current version
# - os: ubuntu-latest
# smoke_test: docker
- os: macos-latest
smoke_test: localhost
- os: windows-latest
runs-on: ${{ matrix.os }}
timeout-minutes: ${{ (github.ref == 'refs/heads/express' && 1) || 60 }}
continue-on-error: ${{ github.ref == 'refs/heads/express' }}
steps:
- uses: actions/checkout@v4
- name: Install `bencher` CLI
run: cargo install --debug --path services/cli --locked --force
- name: Run Smoke Test
run: cargo test-api smoke localhost

docker_api_smoke_test:
name: Docker API Smoke Test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
# https://github.com/actions/runner-images/issues/17#issuecomment-614726536
# - os: macos-latest
# smoke_test: docker
- os: windows-latest
smoke_test: localhost
# https://github.com/orgs/community/discussions/25491#discussioncomment-3248089
# - os: windows-latest
# smoke_test: docker
runs-on: ${{ matrix.os }}
timeout-minutes: ${{ (github.ref == 'refs/heads/express' && 1) || 60 }}
continue-on-error: ${{ github.ref == 'refs/heads/express' || startsWith(github.ref, 'refs/tags/') && matrix.smoke_test == 'docker' }}
continue-on-error: ${{ github.ref == 'refs/heads/express' }}
steps:
- uses: jlumbroso/free-disk-space@main
if: matrix.smoke_test == 'docker'
with:
large-packages: false
- uses: actions/checkout@v4
Expand All @@ -303,7 +312,7 @@ jobs:
- name: Install `bencher` CLI
run: cargo install --debug --path services/cli --locked --force
- name: Run Smoke Test
run: cargo test-api smoke ${{ matrix.smoke_test }}
run: cargo test-api smoke docker

# Cargo Check (Minus)
cargo_check_api_minus:
Expand Down
2 changes: 2 additions & 0 deletions examples/rust/custom/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[workspace]

[package]
name = "custom"
version.workspace = true
Expand Down
21 changes: 13 additions & 8 deletions tasks/test_api/src/task/test/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,29 @@ impl Example {
pub fn require(self) -> anyhow::Result<()> {
match self {
Self::RustBench => {
Command::new("rustup")
let status = Command::new("rustup")
.args(["install", "nightly"])
.status()?;
assert!(status.success(), "{status}");
Ok(())
},
Self::RustCriterion | Self::RustCustom => Ok(()),
Self::RustIai => {
Command::new("sudo")
.args(["apt", "install", "valgrind"])
let status = Command::new("sudo")
.args(["apt", "install", "valgrind", "-y"])
.status()?;
assert!(status.success(), "{status}");
Ok(())
},
Self::RustIaiCallgrind => {
Command::new("sudo")
.args(["apt", "install", "valgrind"])
let status = Command::new("sudo")
.args(["apt", "install", "valgrind", "-y"])
.status()?;
Command::new("cargo")
.args(["install", "iai-callgrind-runner"])
assert!(status.success(), "{status}");
let status = Command::new("cargo")
.args(["install", "iai-callgrind-runner", "--force"])
.status()?;
assert!(status.success(), "{status}");
Ok(())
},
}
Expand Down Expand Up @@ -128,7 +132,7 @@ fn run_example(api_url: &Url, token: &Jwt, example: Example) -> anyhow::Result<(

example.require()?;

Command::new("bencher")
let status = Command::new("bencher")
.args([
"run",
"--host",
Expand All @@ -145,6 +149,7 @@ fn run_example(api_url: &Url, token: &Jwt, example: Example) -> anyhow::Result<(
])
.current_dir(example.dir())
.status()?;
assert!(status.success(), "{status}");

Ok(())
}
7 changes: 5 additions & 2 deletions tasks/test_api/src/task/test/smoke_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ fn api_run() -> anyhow::Result<Child> {
}

fn bencher_up() -> anyhow::Result<()> {
Command::new("cargo")
// Use the `latest`` image tag so this test doesn't fail when releasing a new version.
let status = Command::new("cargo")
.args(["run", "--", "up", "--detach", "--tag", "latest", "api"])
.current_dir("./services/cli")
.status()?;
assert!(status.success(), "{status}");

while std::net::TcpStream::connect("localhost:61016").is_err() {
std::thread::sleep(std::time::Duration::from_secs(1));
Expand All @@ -122,10 +124,11 @@ fn bencher_up() -> anyhow::Result<()> {
}

fn bencher_down() -> anyhow::Result<()> {
Command::new("cargo")
let status = Command::new("cargo")
.args(["run", "--", "down", "api"])
.current_dir("./services/cli")
.status()?;
assert!(status.success(), "{status}");

Ok(())
}
Expand Down
2 changes: 0 additions & 2 deletions xtask/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ mod version;

#[cfg(feature = "admin")]
pub use admin::email_list::TaskEmailList;
#[cfg(feature = "cli")]
pub use package::{TaskDeb, TaskMan};
#[cfg(feature = "plus")]
pub use plus::{
index::{TaskIndex, TaskIndexDelete, TaskIndexUpdate, TaskSearchEngine},
Expand Down
2 changes: 0 additions & 2 deletions xtask/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use crate::parser::{TaskSub, TaskTask};

#[cfg(feature = "admin")]
mod admin;
#[cfg(feature = "cli")]
mod package;
#[cfg(feature = "plus")]
mod plus;
mod test;
Expand Down
3 changes: 2 additions & 1 deletion xtask/src/task/types/typeshare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ impl TryFrom<TaskTypeshare> for Typeshare {

impl Typeshare {
pub fn exec(&self) -> anyhow::Result<()> {
Command::new("npm")
let status = Command::new("npm")
.args(["run", "typeshare"])
.current_dir("./services/console")
.status()?;
assert!(status.success(), "{status}");

println!("Saved to: ./services/console/src/types/bencher.ts");

Expand Down

0 comments on commit 5bdd836

Please sign in to comment.