Skip to content

Commit

Permalink
Allows multiple commands to watch (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: Cecile Tonglet <[email protected]>
  • Loading branch information
yozhgoor and cecton authored Oct 17, 2023
1 parent 805988a commit bfce374
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 141 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/main.yml

This file was deleted.

65 changes: 0 additions & 65 deletions .github/workflows/pr.yml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Rust

on:
push:
branches: [ main ]
schedule:
- cron: 0 0 1 * *
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
test:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
rust:
- stable
- 1.73.0 # MSRV
include:
- os: ubuntu-latest
rust: stable
lint: 1
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source
uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
default: true
override: true

- uses: Swatinem/rust-cache@v1

- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features

- name: rustfmt
if: github.event_name == 'pull_request' && matrix.lint
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: clippy
if: github.event_name == 'pull_request' && matrix.lint
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --tests --all-features -- -D warnings
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "xtask-watch"
version = "0.1.6"
edition = "2021"
rust-version = "1.73"
license = "MIT OR Apache-2.0"
description = "A customizable helper to watch for changes in your projects using xtask."
homepage = "https://github.com/rustminded/xtask-wasm"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![dependencies status][deps-badge]][deps-url]
![licenses][licenses-badge]

[actions-badge]: https://github.com/rustminded/xtask-watch/workflows/main/badge.svg
[actions-badge]: https://github.com/rustminded/xtask-watch/workflows/rust/badge.svg
[actions-url]: https://github.com/rustminded/xtask-watch/actions
[crates-version-badge]: https://img.shields.io/crates/v/xtask-watch
[crates-url]: https://crates.io/crates/xtask-watch
Expand Down
21 changes: 13 additions & 8 deletions examples/demo/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,27 @@ fn main() -> Result<()> {

match opt {
Opt::Watch { command, watch } => {
let command = if !command.is_empty() {
log::info!("starting to watch");
if !command.is_empty() {
let mut it = command.iter();

let mut command = Command::new(it.next().unwrap());
command.args(it);

command
watch.run(command)?;
} else {
let mut command = Command::new("cargo");
command.arg("check");
let mut check = Command::new("cargo");
check.arg("check");

command
};
let mut test = Command::new("cargo");
test.arg("test");

log::info!("starting to watch");
watch.run(command)?;
let mut sleep = Command::new("bash");
sleep.arg("-c");
sleep.arg("echo sleeping for 10 seconds...; sleep 10; echo sleep ended");

watch.run([check, test, sleep])?;
}
}
}

Expand Down
Loading

0 comments on commit bfce374

Please sign in to comment.