Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for actionlint #581

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased](https://github.com/hougesen/mdsf/compare/v0.3.2...HEAD)

- feat: add support for actionlint [`#581`](https://github.com/hougesen/mdsf/pull/581)
- feat: add support for tex-fmt [`#580`](https://github.com/hougesen/mdsf/pull/580)
- build(deps): bump console from 0.15.8 to 0.15.10 [`#565`](https://github.com/hougesen/mdsf/pull/565)
- build(deps): bump clap from 4.5.21 to 4.5.26 [`#571`](https://github.com/hougesen/mdsf/pull/571)
- build(deps): bump tempfile from 3.14.0 to 3.15.0 [`#573`](https://github.com/hougesen/mdsf/pull/573)
- build(deps): bump serde from 1.0.215 to 1.0.217 [`#567`](https://github.com/hougesen/mdsf/pull/567)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ mdsf init

<!-- START_SECTION:supported-tools -->

`mdsf` currently supports 213 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
`mdsf` currently supports 214 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃

| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
| [actionlint](https://github.com/rhysd/actionlint) | Static checker for GitHub Actions workflow files | `linter` | `yaml` |
| [alejandra](https://github.com/kamadorueda/alejandra) | The Uncompromising Nix Code Formatter | `formatter` | `nix` |
| [ameba](https://github.com/crystal-ameba/ameba) | A static code analysis tool for Crystal | `linter` | `crystal` |
| [asmfmt](https://github.com/klauspost/asmfmt) | Go Assembler Formatter | `formatter` | `go` |
Expand Down
34 changes: 34 additions & 0 deletions mdsf/src/tools/actionlint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::process::Command;

use crate::{error::MdsfError, execution::execute_command, runners::CommandType};

#[inline]
fn set_actionlint_args(mut cmd: Command, file_path: &std::path::Path) -> Command {
cmd.arg(file_path);
cmd
}

#[inline]
pub fn run(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let commands = [CommandType::Direct("actionlint")];

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_actionlint_args(cmd.build(), file_path);
let execution_result = execute_command(cmd, file_path);

if index == commands.len() - 1 {
return execution_result;
}

if let Ok(r) = execution_result {
if !r.0 {
return Ok(r);
}
}
}

Ok((true, None))
}

#[cfg(test)]
mod test_actionlint {}
7 changes: 7 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod actionlint;
pub mod alejandra;
pub mod ameba;
pub mod asmfmt;
Expand Down Expand Up @@ -225,6 +226,10 @@ pub mod zprint;
#[cfg_attr(test, derive(Debug, PartialEq, Eq))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum Tooling {
#[serde(rename = "actionlint")]
/// `actionlint $PATH`
Actionlint,

#[serde(rename = "alejandra")]
/// `alejandra --quiet $PATH`
Alejandra,
Expand Down Expand Up @@ -1122,6 +1127,7 @@ impl Tooling {
snippet_path: &std::path::Path,
) -> Result<(bool, Option<String>), crate::error::MdsfError> {
match self {
Self::Actionlint => actionlint::run(snippet_path),
Self::Alejandra => alejandra::run(snippet_path),
Self::Ameba => ameba::run(snippet_path),
Self::Asmfmt => asmfmt::run(snippet_path),
Expand Down Expand Up @@ -1353,6 +1359,7 @@ impl AsRef<str> for Tooling {
#[inline]
fn as_ref(&self) -> &str {
match self {
Self::Actionlint => "actionlint",
Self::Alejandra => "alejandra",
Self::Ameba => "ameba",
Self::Asmfmt => "asmfmt",
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.3.3-dev/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
},
"Tooling": {
"oneOf": [
{
"description": "`actionlint $PATH`",
"type": "string",
"enum": ["actionlint"]
},
{
"description": "`alejandra --quiet $PATH`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/actionlint/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "actionlint",
"categories": ["linter"],
"commands": {
"": ["$PATH"]
},
"description": "Static checker for GitHub Actions workflow files",
"homepage": "https://github.com/rhysd/actionlint",
"languages": ["yaml"],
"name": null,
"npm": null,
"php": null,
"tests": []
}
Loading