Skip to content

Commit

Permalink
build: use cmake-build for rdkafka (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Oct 8, 2024
1 parent e0423eb commit ba88d59
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 65 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ concurrency:

jobs:
check:
name: Check
runs-on: ubuntu-latest
name: Check lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
Expand All @@ -45,18 +45,17 @@ jobs:
- run: cargo x lint

test:
name: Build and test
runs-on: ubuntu-latest
name: Run tests with testcontainers
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- run: cargo x build --locked
- run: cargo x test

required:
name: Required
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
if: ${{ always() }}
needs:
- check
Expand Down
29 changes: 29 additions & 0 deletions Cargo.lock

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

15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ tokio-util = { version = "0.7", features = ["compat"] }
toml = "0.8"
url = "2.5"
uuid = { version = "1.8", features = ["v4"] }
which = { version = "6.0" }

# workspace dependencies
kafka-api = { version = "0.4.1", path = "api/kafka-api" }
Expand Down Expand Up @@ -115,6 +116,20 @@ shared-version = true
sign-tag = true
tag-name = "v{{version}}"

[workspace.metadata.dist]
cargo-dist-version = "0.22.1"
ci = "github"
install-path = "CARGO_HOME"
install-updater = false
installers = ["shell"]
pr-run-mode = "upload"
targets = [
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
]

[profile.dist]
inherits = "release"
lto = "thin"
30 changes: 0 additions & 30 deletions dist-workspace.toml

This file was deleted.

4 changes: 2 additions & 2 deletions tests/rdkafka/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ readme.workspace = true
repository.workspace = true
version.workspace = true

[dev-dependencies]
[dependencies]
log = { workspace = true }
morax-protos = { workspace = true }
morax-runtime = { workspace = true, features = ["test"] }
morax-telemetry = { workspace = true }
rdkafka = { version = "0.36" }
rdkafka = { version = "0.36", features = ["cmake-build"] }
test-harness = { workspace = true }
tests-toolkit = { workspace = true }

Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions tests/rdkafka/tests/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

mod testkit;

use std::time::Duration;

use rdkafka::admin::NewTopic;
Expand All @@ -22,9 +20,9 @@ use rdkafka::consumer::Consumer;
use rdkafka::producer::FutureRecord;
use rdkafka::util::Timeout;
use rdkafka::Message;
use rdkafka_tests::harness;
use rdkafka_tests::Testkit;
use test_harness::test;
use testkit::harness;
use testkit::Testkit;

#[test(harness)]
async fn test_simple_pubsub(testkit: Testkit) {
Expand Down
2 changes: 1 addition & 1 deletion tests/rskafka/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ readme.workspace = true
repository.workspace = true
version.workspace = true

[dev-dependencies]
[dependencies]
log = { workspace = true }
morax-protos = { workspace = true }
morax-runtime = { workspace = true, features = ["test"] }
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions tests/rskafka/tests/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

mod testkit;

use std::collections::BTreeMap;

use rskafka::chrono::TimeZone;
use rskafka::chrono::Utc;
use rskafka::client::partition::Compression;
use rskafka::client::partition::UnknownTopicHandling;
use rskafka::record::Record;
use rskafka_tests::harness;
use rskafka_tests::Testkit;
use test_harness::test;
use testkit::harness;
use testkit::Testkit;

#[test(harness)]
async fn test_simple_pubsub(testkit: Testkit) {
Expand Down
2 changes: 1 addition & 1 deletion tests/wal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ readme.workspace = true
repository.workspace = true
version.workspace = true

[dev-dependencies]
[dependencies]
base64 = { workspace = true }
insta = { workspace = true }
log = { workspace = true }
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions tests/wal/tests/read_after_append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

mod testkit;

use base64::prelude::BASE64_STANDARD;
use base64::Engine;
use insta::assert_compact_debug_snapshot;
Expand All @@ -22,8 +20,8 @@ use morax_protos::rpc::CreateLogRequest;
use morax_protos::rpc::Entry;
use morax_protos::rpc::ReadLogRequest;
use test_harness::test;
use testkit::harness;
use testkit::Testkit;
use wal_tests::harness;
use wal_tests::Testkit;

fn make_entry(payload: &str) -> Entry {
Entry {
Expand Down
1 change: 1 addition & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ version.workspace = true

[dependencies]
clap = { workspace = true }
which = { workspace = true }
22 changes: 9 additions & 13 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,15 @@ impl CommandLint {
}

fn find_command(cmd: &str) -> StdCommand {
let output = StdCommand::new("which")
.arg(cmd)
.output()
.expect("broken command: which");
if output.status.success() {
let result = String::from_utf8_lossy(&output.stdout);
let mut cmd = StdCommand::new(result.trim());
cmd.current_dir(env!("CARGO_WORKSPACE_DIR"));
cmd
} else {
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
panic!("{cmd} not found.\nstdout: {}\nstderr: {}", stdout, stderr);
match which::which(cmd) {
Ok(exe) => {
let mut cmd = StdCommand::new(exe);
cmd.current_dir(env!("CARGO_WORKSPACE_DIR"));
cmd
}
Err(err) => {
panic!("{cmd} not found: {err}");
}
}
}

Expand Down

0 comments on commit ba88d59

Please sign in to comment.