Skip to content

Commit 1dd8221

Browse files
committed
add CI
Signed-off-by: Charalampos Mitrodimas <[email protected]>
1 parent c9f210d commit 1dd8221

File tree

5 files changed

+301
-0
lines changed

5 files changed

+301
-0
lines changed

.github/workflows/ci.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, macos-latest]
19+
rust: [stable]
20+
include:
21+
- os: ubuntu-latest
22+
rust: beta
23+
- os: ubuntu-latest
24+
rust: nightly
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Install Rust
30+
uses: dtolnay/rust-toolchain@master
31+
with:
32+
toolchain: ${{ matrix.rust }}
33+
components: rustfmt, clippy
34+
35+
- name: Cache cargo registry
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.cargo/registry
39+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
40+
41+
- name: Cache cargo index
42+
uses: actions/cache@v4
43+
with:
44+
path: ~/.cargo/git
45+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
46+
47+
- name: Cache cargo build
48+
uses: actions/cache@v4
49+
with:
50+
path: target
51+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
52+
53+
- name: Check formatting
54+
run: cargo fmt -- --check
55+
if: matrix.rust == 'stable'
56+
57+
- name: Run clippy
58+
run: cargo clippy --all-targets --all-features -- -D warnings
59+
if: matrix.rust == 'stable'
60+
61+
- name: Run tests
62+
run: cargo test --verbose
63+
64+
- name: Build release
65+
run: cargo build --release --verbose
66+
67+
- name: Test binary
68+
run: |
69+
./target/release/peak-mem -- echo "Hello, CI!"
70+
./target/release/peak-mem --json -- echo "JSON test"
71+
./target/release/peak-mem --csv -- echo "CSV test"
72+
./target/release/peak-mem --quiet -- echo "Quiet test"
73+
74+
# Separate job for checking MSRV (Minimum Supported Rust Version)
75+
msrv:
76+
name: Check MSRV
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Install Rust 1.70
82+
uses: dtolnay/rust-toolchain@master
83+
with:
84+
toolchain: "1.70"
85+
86+
- name: Check compilation
87+
run: cargo check --verbose
88+
89+
# Build artifacts for releases
90+
build-release:
91+
name: Build Release Artifacts
92+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
93+
runs-on: ${{ matrix.os }}
94+
strategy:
95+
matrix:
96+
include:
97+
- os: ubuntu-latest
98+
target: x86_64-unknown-linux-gnu
99+
artifact_name: peak-mem-linux-x86_64
100+
- os: macos-latest
101+
target: x86_64-apple-darwin
102+
artifact_name: peak-mem-macos-x86_64
103+
- os: macos-latest
104+
target: aarch64-apple-darwin
105+
artifact_name: peak-mem-macos-aarch64
106+
107+
steps:
108+
- uses: actions/checkout@v4
109+
110+
- name: Install Rust
111+
uses: dtolnay/rust-toolchain@stable
112+
with:
113+
targets: ${{ matrix.target }}
114+
115+
- name: Build release binary
116+
run: cargo build --release --target ${{ matrix.target }}
117+
118+
- name: Strip binary (Linux)
119+
if: matrix.os == 'ubuntu-latest'
120+
run: strip target/${{ matrix.target }}/release/peak-mem
121+
122+
- name: Upload artifact
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: ${{ matrix.artifact_name }}
126+
path: target/${{ matrix.target }}/release/peak-mem
127+
retention-days: 7

.github/workflows/release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create-release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
outputs:
16+
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Create Release
21+
id: create_release
22+
uses: actions/create-release@v1
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
with:
26+
tag_name: ${{ github.ref }}
27+
release_name: Release ${{ github.ref }}
28+
draft: false
29+
prerelease: false
30+
31+
build-and-upload:
32+
name: Build and Upload
33+
needs: create-release
34+
runs-on: ${{ matrix.os }}
35+
strategy:
36+
matrix:
37+
include:
38+
- os: ubuntu-latest
39+
target: x86_64-unknown-linux-gnu
40+
artifact_name: peak-mem
41+
asset_name: peak-mem-linux-x86_64
42+
- os: ubuntu-latest
43+
target: x86_64-unknown-linux-musl
44+
artifact_name: peak-mem
45+
asset_name: peak-mem-linux-x86_64-musl
46+
- os: macos-latest
47+
target: x86_64-apple-darwin
48+
artifact_name: peak-mem
49+
asset_name: peak-mem-macos-x86_64
50+
- os: macos-latest
51+
target: aarch64-apple-darwin
52+
artifact_name: peak-mem
53+
asset_name: peak-mem-macos-aarch64
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Install Rust
59+
uses: dtolnay/rust-toolchain@stable
60+
with:
61+
targets: ${{ matrix.target }}
62+
63+
- name: Install musl tools (Linux)
64+
if: matrix.target == 'x86_64-unknown-linux-musl'
65+
run: sudo apt-get update && sudo apt-get install -y musl-tools
66+
67+
- name: Build release binary
68+
run: cargo build --release --target ${{ matrix.target }}
69+
70+
- name: Strip binary (Linux)
71+
if: matrix.os == 'ubuntu-latest'
72+
run: |
73+
strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }} || true
74+
75+
- name: Create tarball
76+
run: |
77+
cd target/${{ matrix.target }}/release
78+
tar czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
79+
cd -
80+
mv target/${{ matrix.target }}/release/${{ matrix.asset_name }}.tar.gz .
81+
82+
- name: Upload Release Asset
83+
uses: actions/upload-release-asset@v1
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
with:
87+
upload_url: ${{ needs.create-release.outputs.upload_url }}
88+
asset_path: ./${{ matrix.asset_name }}.tar.gz
89+
asset_name: ${{ matrix.asset_name }}.tar.gz
90+
asset_content_type: application/gzip

.github/workflows/security.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Security Audit
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
schedule:
9+
# Run security audit weekly on Monday at 00:00 UTC
10+
- cron: '0 0 * * 1'
11+
12+
jobs:
13+
audit:
14+
name: Security Audit
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
22+
- name: Install cargo-audit
23+
run: cargo install cargo-audit
24+
25+
- name: Run security audit
26+
run: cargo audit
27+
28+
deny:
29+
name: Dependency License Check
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install Rust
35+
uses: dtolnay/rust-toolchain@stable
36+
37+
- name: Install cargo-deny
38+
run: cargo install cargo-deny
39+
40+
- name: Check dependencies
41+
run: cargo deny check

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# peak-mem
22

3+
[![CI](https://github.com/peak-mem/peak-mem/actions/workflows/ci.yml/badge.svg)](https://github.com/peak-mem/peak-mem/actions/workflows/ci.yml)
4+
[![Security Audit](https://github.com/peak-mem/peak-mem/actions/workflows/security.yml/badge.svg)](https://github.com/peak-mem/peak-mem/actions/workflows/security.yml)
5+
36
A lightweight, cross-platform memory usage monitor for any process. Track peak memory consumption with minimal overhead.
47

58
## Features

deny.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# cargo-deny configuration
2+
3+
[bans]
4+
# Lint level for when multiple versions of the same dependency are detected
5+
multiple-versions = "warn"
6+
# Lint level for when a dependency marked as 'unused' is still present
7+
unused = "warn"
8+
# List of explicitly disallowed crates
9+
deny = []
10+
11+
[licenses]
12+
# List of explicitly allowed licenses
13+
allow = [
14+
"MIT",
15+
"Apache-2.0",
16+
"Apache-2.0 WITH LLVM-exception",
17+
"BSD-2-Clause",
18+
"BSD-3-Clause",
19+
"ISC",
20+
"Unicode-DFS-2016",
21+
"CC0-1.0",
22+
]
23+
# List of explicitly disallowed licenses
24+
deny = []
25+
# Lint level for licenses considered copyleft
26+
copyleft = "warn"
27+
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
28+
allow-osi-fsf-free = "neither"
29+
# Lint level used when no other predicates are matched
30+
default = "deny"
31+
# The confidence threshold for detecting a license from license text.
32+
confidence-threshold = 0.8
33+
34+
[sources]
35+
# Lint level for what to happen when a crate from a crate registry that is not in the allow list is encountered
36+
unknown-registry = "warn"
37+
# Lint level for what to happen when a crate from a git repository that is not in the allow list is encountered
38+
unknown-git = "warn"
39+
# List of allowed crate registries
40+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]

0 commit comments

Comments
 (0)