Skip to content

Commit

Permalink
feat: imporve CI (#8)
Browse files Browse the repository at this point in the history
* feat: improve CI

* fix: clippy warnings
  • Loading branch information
MuZhou233 authored Feb 26, 2024
1 parent 0e82673 commit 3c5bec6
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 65 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/CI.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Auto Build

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
name: Auto Build CI
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [nightly, beta, stable]

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

- name: Install Rust toolchain
run: |
rustup set profile minimal
rustup update --no-self-update ${{ matrix.rust }}
rustup component add --toolchain ${{ matrix.rust }} rustfmt clippy
rustup default ${{ matrix.rust }}
- name: Cargo Build
run: cargo build

- name: Cargo Clippy
run: cargo clippy -- -D warnings

- name: Cargo Fmt Check
run: cargo fmt --all -- --check
34 changes: 34 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Code Coverage

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
cover:
name: Auto Codecov Coverage
runs-on: ubuntu-latest

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

- name: Install Rust toolchain
run: |
rustup set profile minimal
rustup update --no-self-update stable
rustup default stable
- name: Run cargo-tarpaulin
run: |
cargo install cargo-tarpaulin
cargo tarpaulin --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{secrets.CODECOV_TOKEN}}
23 changes: 8 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@ jobs:

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

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
run: |
rustup set profile minimal
rustup update --no-self-update stable
rustup default stable
- name: Cargo Login
uses: actions-rs/cargo@v1
with:
command: login
args: -- ${{ secrets.CARGO_TOKEN }}
run: cargo login ${{ secrets.CARGO_TOKEN }}

- name: Cargo Publish
uses: actions-rs/cargo@v1
with:
command: publish
args: --no-verify
run: cargo publish

- name: GitHub Release
id: create_release
Expand All @@ -43,4 +36,4 @@ jobs:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
prerelease: false
3 changes: 1 addition & 2 deletions src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ use bytes::Bytes;
use casbin::prelude::{TryIntoAdapter, TryIntoModel};
use casbin::{CachedEnforcer, CoreApi, Result as CasbinResult};
use futures::future::BoxFuture;
use http::{self, Request, StatusCode};
use http::{Request, StatusCode};
use http_body::{Body as HttpBody, Full};
use std::{
boxed::Box,
convert::Infallible,
ops::{Deref, DerefMut},
sync::Arc,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use bytes::Bytes;
use casbin::function_map::key_match2;
use casbin::{CoreApi, DefaultModel, FileAdapter};
use futures::future::BoxFuture;
use http::{self, Request, StatusCode};
use http::{Request, StatusCode};
use http_body::Body as HttpBody;
use std::{
boxed::Box,
convert::Infallible,
task::{Context, Poll},
};
Expand Down
3 changes: 1 addition & 2 deletions tests/test_middleware_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use axum_test_helper::TestClient;
use bytes::Bytes;
use casbin::{DefaultModel, FileAdapter};
use futures::future::BoxFuture;
use http::{self, Request, StatusCode};
use http::{Request, StatusCode};
use http_body::Body as HttpBody;
use std::{
boxed::Box,
convert::Infallible,
task::{Context, Poll},
};
Expand Down
3 changes: 1 addition & 2 deletions tests/test_set_enforcer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use bytes::Bytes;
use casbin::function_map::key_match2;
use casbin::{CachedEnforcer, CoreApi, DefaultModel, FileAdapter};
use futures::future::BoxFuture;
use http::{self, Request, StatusCode};
use http::{Request, StatusCode};
use http_body::Body as HttpBody;
use std::{
boxed::Box,
convert::Infallible,
sync::Arc,
task::{Context, Poll},
Expand Down

0 comments on commit 3c5bec6

Please sign in to comment.