Skip to content

Commit 0d5c318

Browse files
authored
Merge pull request #19 from openSVM/0xrinegade/update-ci-workflows
Update CI workflows for consistency and performance
2 parents ed3a548 + 294c49f commit 0d5c318

File tree

7 files changed

+189
-170
lines changed

7 files changed

+189
-170
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tasks": {
3+
"build": "cargo build --release"
4+
}
5+
}

.github/workflows/benchmarks.yml

Lines changed: 58 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,72 @@ name: Benchmarks
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- main
67
pull_request:
7-
branches: [ main ]
8-
schedule:
9-
- cron: '0 0 * * 0' # Run weekly on Sundays
10-
11-
env:
12-
CARGO_TERM_COLOR: always
13-
RUST_BACKTRACE: 1
8+
branches:
9+
- main
1410

1511
jobs:
16-
benchmarks:
17-
name: Run Benchmarks
12+
benchmark:
1813
runs-on: ubuntu-latest
14+
1915
steps:
20-
- uses: actions/checkout@v3
21-
22-
- name: Install Rust
23-
uses: actions-rs/toolchain@v1
24-
with:
25-
profile: minimal
26-
toolchain: stable
27-
override: true
28-
29-
- name: Cache dependencies
30-
uses: actions/cache@v3
31-
with:
32-
path: |
33-
~/.cargo/registry
34-
~/.cargo/git
35-
target
36-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
37-
38-
- name: Install cargo-criterion
39-
uses: actions-rs/[email protected]
40-
with:
41-
crate: cargo-criterion
42-
version: latest
43-
use-tool-cache: true
44-
45-
- name: Run benchmarks
46-
uses: actions-rs/cargo@v1
47-
with:
48-
command: criterion
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Install Rust
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
toolchain: stable
23+
override: true
24+
25+
- name: Install dependencies
26+
run: sudo apt-get update && sudo apt-get install -y libudev-dev
27+
28+
- name: Set environment variables
29+
run: |
30+
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
31+
export LD_LIBRARY_PATH=/usr/local/lib
32+
33+
- name: Run benchmarks
34+
run: |
35+
export RUST_BACKTRACE=full
36+
cargo bench
4937
50-
- name: Create benchmark results directory
51-
run: mkdir -p target/criterion
38+
- name: Create benchmark results directory
39+
run: mkdir -p target/criterion
5240

53-
- name: Upload benchmark results
54-
uses: actions/upload-artifact@v3
55-
with:
56-
name: benchmark-results
57-
path: target/criterion
58-
if-no-files-found: warn
41+
- name: Upload benchmark results
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: benchmark-results
45+
path: target/criterion
46+
if-no-files-found: warn
5947

60-
- name: Generate benchmark report
61-
run: |
62-
mkdir -p benchmark-report
48+
- name: Generate benchmark report
49+
run: |
50+
mkdir -p benchmark-report
51+
if [ -d "target/criterion" ]; then
6352
cp -r target/criterion/* benchmark-report/ || true
64-
echo "# Benchmark Results" > benchmark-report/README.md
65-
echo "Generated on $(date)" >> benchmark-report/README.md
66-
echo "## Summary" >> benchmark-report/README.md
67-
find target/criterion -name "*/new/estimates.json" -exec cat {} \; | jq -r '.mean | { command: .point_estimate, lower_bound: .confidence_interval.lower_bound, upper_bound: .confidence_interval.upper_bound }' >> benchmark-report/README.md || echo "No benchmark results found" >> benchmark-report/README.md
53+
fi
54+
echo "# Benchmark Results" > benchmark-report/README.md
55+
echo "Generated on $(date)" >> benchmark-report/README.md
56+
echo "## Summary" >> benchmark-report/README.md
57+
find target/criterion -name "*/new/estimates.json" -exec cat {} \; | jq -r '.mean | { command: .point_estimate, lower_bound: .confidence_interval.lower_bound, upper_bound: .confidence_interval.upper_bound}' >> benchmark-report/README.md
6858
69-
- name: Upload benchmark report
70-
uses: actions/upload-artifact@v3
71-
with:
72-
name: benchmark-report
73-
path: benchmark-report
74-
if-no-files-found: warn
59+
- name: Upload benchmark report
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: benchmark-report
63+
path: benchmark-report
64+
if-no-files-found: warn
7565

76-
- name: Compare with previous benchmarks
77-
if: github.event_name == 'pull_request'
78-
run: |
79-
git fetch origin ${{ github.base_ref }}
80-
git checkout FETCH_HEAD
81-
cargo criterion --baseline main
82-
git checkout ${{ github.sha }}
83-
cargo criterion --baseline main
66+
- name: Compare with previous benchmarks
67+
if: github.event_name == 'pull_request'
68+
run: |
69+
git fetch origin ${{ github.base_ref }}
70+
git checkout FETCH_HEAD
71+
cargo criterion --baseline main
72+
git checkout ${{ github.sha }}
73+
cargo criterion --baseline main

.github/workflows/ci.yml

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ jobs:
1515
name: Sanity Checks
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
19-
18+
- uses: actions/checkout@v4
19+
- name: Install dependencies
20+
run: sudo apt-get update && sudo apt-get install -y libudev-dev
21+
2022
- name: Install Rust
21-
uses: actions-rs/toolchain@v1
23+
uses: dtolnay/rust-toolchain@stable
2224
with:
2325
profile: minimal
2426
toolchain: stable
2527
override: true
2628
components: rustfmt, clippy
2729

2830
- name: Cache dependencies
29-
uses: actions/cache@v3
31+
uses: actions/cache@v4
3032
with:
3133
path: |
3234
~/.cargo/registry
@@ -35,33 +37,32 @@ jobs:
3537
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3638

3739
- name: Check formatting
38-
uses: actions-rs/cargo@v1
39-
with:
40-
command: fmt
41-
args: --all -- --check
40+
run: cargo fmt --all -- --check
41+
working-directory: .
4242

4343
- name: Run clippy
44-
uses: actions-rs/cargo@v1
45-
with:
46-
command: clippy
47-
args: -- -D warnings
44+
run: cargo clippy -- -D warnings
45+
working-directory: .
4846

4947
unit-tests:
5048
name: Unit Tests
5149
needs: sanity-check
5250
runs-on: ubuntu-latest
5351
steps:
54-
- uses: actions/checkout@v3
52+
- uses: actions/checkout@v4
53+
54+
- name: Install dependencies
55+
run: sudo apt-get update && sudo apt-get install -y libudev-dev
5556

5657
- name: Install Rust
57-
uses: actions-rs/toolchain@v1
58+
uses: dtolnay/rust-toolchain@stable
5859
with:
5960
profile: minimal
6061
toolchain: stable
6162
override: true
6263

6364
- name: Cache dependencies
64-
uses: actions/cache@v3
65+
uses: actions/cache@v4
6566
with:
6667
path: |
6768
~/.cargo/registry
@@ -70,27 +71,28 @@ jobs:
7071
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
7172

7273
- name: Run unit tests
73-
uses: actions-rs/cargo@v1
74-
with:
75-
command: test
76-
args: --lib --bins
74+
run: cargo test --lib --bins
75+
working-directory: .
7776

7877
e2e-tests:
7978
name: End-to-End Tests
8079
needs: unit-tests
8180
runs-on: ubuntu-latest
8281
steps:
83-
- uses: actions/checkout@v3
82+
- uses: actions/checkout@v4
83+
84+
- name: Install dependencies
85+
run: sudo apt-get update && sudo apt-get install -y libudev-dev
8486

8587
- name: Install Rust
86-
uses: actions-rs/toolchain@v1
88+
uses: dtolnay/rust-toolchain@stable
8789
with:
8890
profile: minimal
8991
toolchain: stable
9092
override: true
9193

9294
- name: Cache dependencies
93-
uses: actions/cache@v3
95+
uses: actions/cache@v4
9496
with:
9597
path: |
9698
~/.cargo/registry
@@ -99,46 +101,40 @@ jobs:
99101
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
100102

101103
- name: Build binary
102-
uses: actions-rs/cargo@v1
103-
with:
104-
command: build
105-
args: --release
104+
run: cargo build --release
105+
working-directory: .
106106

107107
- name: Run e2e tests
108-
uses: actions-rs/cargo@v1
109-
with:
110-
command: test
111-
args: --test main
108+
run: cargo test --test main
109+
working-directory: .
112110

113111
code-coverage:
114112
name: Code Coverage
115113
needs: [unit-tests, e2e-tests]
116114
runs-on: ubuntu-latest
117115
steps:
118-
- uses: actions/checkout@v3
119-
116+
- uses: actions/checkout@v4
117+
118+
- name: Install dependencies
119+
run: sudo apt-get update && sudo apt-get install -y libudev-dev
120+
120121
- name: Install Rust
121-
uses: actions-rs/toolchain@v1
122+
uses: dtolnay/rust-toolchain@stable
122123
with:
123124
profile: minimal
124125
toolchain: stable
125126
override: true
126127

127128
- name: Install cargo-tarpaulin
128-
uses: actions-rs/[email protected]
129-
with:
130-
crate: cargo-tarpaulin
131-
version: latest
132-
use-tool-cache: true
129+
run: cargo install cargo-tarpaulin
130+
working-directory: .
133131

134132
- name: Generate coverage report
135-
uses: actions-rs/cargo@v1
136-
with:
137-
command: tarpaulin
138-
args: --out Xml --output-dir coverage
133+
run: cargo tarpaulin --out Xml --output-dir coverage
134+
working-directory: .
139135

140136
- name: Upload coverage to Codecov
141-
uses: codecov/codecov-action@v3
137+
uses: codecov/codecov-action@v4
142138
with:
143139
directory: ./coverage/
144-
fail_ci_if_error: true
140+
fail_ci_if_error: true

.github/workflows/cross-platform.yml

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@ jobs:
1818
os: [ubuntu-latest, macos-latest, windows-latest]
1919
runs-on: ${{ matrix.os }}
2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
22+
23+
- name: Install dependencies
24+
if: runner.os == 'linux'
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y libudev-dev
2228
2329
- name: Install Rust
24-
uses: actions-rs/toolchain@v1
30+
uses: dtolnay/rust-toolchain@stable
2531
with:
2632
profile: minimal
2733
toolchain: stable
2834
override: true
2935

3036
- name: Cache dependencies
31-
uses: actions/cache@v3
37+
uses: actions/cache@v4
3238
with:
3339
path: |
3440
~/.cargo/registry
@@ -37,19 +43,38 @@ jobs:
3743
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3844

3945
- name: Build
40-
uses: actions-rs/cargo@v1
41-
with:
42-
command: build
46+
run: cargo build
47+
working-directory: .
4348

4449
- name: Run unit tests
45-
uses: actions-rs/cargo@v1
46-
with:
47-
command: test
48-
args: --lib --bins
50+
run: cargo test --lib --bins
51+
working-directory: .
4952

5053
- name: Run e2e tests
51-
uses: actions-rs/cargo@v1
52-
with:
53-
command: test
54-
args: --test "*"
54+
run: cargo test --test "*"
55+
working-directory: .
5556
continue-on-error: true
57+
58+
release:
59+
name: release ${{ matrix.target }}
60+
runs-on: ubuntu-latest
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
include:
65+
- target: x86_64-pc-windows-gnu
66+
archive: zip
67+
- target: x86_64-unknown-linux-musl
68+
archive: tar.gz tar.xz tar.zst
69+
- target: x86_64-apple-darwin
70+
archive: zip
71+
steps:
72+
- uses: actions/checkout@master
73+
- name: Compile and release
74+
uses: rust-build/[email protected]
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
with:
78+
RUSTTARGET: ${{ matrix.target }}
79+
ARCHIVE_TYPES: ${{ matrix.archive }}
80+

0 commit comments

Comments
 (0)