From 6253e566ed7107bdd0e66caa7a099725acafab9d Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Thu, 5 Sep 2024 18:58:02 -0400 Subject: [PATCH] Run `actionlint` and `shellcheck` in Rust tests --- .github/workflows/ci.yml | 8 -------- Cargo.lock | 1 + cargo-dylint/Cargo.toml | 1 + cargo-dylint/tests/ci.rs | 27 +++++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acc56ea87..4408beead 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,14 +69,6 @@ jobs: - name: Install dylint-link run: cargo install --path ./dylint-link --force - - name: Actionlint - run: | - go install github.com/rhysd/actionlint/cmd/actionlint@latest - "$HOME"/go/bin/actionlint - - - name: Shellcheck - run: shellcheck --exclude=SC2002 scripts/* - - name: Install tools run: | # smoelius: Prettier is still needed for scripts/update_example_READMEs.sh. diff --git a/Cargo.lock b/Cargo.lock index b8e6e9861..786d45476 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,6 +396,7 @@ dependencies = [ "dylint_internal", "env_logger", "glob", + "home", "log", "once_cell", "predicates", diff --git a/cargo-dylint/Cargo.toml b/cargo-dylint/Cargo.toml index 447aea539..fd36644b6 100644 --- a/cargo-dylint/Cargo.toml +++ b/cargo-dylint/Cargo.toml @@ -27,6 +27,7 @@ assert_cmd = "2.0" cargo_metadata = "0.18" ctor = "0.2" glob = "0.3" +home = "0.5" log = "0.4" once_cell = "1.19" predicates = "3.1" diff --git a/cargo-dylint/tests/ci.rs b/cargo-dylint/tests/ci.rs index f45ac8fc6..4a20a6de4 100644 --- a/cargo-dylint/tests/ci.rs +++ b/cargo-dylint/tests/ci.rs @@ -33,6 +33,21 @@ fn initialize() { set_var(env::CARGO_TERM_COLOR, "never"); } +#[test] +fn actionlint() { + Command::new("go") + .args([ + "install", + "github.com/rhysd/actionlint/cmd/actionlint@latest", + ]) + .assert() + .success(); + let home = home::home_dir().unwrap(); + Command::new(home.join("go/bin/actionlint")) + .assert() + .success(); +} + #[test] fn versions_are_equal() { for package in &METADATA.packages { @@ -473,6 +488,18 @@ fn prettier_examples_and_template() { }); } +#[test] +fn shellcheck() { + for entry in read_dir("scripts").unwrap() { + let entry = entry.unwrap(); + let path = entry.path(); + Command::new("shellcheck") + .args(["--exclude=SC2002", &path.to_string_lossy()]) + .assert() + .success(); + } +} + #[test] fn sort() { for entry in walkdir(true).with_file_name("Cargo.toml") {