Skip to content

Commit 0395b72

Browse files
author
alex
committed
Initial and first commit
Signed-off-by: alex <alex@alex-tuxedoinfinitybooks1517gen7>
0 parents  commit 0395b72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+18835
-0
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
rustflags = ["--cfg", "reqwest_unstable"]

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
fmt:
13+
name: Rustfmt
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: dtolnay/rust-toolchain@stable
18+
with:
19+
components: rustfmt
20+
- name: Check formatting
21+
run: cargo fmt --all --check
22+
23+
clippy:
24+
name: Clippy
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: dtolnay/rust-toolchain@stable
29+
with:
30+
components: clippy
31+
- uses: Swatinem/rust-cache@v2
32+
- name: Lint
33+
run: cargo clippy --package loadgen-rs --all-targets -- -D warnings
34+
35+
test:
36+
name: Test (${{ matrix.os }})
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
os: [ubuntu-latest, macos-latest, windows-latest]
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: dtolnay/rust-toolchain@stable
45+
- uses: Swatinem/rust-cache@v2
46+
- name: Run tests
47+
run: cargo test --package loadgen-rs

.github/workflows/release.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
BINARY_NAME: loadgen-rs
14+
15+
jobs:
16+
prepare:
17+
name: Prepare release
18+
runs-on: ubuntu-latest
19+
outputs:
20+
version: ${{ steps.version.outputs.version }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Extract version from Cargo.toml
24+
id: version
25+
run: |
26+
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
27+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
28+
TAG_VERSION="${GITHUB_REF_NAME#v}"
29+
if [ "$VERSION" != "$TAG_VERSION" ]; then
30+
echo "::error::Tag version (${TAG_VERSION}) does not match Cargo.toml version (${VERSION})"
31+
exit 1
32+
fi
33+
34+
build:
35+
name: Build ${{ matrix.target }}
36+
needs: prepare
37+
runs-on: ${{ matrix.runner }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- target: x86_64-unknown-linux-gnu
43+
runner: ubuntu-latest
44+
use_cross: false
45+
archive_ext: tar
46+
- target: x86_64-unknown-linux-musl
47+
runner: ubuntu-latest
48+
use_cross: false
49+
archive_ext: tar
50+
- target: aarch64-unknown-linux-musl
51+
runner: ubuntu-latest
52+
use_cross: true
53+
archive_ext: tar
54+
- target: x86_64-apple-darwin
55+
runner: macos-13
56+
use_cross: false
57+
archive_ext: tar
58+
- target: aarch64-apple-darwin
59+
runner: macos-latest
60+
use_cross: false
61+
archive_ext: tar
62+
- target: x86_64-pc-windows-msvc
63+
runner: windows-latest
64+
use_cross: false
65+
archive_ext: zip
66+
67+
env:
68+
VERSION: ${{ needs.prepare.outputs.version }}
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Install musl-tools
74+
if: contains(matrix.target, 'musl') && !matrix.use_cross
75+
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
76+
77+
- name: Install Rust toolchain
78+
uses: dtolnay/rust-toolchain@stable
79+
with:
80+
targets: ${{ matrix.target }}
81+
82+
- name: Install cross
83+
if: matrix.use_cross
84+
uses: taiki-e/install-action@v2
85+
with:
86+
tool: cross
87+
88+
- uses: Swatinem/rust-cache@v2
89+
with:
90+
key: release-${{ matrix.target }}
91+
92+
- name: Build release binary
93+
shell: bash
94+
run: |
95+
if [ "${{ matrix.use_cross }}" = "true" ]; then
96+
cross build --release --locked --package loadgen-rs --target ${{ matrix.target }}
97+
else
98+
cargo build --release --locked --package loadgen-rs --target ${{ matrix.target }}
99+
fi
100+
101+
- name: Determine binary path
102+
id: bin
103+
shell: bash
104+
run: |
105+
if [ "${{ matrix.archive_ext }}" = "zip" ]; then
106+
echo "path=target/${{ matrix.target }}/release/${BINARY_NAME}.exe" >> "$GITHUB_OUTPUT"
107+
else
108+
echo "path=target/${{ matrix.target }}/release/${BINARY_NAME}" >> "$GITHUB_OUTPUT"
109+
fi
110+
111+
- name: Create tar.gz and tar.xz archives
112+
if: matrix.archive_ext == 'tar'
113+
shell: bash
114+
run: |
115+
STAGING="${BINARY_NAME}-v${VERSION}-${{ matrix.target }}"
116+
mkdir -p "${STAGING}"
117+
cp "${{ steps.bin.outputs.path }}" "${STAGING}/"
118+
cp README.md "${STAGING}/" 2>/dev/null || true
119+
tar czf "${STAGING}.tar.gz" "${STAGING}"
120+
tar cJf "${STAGING}.tar.xz" "${STAGING}"
121+
122+
- name: Create zip archive
123+
if: matrix.archive_ext == 'zip'
124+
shell: pwsh
125+
run: |
126+
$STAGING = "${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}"
127+
New-Item -ItemType Directory -Path $STAGING
128+
Copy-Item "${{ steps.bin.outputs.path }}" $STAGING
129+
Copy-Item README.md $STAGING -ErrorAction SilentlyContinue
130+
Compress-Archive -Path $STAGING -DestinationPath "${STAGING}.zip"
131+
132+
- name: Upload artifacts
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: ${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}
136+
path: |
137+
${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}.tar.gz
138+
${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}.tar.xz
139+
${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}.zip
140+
if-no-files-found: ignore
141+
142+
- name: Upload tar.gz to release
143+
if: matrix.archive_ext == 'tar'
144+
uses: svenstaro/upload-release-action@v2
145+
with:
146+
repo_token: ${{ secrets.GITHUB_TOKEN }}
147+
file: ${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}.tar.gz
148+
tag: ${{ github.ref }}
149+
150+
- name: Upload tar.xz to release
151+
if: matrix.archive_ext == 'tar'
152+
uses: svenstaro/upload-release-action@v2
153+
with:
154+
repo_token: ${{ secrets.GITHUB_TOKEN }}
155+
file: ${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}.tar.xz
156+
tag: ${{ github.ref }}
157+
158+
- name: Upload zip to release
159+
if: matrix.archive_ext == 'zip'
160+
uses: svenstaro/upload-release-action@v2
161+
with:
162+
repo_token: ${{ secrets.GITHUB_TOKEN }}
163+
file: ${{ env.BINARY_NAME }}-v${{ env.VERSION }}-${{ matrix.target }}.zip
164+
tag: ${{ github.ref }}

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Rust
2+
target/
3+
**/*.rs.bk
4+
5+
# VSCode
6+
.vscode/
7+
8+
# Claude
9+
.claude/
10+
11+
# OS
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Environment / secrets
16+
.env
17+
*.pem
18+
19+
CLAUDE*
20+
blog-post.md
21+
22+
*/:

0 commit comments

Comments
 (0)