feat(cli): add --deny to build, check, and docs
This is useful for CI, where people that may have a stricter workflow want to force CI to fail if any warnings are detected.
This commit is contained in:
parent
819a0a20e6
commit
1de7b2866a
|
@ -2,6 +2,10 @@
|
|||
|
||||
## v1.0.17-alpha - unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- **aiken**: add ability to force warnings to cause a failing exit code on check, build, and docs
|
||||
|
||||
### Fixed
|
||||
|
||||
- **uplc**: trim whitespace when loading files with hex strings to avoid confusing errors #720
|
||||
|
|
|
@ -34,7 +34,7 @@ pub fn exec(
|
|||
rebuild,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
with_project(directory, |p| {
|
||||
with_project(directory, false, |p| {
|
||||
if rebuild {
|
||||
p.build(false, Tracing::NoTraces)?;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn exec(
|
|||
validator,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
with_project(None, |p| {
|
||||
with_project(None, false, |p| {
|
||||
let title = module.as_ref().map(|m| {
|
||||
format!(
|
||||
"{m}{}",
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn exec(
|
|||
rebuild,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
with_project(directory, |p| {
|
||||
with_project(directory, false, |p| {
|
||||
if rebuild {
|
||||
p.build(false, Tracing::NoTraces)?;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn exec(
|
|||
rebuild,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
with_project(directory, |p| {
|
||||
with_project(directory, false, |p| {
|
||||
if rebuild {
|
||||
p.build(false, Tracing::NoTraces)?;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ pub struct Args {
|
|||
/// Path to project
|
||||
directory: Option<PathBuf>,
|
||||
|
||||
/// Deny warnings; warnings will be treated as errors
|
||||
#[clap(short = 'D', long)]
|
||||
deny: bool,
|
||||
|
||||
/// Also dump textual uplc
|
||||
#[clap(short, long)]
|
||||
uplc: bool,
|
||||
|
@ -18,9 +22,10 @@ pub struct Args {
|
|||
pub fn exec(
|
||||
Args {
|
||||
directory,
|
||||
deny,
|
||||
uplc,
|
||||
keep_traces,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
crate::with_project(directory, |p| p.build(uplc, keep_traces.into()))
|
||||
crate::with_project(directory, deny, |p| p.build(uplc, keep_traces.into()))
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ pub struct Args {
|
|||
/// Path to project
|
||||
directory: Option<PathBuf>,
|
||||
|
||||
/// Deny warnings; warnings will be treated as errors
|
||||
#[clap(short = 'D', long)]
|
||||
deny: bool,
|
||||
|
||||
/// Skip tests; run only the type-checker
|
||||
#[clap(short, long)]
|
||||
skip_tests: bool,
|
||||
|
@ -33,6 +37,7 @@ pub struct Args {
|
|||
pub fn exec(
|
||||
Args {
|
||||
directory,
|
||||
deny,
|
||||
skip_tests,
|
||||
debug,
|
||||
match_tests,
|
||||
|
@ -40,7 +45,7 @@ pub fn exec(
|
|||
no_traces,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
crate::with_project(directory, |p| {
|
||||
crate::with_project(directory, deny, |p| {
|
||||
p.check(
|
||||
skip_tests,
|
||||
match_tests.clone(),
|
||||
|
|
|
@ -6,6 +6,10 @@ pub struct Args {
|
|||
/// Path to project
|
||||
directory: Option<PathBuf>,
|
||||
|
||||
/// Deny warnings; warnings will be treated as errors
|
||||
#[clap(short = 'D', long)]
|
||||
deny: bool,
|
||||
|
||||
/// Output directory for the documentation
|
||||
#[clap(short = 'o', long)]
|
||||
destination: Option<PathBuf>,
|
||||
|
@ -14,8 +18,9 @@ pub struct Args {
|
|||
pub fn exec(
|
||||
Args {
|
||||
directory,
|
||||
deny,
|
||||
destination,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
crate::with_project(directory, |p| p.docs(destination.clone()))
|
||||
crate::with_project(directory, deny, |p| p.docs(destination.clone()))
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ fn create_github_action(root: &Path) -> miette::Result<()> {
|
|||
version: v{version}
|
||||
|
||||
- run: aiken fmt --check
|
||||
- run: aiken check
|
||||
- run: aiken check -D
|
||||
- run: aiken build
|
||||
"#,
|
||||
version = built_info::PKG_VERSION,
|
||||
|
|
|
@ -13,7 +13,7 @@ pub mod built_info {
|
|||
include!(concat!(env!("OUT_DIR"), "/built.rs"));
|
||||
}
|
||||
|
||||
pub fn with_project<A>(directory: Option<PathBuf>, mut action: A) -> miette::Result<()>
|
||||
pub fn with_project<A>(directory: Option<PathBuf>, deny: bool, mut action: A) -> miette::Result<()>
|
||||
where
|
||||
A: FnMut(&mut Project<Terminal>) -> Result<(), Vec<aiken_project::error::Error>>,
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ where
|
|||
|
||||
let warning_count = warnings.len();
|
||||
|
||||
for warning in warnings {
|
||||
for warning in &warnings {
|
||||
warning.report()
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,11 @@ where
|
|||
warning_text.if_supports_color(Stderr, |s| s.yellow()),
|
||||
);
|
||||
}
|
||||
|
||||
if warning_count > 0 && deny {
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue