Skip to content

Commit fd8bc83

Browse files
committed
ci(action/config): Update GitHub workflows
- Configure Dependabot for GitHub Actions and Cargo dependencies. - Add a scheduled audit job to run daily using rustsec/audit-check.
1 parent c9f5185 commit fd8bc83

File tree

6 files changed

+181
-58
lines changed

6 files changed

+181
-58
lines changed

.github/workflows/audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
- name: Checkout code
1212
uses: actions/checkout@v4
1313
- name: Run audit check
14-
uses: actions-rs/audit-check@v1
14+
uses: rustsec/audit-check@v2
1515
with:
1616
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/check.yml

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,61 @@ on:
1010
branches: [ "main" ]
1111

1212
jobs:
13+
check:
14+
name: Check
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 5
17+
strategy:
18+
fail-fast: true
19+
matrix:
20+
rustc: [ nightly, stable ] # MSVR and current stable rustc
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: dtolnay/rust-toolchain@master
24+
with:
25+
toolchain: ${{ matrix.rustc }}
26+
- uses: actions-rs/cargo@v1
27+
with:
28+
command: check
1329
rust_fmt_check:
1430
name: RustFmt check
1531
runs-on: ubuntu-latest
1632
steps:
1733
- name: Checkout code
1834
uses: actions/checkout@v4
19-
- uses: actions/cache@v3
35+
- uses: actions/cache@v4
2036
with:
2137
path: |
2238
~/.cargo/registry
2339
~/.cargo/git
2440
target
2541
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
2642
- name: Install rust
27-
uses: actions-rs/toolchain@v1
43+
uses: dtolnay/rust-toolchain@master
2844
with:
2945
toolchain: stable
3046
components: rustfmt
3147
- name: Run cargo fmt
32-
uses: actions-rs/cargo@v1
33-
with:
34-
command: fmt
35-
args: -- --check
48+
run: cargo fmt --all -- --check
3649
clippy_check:
3750
name: Clippy check
3851
runs-on: ubuntu-latest
3952
steps:
4053
- name: Checkout code
4154
uses: actions/checkout@v4
42-
- uses: actions/cache@v3
55+
- uses: actions/cache@v4
4356
with:
4457
path: |
4558
~/.cargo/registry
4659
~/.cargo/git
4760
target
4861
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
49-
- name: Install clippy
50-
run: rustup component add clippy
51-
- name: Run clippy check
52-
uses: actions-rs/clippy-check@v1
62+
- uses: dtolnay/rust-toolchain@master
5363
with:
54-
token: ${{ secrets.GITHUB_TOKEN }}
55-
args: --all-features
64+
toolchain: stable
65+
components: clippy
66+
- name: Run clippy check
67+
run: cargo clippy --all-features
5668
test:
5769
name: Run tests
5870
runs-on: ubuntu-latest
@@ -67,8 +79,27 @@ jobs:
6779
target
6880
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
6981
- name: Install rust
70-
uses: actions-rs/toolchain@v1
71-
- name: Run cargo test
72-
uses: actions-rs/cargo@v1
82+
uses: dtolnay/rust-toolchain@master
7383
with:
74-
command: test
84+
toolchain: stable
85+
- name: Run cargo test
86+
run: cargo test --all-features
87+
publish_on_crates_io:
88+
name: Publish on crates.io
89+
runs-on: ubuntu-latest
90+
if: startsWith(github.ref, 'refs/tags') # Only on tags
91+
needs:
92+
- check
93+
- rust_fmt_check
94+
- clippy_check
95+
- test
96+
steps:
97+
- name: Checkout code
98+
uses: actions/checkout@v4
99+
- name: Install rust
100+
uses: dtolnay/rust-toolchain@stable
101+
- name: Run cargo publish
102+
run: cargo publish --registry crates-io --package polaris-rust --allow-dirty
103+
env:
104+
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
105+

.github/workflows/docs.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
name: Docs
7+
8+
jobs:
9+
docs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout sources
13+
uses: actions/checkout@v4
14+
with:
15+
submodules: 'recursive'
16+
17+
- name: Install build dependencies
18+
run: |
19+
sudo apt update
20+
sudo apt install -y cmake libclang-dev
21+
22+
- name: Install stable toolchain
23+
uses: dtolnay/rust-toolchain@stable
24+
25+
- name: Run cargo doc
26+
run: cargo doc --no-deps --all-features

.github/workflows/rust-clippy.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# rust-clippy is a tool that runs a bunch of lints to catch common
6+
# mistakes in your Rust code and help improve your Rust code.
7+
# More details at https://github.com/rust-lang/rust-clippy
8+
# and https://rust-lang.github.io/rust-clippy/
9+
10+
name: rust-clippy analyze
11+
12+
on:
13+
push:
14+
branches: [ "main" ]
15+
pull_request:
16+
# The branches below must be a subset of the branches above
17+
branches: [ "main" ]
18+
schedule:
19+
- cron: '25 15 * * 1'
20+
21+
jobs:
22+
rust-clippy-analyze:
23+
name: Run rust-clippy analyzing
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
security-events: write
28+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Install Rust toolchain
34+
uses: dtolnay/rust-toolchain@stable
35+
with:
36+
components: clippy
37+
38+
- name: Install required cargo
39+
run: cargo install clippy-sarif sarif-fmt
40+
41+
- name: Run rust-clippy
42+
run:
43+
cargo clippy
44+
--all-features
45+
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
46+
continue-on-error: true
47+
48+
- name: Upload analysis results to GitHub
49+
uses: github/codeql-action/upload-sarif@v3
50+
with:
51+
sarif_file: rust-clippy-results.sarif
52+
wait-for-processing: true

Cargo.toml

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,67 @@
11
[package]
2-
edition = "2021"
32
name = "polaris-rust"
4-
version = "0.0.1"
3+
edition = "2021"
4+
version = "0.2.0"
5+
license = "BSD 3-Clause"
6+
authors = ["houseme <[email protected]>", "liaochuntao <[email protected]>"]
7+
repository = "https://github.com/polaris-contrib/polaris-rust"
8+
description = "Lightweight Rust SDK used as Proxyless Service Governance Solution."
9+
homepage = "https://polarismesh.cn"
10+
documentation = "https://docs.rs/polaris-rust"
11+
keywords = ["polaris", "solution", "governance", "server", "proxyless"]
12+
categories = ["config", "asynchronous", "development-tools"]
13+
readme = "README.md"
514

615
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
716
[dependencies]
8-
bytes = {version = "1.4.0"}
9-
schemars = {version = "0.8.16"}
10-
serde = {version = "1.0.198", features = ["derive"]}
11-
serde-duration-ext = {version = "0.1.0"}
12-
serde_json = {version = "1.0.116"}
13-
serde_yaml = {version = "0.9.34"}
14-
15-
uuid = {version = "1.8.0", features = [
16-
"v4", # Lets you generate random UUIDs
17-
"fast-rng", # Use a faster (but still sufficiently random) RNG
18-
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
19-
]}
17+
bytes = { version = "1.4.0" }
18+
schemars = { version = "0.8.16" }
19+
serde = { version = "1.0.198", features = ["derive"] }
20+
serde-duration-ext = { version = "0.1.0" }
21+
serde_json = { version = "1.0.116" }
22+
serde_yaml = { version = "0.9.34" }
23+
24+
uuid = { version = "1.8.0", features = [
25+
"v4", # Lets you generate random UUIDs
26+
"fast-rng", # Use a faster (but still sufficiently random) RNG
27+
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
28+
] }
2029

2130
# cache
22-
dashmap = {version = "5.4.0"}
31+
dashmap = { version = "5.4.0" }
2332

2433
# http
25-
reqwest = {version = "0.12.8", features = ["blocking"]}
34+
reqwest = { version = "0.12.8", features = ["blocking"] }
2635

2736
# async
28-
async-trait = {version = "0.1"}
29-
http = {version = "0.2.12"}
30-
hyper = {version = "0.14.28", features = ["full"]}
31-
tokio = {version = "1.37.0", features = ["full"]}
32-
tokio-stream = {version = "0.1.16"}
33-
tower = {version = "0.4.13"}
37+
async-trait = { version = "0.1" }
38+
http = { version = "0.2.12" }
39+
hyper = { version = "0.14.28", features = ["full"] }
40+
tokio = { version = "1.37.0", features = ["full"] }
41+
tokio-stream = { version = "0.1.16" }
42+
tower = { version = "0.4.13" }
3443

3544
# gRPC dep
36-
futures = {version = "0.3.30"}
37-
once_cell = {version = "1.19.0"}
38-
prost = {version = "0.12.4"}
39-
prost-build = {version = "0.12.4"}
40-
prost-types = {version = "0.12.4"}
41-
tonic = {version = "0.11.0"}
45+
futures = { version = "0.3.30" }
46+
once_cell = { version = "1.19.0" }
47+
prost = { version = "0.12.4" }
48+
prost-build = { version = "0.12.4" }
49+
prost-types = { version = "0.12.4" }
50+
tonic = { version = "0.11.0" }
4251

4352
# logging
44-
tracing = {version = "0.1.36"}
53+
tracing = { version = "0.1.36" }
4554

4655
# crypto
47-
aes = {version = "0.7.4"}
48-
base64 = {version = "0.22.1"}
49-
block-modes = {version = "0.8.1"}
50-
hex = {version = "0.4.3"}
51-
rand = {version = "0.8.4"}
52-
rsa = {version = "0.9.6"}
56+
aes = { version = "0.7.4" }
57+
base64 = { version = "0.22.1" }
58+
block-modes = { version = "0.8.1" }
59+
hex = { version = "0.4.3" }
60+
rand = { version = "0.8.4" }
61+
rsa = { version = "0.9.6" }
5362

5463
[dev-dependencies]
55-
tracing-subscriber = {version = "0.3", features = ["default"]}
64+
tracing-subscriber = { version = "0.3", features = ["default"] }
5665

5766
[[example]]
5867
name = "discover"

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
# Polaris rust sdk
22

3-
[![Build](https://github.com/polarismesh/polaris-rust/workflows/Build/badge.svg)](https://github.com/polarismesh/polaris-rust/actions?query=workflow%3ABuild)
3+
[![Build](https://github.com/polaris-contrib/polaris-rust/workflows/Build/badge.svg)](https://github.com/polarismesh/polaris-rust/actions?query=workflow%3ABuild)
44
[![docs.rs](https://docs.rs/polaris-rust/badge.svg)](https://docs.rs/polaris-rust/)
5-
[![License](https://img.shields.io/crates/l/polaris-rust)](LICENSE-APACHE)
5+
[![License](https://img.shields.io/crates/l/polaris-rust)](LICENSE)
66
[![Crates.io](https://img.shields.io/crates/v/polaris-rust)](https://crates.io/crates/polaris-rust)
77
[![Crates.io](https://img.shields.io/crates/d/polaris-rust)](https://crates.io/crates/polaris-rust)
88

99
## Introduction
10+
1011
Lightweight Rust SDK used as Proxyless Service Governance
1112

1213
## Install
13-
Add the following to your `Cargo.toml`:
14+
15+
Add the following to your `Cargo.toml`:
16+
1417
```toml
1518
[dependencies]
16-
polaris-rust = "0.0.1"
19+
polaris-rust = "0.2.0"
1720
```
1821

1922
## Quickstart
23+
2024
rust version >= 1.63.0
2125

2226
```rust
@@ -28,6 +32,7 @@ rust version >= 1.63.0
2832
Run them yourself with `cargo bench`.
2933

3034
## License
35+
3136
Licensed under either of
3237

3338
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)

0 commit comments

Comments
 (0)