From 669ad6a7bfcec7e04cbf1031f0f61a070fe21cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Wed, 7 Sep 2022 14:15:38 +1200 Subject: [PATCH] Ditch actions-rs (#395) --- .github/workflows/audit.yml | 18 ------- .github/workflows/clippy.yml | 34 ++++++++---- .github/workflows/release-cli.yml | 80 +++++++++++++++++------------ .github/workflows/release-tag.yml | 2 +- .github/workflows/tests.yml | 38 +++++++++----- crates/cli/src/args.rs | 2 +- crates/cli/src/filterer/common.rs | 2 +- crates/filterer/globset/src/lib.rs | 4 +- crates/ignore-files/src/discover.rs | 9 +--- 9 files changed, 104 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/audit.yml diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml deleted file mode 100644 index fddbf01..0000000 --- a/.github/workflows/audit.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Security audit -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' -jobs: - audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 8261eea..cda626a 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -9,6 +9,10 @@ on: tags-ignore: - "*" +env: + CARGO_TERM_COLOR: always + CARGO_UNSTABLE_SPARSE_REGISTRY: "true" + jobs: check: strategy: @@ -22,14 +26,24 @@ jobs: runs-on: "${{ matrix.platform }}-latest" steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 - with: - command: clippy + - uses: actions/checkout@v3 + - name: Configure toolchain + run: | + rustup toolchain install --profile minimal --no-self-update nightly + rustup default nightly + rustup component add clippy + - name: Configure caching + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Clippy + run: cargo clippy -- -D clippy::all diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index ddf2500..a133fa4 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -7,6 +7,10 @@ on: tags: - "v*.*.*" +env: + CARGO_TERM_COLOR: always + CARGO_UNSTABLE_SPARSE_REGISTRY: "true" + jobs: info: name: Gather info @@ -16,7 +20,7 @@ jobs: release_notes: ${{ fromJSON(steps.notes.outputs.notes_json) }} announce: ${{ steps.announce.outputs.announce }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Extract version id: version shell: bash @@ -159,11 +163,19 @@ jobs: dst: watchexec-${{ needs.info.outputs.cli_version }}-${{ matrix.target }} steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - name: Configure caching + uses: actions/cache@v3 with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-${{ matrix.target }}- + ${{ runner.os }}-cargo- - name: Add musl tools run: sudo apt install -y musl musl-dev musl-tools @@ -183,31 +195,38 @@ jobs: - name: Install cargo-deb if: startsWith(matrix.name, 'linux-') - uses: baptiste0928/cargo-install@v1 + uses: taiki-e/install-action@v1 with: - crate: cargo-deb - version: 1.34.2 + tool: cargo-deb - name: Install cargo-generate-rpm if: startsWith(matrix.name, 'linux-') - uses: baptiste0928/cargo-install@v1 + uses: taiki-e/install-action@v1 with: - crate: cargo-generate-rpm - version: 0.6.0 + tool: cargo-generate-rpm - - uses: actions-rs/toolchain@v1 - with: - target: ${{ matrix.target }} - toolchain: stable - profile: minimal - override: true + - name: Configure toolchain + run: | + rustup toolchain install --profile minimal --no-self-update stable + rustup default stable - - uses: actions-rs/cargo@v1 - name: Build + - name: Install cross + if: matrix.cross + uses: taiki-e/install-action@v1 with: - use-cross: ${{ matrix.cross }} - command: build - args: --package watchexec-cli --release --locked --target ${{ matrix.target }} + tool: cross + + - name: Install host target + if: "!matrix.cross" + run: rustup target add ${{ matrix.target }} + + - name: Build (cargo) + if: "!matrix.cross" + run: cargo build --package watchexec-cli --release --locked --target ${{ matrix.target }} + + - name: Build (cross) + if: matrix.cross + run: cross build --package watchexec-cli --release --locked --target ${{ matrix.target }} - name: Package shell: bash @@ -245,7 +264,7 @@ jobs: shell: bash run: 7z a "$dst.zip" "$dst" - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: builds retention-days: 1 @@ -262,23 +281,20 @@ jobs: name: Checksum and sign runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install rsign2 - uses: baptiste0928/cargo-install@v1 + uses: taiki-e/install-action@v1 with: - crate: rsign2 - version: 0.6.1 + tool: rsign2 - name: Install b3sum - uses: baptiste0928/cargo-install@v1 + uses: taiki-e/install-action@v1 with: - crate: b3sum - version: 1.3.0 + tool: b3sum - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: builds diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index 8e6fb8b..9cb4af2 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -29,7 +29,7 @@ jobs: echo "CUSTOM_TAG=${crate}-${version}" >> $GITHUB_ENV fi - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Push release tag id: tag_version uses: mathieudutour/github-tag-action@v6.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ee8aa8c..72ea5e0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,6 +9,10 @@ on: tags-ignore: - "*" +env: + CARGO_TERM_COLOR: always + CARGO_UNSTABLE_SPARSE_REGISTRY: "true" + jobs: test: strategy: @@ -25,15 +29,25 @@ jobs: runs-on: "${{ matrix.platform }}-latest" steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: "${{ matrix.toolchain }}" - override: true - - name: Run test suite - uses: actions-rs/cargo@v1 - with: - command: test - - name: Check that CLI runs - run: cargo run -p watchexec-cli -- -1 echo + - uses: actions/checkout@v3 + - name: Configure toolchain + run: | + rustup toolchain install --profile minimal --no-self-update ${{ matrix.toolchain }} + rustup default ${{ matrix.toolchain }} + - name: Configure caching + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-${{ matrix.toolchain }}- + ${{ runner.os }}-cargo- + + - name: Run test suite + run: cargo test + - name: Check that CLI runs + run: cargo run -p watchexec-cli -- -1 echo diff --git a/crates/cli/src/args.rs b/crates/cli/src/args.rs index 62a55a7..d54b1c9 100644 --- a/crates/cli/src/args.rs +++ b/crates/cli/src/args.rs @@ -45,7 +45,7 @@ pub fn get_args(tagged_filterer: bool) -> Result { .help_heading(Some(OPTSET_BEHAVIOUR)) .help("Select the behaviour to use when receiving events while the command is running. Current default is queue, will change to do-nothing in 2.0.") .takes_value(true) - .possible_values(&["do-nothing", "queue", "restart", "signal"]) + .possible_values(["do-nothing", "queue", "restart", "signal"]) .long("on-busy-update")) .arg(Arg::new("restart") .help_heading(Some(OPTSET_BEHAVIOUR)) diff --git a/crates/cli/src/filterer/common.rs b/crates/cli/src/filterer/common.rs index 197db38..47c7d4c 100644 --- a/crates/cli/src/filterer/common.rs +++ b/crates/cli/src/filterer/common.rs @@ -169,7 +169,7 @@ pub async fn ignores( .filter(|ig| { !ig.applies_in .as_ref() - .map_or(false, |p| p.starts_with(&origin)) + .map_or(false, |p| p.starts_with(origin)) }) .collect::>(); debug!( diff --git a/crates/filterer/globset/src/lib.rs b/crates/filterer/globset/src/lib.rs index 59a18c6..58d7e3e 100644 --- a/crates/filterer/globset/src/lib.rs +++ b/crates/filterer/globset/src/lib.rs @@ -56,8 +56,8 @@ impl GlobsetFilterer { extensions: impl IntoIterator, ) -> Result { let origin = origin.as_ref(); - let mut filters_builder = GitignoreBuilder::new(&origin); - let mut ignores_builder = GitignoreBuilder::new(&origin); + let mut filters_builder = GitignoreBuilder::new(origin); + let mut ignores_builder = GitignoreBuilder::new(origin); for (filter, in_path) in filters { trace!(filter=?&filter, "add filter to globset filterer"); diff --git a/crates/ignore-files/src/discover.rs b/crates/ignore-files/src/discover.rs index e9f7fec..d2ef87f 100644 --- a/crates/ignore-files/src/discover.rs +++ b/crates/ignore-files/src/discover.rs @@ -461,14 +461,7 @@ impl DirTourist { pub fn skip(&mut self, path: PathBuf) { let check_path = path.as_path(); - self.to_visit = self - .to_visit - .iter() - .filter(|p| !p.starts_with(check_path)) - .cloned() - .collect(); - // TODO: use drain_filter when that lands - + self.to_visit.retain(|p| !p.starts_with(check_path)); self.to_skip.insert(path); }