Skip to content

Commit

Permalink
ci: setup github actions workflows (#24)
Browse files Browse the repository at this point in the history
* ci: setup github actions workflows

This adds linting and tests

* Formatting

* Add concurrency settings

* Format

* Test only our shell
  • Loading branch information
Hofer-Julian authored Sep 6, 2024
1 parent 4912f7f commit d2a8cd6
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 7 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/rust-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Rust Linting

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Run cargo fmt
run: cargo fmt -- --check

clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Run cargo clippy
run: cargo clippy --all-targets --workspace -- -D warnings
30 changes: 30 additions & 0 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Rust

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Run tests
run: cargo test --manifest-path crates/shell/Cargo.toml --all-targets
13 changes: 6 additions & 7 deletions crates/deno_task_shell/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pub enum RedirectOpOutput {
struct ShellParser;

pub fn parse(input: &str) -> Result<SequentialList> {
let mut pairs = ShellParser::parse(Rule::FILE, input)?;
let mut pairs = ShellParser::parse(Rule::FILE, input)?;

// println!("pairs: {:?}", pairs);

Expand Down Expand Up @@ -410,10 +410,7 @@ fn parse_compound_list(
}
}
_ => {
anyhow::bail!(
"Unexpected rule in compound_list: {:?}",
item.as_rule()
);
anyhow::bail!("Unexpected rule in compound_list: {:?}", item.as_rule());
}
}
}
Expand Down Expand Up @@ -510,7 +507,9 @@ fn parse_pipeline(pair: Pair<Rule>) -> Result<Sequence> {
.ok_or_else(|| anyhow::anyhow!("Expected pipeline content"))?;
let (negated, pipe_sequence) = if first.as_rule() == Rule::Bang {
// If it's Bang, check for whitespace
if pipeline_str.len() > 1 && !pipeline_str[1..2].chars().next().unwrap().is_whitespace() {
if pipeline_str.len() > 1
&& !pipeline_str[1..2].chars().next().unwrap().is_whitespace()
{
anyhow::bail!(
"Perhaps you meant to add a space after the exclamation point to negate the command?\n ! {}",
pipeline_str
Expand Down Expand Up @@ -709,7 +708,7 @@ fn parse_word(pair: Pair<Rule>) -> Result<Word> {
break;
}
}
};
}
if let Some(WordPart::Text(ref mut text)) = parts.last_mut() {
text.push_str(&escaped_char);
} else {
Expand Down

0 comments on commit d2a8cd6

Please sign in to comment.