-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cached rust builds, remove openssl dependency
- Loading branch information
Showing
3 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} | ||
|
@@ -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 | ||
|
@@ -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' || '' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters