Skip to content

Commit

Permalink
cached rust builds, remove openssl dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Firaenix committed Nov 18, 2024
1 parent c4ff5df commit f567315
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 7 deletions.
49 changes: 46 additions & 3 deletions .github/workflows/rust-build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: Build

on:
pull_request:
push:
branches:
- "*"

env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: true
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: /home/runner/.cache/sccache

jobs:
build:
name: Build for ${{ matrix.target }}
Expand Down Expand Up @@ -47,17 +53,54 @@ jobs:
artifact_name: bping

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Install build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y curl build-essential pkg-config libssl-dev
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true

- name: Configure sccache
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust"
shared-key: "${{ matrix.target }}-build"
cache-targets: "true"
cache-on-failure: "true"
cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/master' }}
workspaces: |
. -> target
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}

- name: Show sccache stats
run: sccache --show-stats

# Optional: Upload artifacts if needed
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}-binary
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
47 changes: 45 additions & 2 deletions .github/workflows/rust-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
tags:
- "*"

env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: true
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: /home/runner/.cache/sccache

jobs:
publish:
name: Publish for ${{ matrix.target }}
Expand Down Expand Up @@ -47,21 +53,51 @@ jobs:
asset_name: bping-x86_64-linux-musl

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Install build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y curl build-essential pkg-config libssl-dev
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true

- name: Configure sccache
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust"
shared-key: "${{ matrix.target }}-release"
cache-targets: "true"
cache-on-failure: "true"
cache-all-crates: "true"
save-if: true # Always save cache for tagged releases
workspaces: |
. -> target
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}

- name: Show sccache stats
run: sccache --show-stats

- name: Strip binary
if: runner.os != 'Windows'
run: strip target/${{ matrix.target }}/release/bping
Expand All @@ -73,3 +109,10 @@ jobs:
file: target/${{ matrix.target }}/release/bping${{ runner.os == 'Windows' && '.exe' || '' }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}

# Optional: Upload artifacts for debugging or additional processing
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}-release-binary
path: target/${{ matrix.target }}/release/bping${{ runner.os == 'Windows' && '.exe' || '' }}
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ opt-level = "z"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
reqwest = { version = "0.12.5", features = ["json"] }
reqwest = { version = "0.12", features = [
"json",
"rustls-tls",
], default-features = false }
spinners = "4.1.1"
tokio = { version = "1.38.0", features = ["full"] }
dirs = "5.0.1"
Expand All @@ -24,7 +27,7 @@ colorful = "0.3.2"
indicatif = "0.17.8"
chrono = { version = "0.4", features = ["serde"] }
celes = "2.4.0"
thiserror = "1.0.61"
thiserror = "2.0"
async-stream = "0.3.5"
console = "0.15.8"
keshvar = { version = "0.5.0", features = ["serde", "emojis"] }
Expand Down

0 comments on commit f567315

Please sign in to comment.