Skip to content
Closed
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: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup ruby
uses: ruby/setup-ruby@v1
Expand Down
34 changes: 22 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [beta, stable]
steps:
- name: Checkout Repository
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Rust toolchain ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
override: true
- name: Install rustfmt and clippy
run: |
rustup component add rustfmt clippy || true
- name: Install wasm32-unknown-unknown for ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
Expand All @@ -31,25 +33,33 @@ jobs:
# Work around https://github.com/actions/cache/issues/403 by using GNU tar
# instead of BSD tar.
- name: Install GNU tar
if: matrix.os == 'macOS-latest'
if: matrix.os == 'macos-latest'
run: |
brew install gnu-tar
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
# Install GNU tar if not present, on macOS Homebrew may be in different locations
if ! command -v gtar >/dev/null 2>&1; then
brew install gnu-tar || true
fi
# Add GNU tar to PATH via GITHUB_ENV for actions that rely on gnu-tar
if [ -d "/usr/local/opt/gnu-tar/libexec/gnubin" ]; then
echo "PATH=/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
elif [ -d "/opt/homebrew/opt/gnu-tar/libexec/gnubin" ]; then
echo "PATH=/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
fi
- name: Cache cargo registry
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION }}
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION || github.run_id }}
- name: Cache cargo index
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION }}
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION || github.run_id }}
- name: Cache cargo build
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: target
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION }}
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION || github.run_id }}
- name: Release build async-std
uses: actions-rs/cargo@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@master
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -32,6 +32,6 @@ jobs:
cargo tarpaulin --no-default-features --features runtime-async-std,cached,glob,ip,watcher,logging,incremental,explain

- name: Upload to codecov.io
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{secrets.CODECOV_TOKEN}}
19 changes: 12 additions & 7 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
on:
pull_request_target:
pull_request:
branches: [ master ]
name: Benchmarks
jobs:
runBenchmark:
name: run benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v5
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v2.1.4
uses: actions/cache@v4
with:
path: |
target
~/.cargo/git
~/.cargo/registry
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: smrpn/criterion-compare-action@move_to_actions
restore-keys: |
${{ runner.os }}-cargo-
- uses: smrpn/criterion-compare-action@master
with:
cwd: benches
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
Expand Down
8 changes: 2 additions & 6 deletions src/adapter/file_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
fs::File as file,
io::prelude::*,
io::{
BufReader as ioBufReader, Error as ioError, ErrorKind as ioErrorKind,

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (macos-latest, stable)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (macos-latest, stable)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (ubuntu-latest, beta)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (ubuntu-latest, beta)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (windows-latest, beta)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (ubuntu-latest, stable)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (ubuntu-latest, stable)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`

Check warning on line 14 in src/adapter/file_adapter.rs

View workflow job for this annotation

GitHub Actions / Auto Build CI (macos-latest, beta)

unused imports: `Error as ioError` and `ErrorKind as ioErrorKind`
},
path::Path as ioPath,
prelude::*,
};

#[cfg(feature = "runtime-tokio")]
use std::{
io::{Error as ioError, ErrorKind as ioErrorKind},
path::Path as ioPath,
};
use std::path::Path as ioPath;
#[cfg(feature = "runtime-tokio")]
use tokio::{
fs::File as file,
Expand Down Expand Up @@ -137,8 +134,7 @@

async fn save_policy(&mut self, m: &mut dyn Model) -> Result<()> {
if self.file_path.as_ref().as_os_str().is_empty() {
return Err(ioError::new(
ioErrorKind::Other,
return Err(std::io::Error::other(
"save policy failed, file path is empty",
)
.into());
Expand Down
22 changes: 9 additions & 13 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ use crate::Result;
#[cfg(feature = "runtime-async-std")]
use async_std::{
io::prelude::*,
io::{
BufReader as ioBufReader, Cursor as ioCursor, Error as ioError,
ErrorKind as ioErrorKind,
},
io::{BufReader as ioBufReader, Cursor as ioCursor},
};

#[cfg(all(feature = "runtime-async-std", not(target_arch = "wasm32")))]
use async_std::{fs::File as file, path::Path as ioPath};

#[cfg(feature = "runtime-tokio")]
use std::{io::Cursor as ioCursor, path::Path as ioPath};
use std::io::Cursor as ioCursor;
#[cfg(feature = "runtime-tokio")]
use tokio::io::{
AsyncBufReadExt, AsyncReadExt, BufReader as ioBufReader, Error as ioError,
ErrorKind as ioErrorKind,
};
use std::path::Path as ioPath;
#[cfg(feature = "runtime-tokio")]
use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader as ioBufReader};

#[cfg(all(feature = "runtime-tokio", not(target_arch = "wasm32")))]
use tokio::fs::File as file;
Expand Down Expand Up @@ -128,10 +124,10 @@ impl Config {
.collect();

if option_val.len() != 2 {
return Err(ioError::new(
ioErrorKind::Other,
format!("parse content error, line={}", line),
)
return Err(std::io::Error::other(format!(
"parse content error, line={}",
line
))
.into());
}

Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn remove_comment(s: &str) -> String {
s.trim_end().to_owned()
}

pub fn escape_eval(m: &str) -> Cow<str> {
pub fn escape_eval(m: &str) -> Cow<'_, str> {
ESC_E.replace_all(m, "eval(escape_assertion(${1}))")
}

Expand Down
Loading