ci: Clean up and add audit task
This commit is contained in:
parent
dd8493a0fc
commit
eae0b58163
9
.builds/audit.yml
Normal file
9
.builds/audit.yml
Normal file
@ -0,0 +1,9 @@
|
||||
image: archlinux
|
||||
packages:
|
||||
- cargo-audit
|
||||
sources:
|
||||
- https://github.com/ruma/ruma
|
||||
tasks:
|
||||
- audit: |
|
||||
cd ruma
|
||||
cargo audit
|
@ -9,57 +9,12 @@ tasks:
|
||||
rustup toolchain install 1.45 --profile minimal
|
||||
rustup default 1.45
|
||||
- test: |
|
||||
cd ruma
|
||||
|
||||
# We don't want the build to stop on individual failure of independent
|
||||
# tools, so capture tool exit codes and set the task exit code manually
|
||||
set +e
|
||||
|
||||
# We don't want to try building ruma-signatures on 1.45, since it depends
|
||||
# on ring (MSRV 'stable') and is exempt from our MSRV policy. Instead,
|
||||
# enable all other dependencies on the ruma crate and try building that
|
||||
# (usually you would enable the higher-level features, but we're only
|
||||
# doing this to have all relevant crates compiled, no to build a useful
|
||||
# crate).
|
||||
pushd ruma
|
||||
cd ruma/ruma
|
||||
|
||||
cargo build --features full --quiet
|
||||
ruma_build_exit=$?
|
||||
|
||||
# ruma-client isn't re-exported by ruma right now, so it needs to be built
|
||||
# separately
|
||||
pushd ruma-client
|
||||
|
||||
cargo build --quiet
|
||||
client_build_exit=$?
|
||||
|
||||
popd
|
||||
|
||||
# ruma-identifiers has a bunch of features. Make sure it works both with
|
||||
# all of them and none of them being enabled.
|
||||
pushd ruma-identifiers
|
||||
|
||||
cargo build --no-default-features --quiet
|
||||
id_build_1_exit=$?
|
||||
|
||||
cargo build --all-features --quiet
|
||||
id_build_2_exit=$?
|
||||
|
||||
popd
|
||||
|
||||
# ruma-client_api also has a few optional features, but none are enabled
|
||||
# by default. Make sure it works with all of them.
|
||||
pushd ruma-client-api
|
||||
|
||||
cargo build --all-features --quiet
|
||||
client_api_build_exit=$?
|
||||
|
||||
popd
|
||||
|
||||
exit $(( \
|
||||
$ruma_build_exit \
|
||||
|| $client_build_exit \
|
||||
|| $id_build_1_exit \
|
||||
|| $id_build_2_exit \
|
||||
|| $client_api_build_exit \
|
||||
))
|
||||
|
@ -15,7 +15,7 @@ tasks:
|
||||
# tools, so capture tool exit codes and set the task exit code manually
|
||||
set +e
|
||||
|
||||
cargo test --all --quiet
|
||||
cargo test --workspace --quiet
|
||||
test_exit=$?
|
||||
|
||||
# ruma-identifiers has a bunch of features. Make sure it works both with
|
||||
@ -34,7 +34,7 @@ tasks:
|
||||
# by default. Make sure it works with all of them.
|
||||
pushd ruma-client-api
|
||||
|
||||
cargo check --all-features --quiet
|
||||
cargo test --all-features --quiet
|
||||
client_api_exit=$?
|
||||
|
||||
popd
|
||||
@ -62,5 +62,3 @@ tasks:
|
||||
|| $client_2_exit \
|
||||
|| $client_3_exit \
|
||||
))
|
||||
# TODO: Add audit task once cargo-audit binary releases are available.
|
||||
# See https://github.com/RustSec/cargo-audit/issues/66
|
||||
|
@ -4,13 +4,17 @@ use crate::{cmd, Result};
|
||||
|
||||
const MSRV: &str = "1.45";
|
||||
|
||||
macro_rules! cmd_in {
|
||||
macro_rules! run_in {
|
||||
($dir:expr, $($c:tt),+ $(,)?) => {{
|
||||
let _p = xshell::pushd($dir)?;
|
||||
$(super::cmd!($c).run()?;)+
|
||||
}};
|
||||
}
|
||||
|
||||
//macro_rules! rustup_cmd {
|
||||
//
|
||||
//}
|
||||
|
||||
/// Task to run CI tests.
|
||||
pub struct CiTask {
|
||||
/// Which version of Rust to test against.
|
||||
@ -26,6 +30,8 @@ impl CiTask {
|
||||
}
|
||||
|
||||
pub(crate) fn run(self) -> Result<()> {
|
||||
let _p = xshell::pushd(&self.project_root)?;
|
||||
|
||||
match self.version.as_deref() {
|
||||
Some("msrv") => self.build_msrv(),
|
||||
Some("stable") => self.build_stable(),
|
||||
@ -40,46 +46,46 @@ impl CiTask {
|
||||
}
|
||||
|
||||
fn build_msrv(&self) -> Result<()> {
|
||||
cmd_in!(
|
||||
self.project_root.join("ruma"),
|
||||
"rustup run {MSRV} cargo build --features full --quiet",
|
||||
);
|
||||
cmd_in!(self.project_root.join("ruma-client"), "rustup run {MSRV} cargo build --quiet");
|
||||
cmd_in!(
|
||||
self.project_root.join("ruma-identifiers"),
|
||||
"rustup run {MSRV} cargo build --no-default-features --quiet"
|
||||
);
|
||||
cmd_in!(
|
||||
self.project_root.join("ruma-identifiers"),
|
||||
"rustup run {MSRV} cargo build --all-features --quiet"
|
||||
);
|
||||
cmd_in!(
|
||||
self.project_root.join("ruma-client-api"),
|
||||
"rustup run {MSRV} cargo build --all-features --quiet"
|
||||
);
|
||||
run_in!("ruma", "rustup run {MSRV} cargo build --features full --quiet");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn build_stable(&self) -> Result<()> {
|
||||
cmd!("cargo test --all --quiet").run()?;
|
||||
cmd!("rustup run stable cargo test --workspace --quiet").run()?;
|
||||
|
||||
{
|
||||
let _p = xshell::pushd(self.project_root.join("ruma-identifiers"))?;
|
||||
cmd!("cargo test --no-default-features --quiet").run()?;
|
||||
cmd!("cargo test --all-features --quiet").run()?;
|
||||
let _p = xshell::pushd("ruma-identifiers")?;
|
||||
cmd!("rustup run stable cargo test --no-default-features --quiet").run()?;
|
||||
cmd!("rustup run stable cargo test --all-features --quiet").run()?;
|
||||
}
|
||||
|
||||
run_in!("ruma-client-api", "rustup run stable cargo test --all-features --quiet");
|
||||
|
||||
{
|
||||
let _p = xshell::pushd(self.project_root.join("ruma-client-api"))?;
|
||||
cmd!("cargo check --no-default-features --features http1,http2 --quiet").run()?;
|
||||
cmd!("cargo check --no-default-features --features http1,http2,tls-rustls-native-roots --quiet").run()?;
|
||||
cmd!("cargo check --no-default-features --features http1,http2,tls-rustls-webpki-roots --quiet").run()?;
|
||||
let _p = xshell::pushd("ruma-client")?;
|
||||
cmd!("rustup run stable cargo check --no-default-features --features http1,http2 --quiet")
|
||||
.run()?;
|
||||
cmd!("rustup run stable cargo check --no-default-features --features http1,http2,tls-rustls-native-roots --quiet")
|
||||
.run()?;
|
||||
cmd!("rustup run stable cargo check --no-default-features --features http1,http2,tls-rustls-webpki-roots --quiet")
|
||||
.run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn build_nightly(&self) -> Result<()> {
|
||||
cmd!("cargo fmt --all").run()?;
|
||||
cmd_in!("ruma", "cargo clippy --all-targets --all-features --quiet -- -D warnings");
|
||||
cmd_in!("ruma-client", "cargo clippy --all-targets --quiet -- -D warnings");
|
||||
cmd!("rustup run nightly cargo fmt --all").run()?;
|
||||
run_in!(
|
||||
"ruma",
|
||||
"rustup run nightly cargo clippy --all-targets --all-features --quiet -- -D warnings"
|
||||
);
|
||||
run_in!(
|
||||
"ruma-client",
|
||||
"rustup run nightly cargo clippy --all-targets --quiet -- -D warnings"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user