Skip to content

Rewrite the pinger library #833

Rewrite the pinger library

Rewrite the pinger library #833

Workflow file for this run

on:
push:
tags:
- gping-v*
branches:
- master
pull_request:
name: CI
jobs:
build_and_test:
name: Rust project
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
bin: gping
name: gping-Linux-x86_64.tar.gz
container: quay.io/pypa/manylinux_2_28_x86_64
- os: macOS-latest
bin: gping
name: gping-Darwin-x86_64.tar.gz
container: null
- os: windows-latest
bin: gping.exe
name: gping-Windows-x86_64.zip
container: null
env:
RUST_BACKTRACE: "1"
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: standard-build-${{ matrix.os }}-
- name: Run tests
run: cargo test
- name: Run
run: cargo run -- --help
- name: Build release
if: startsWith(github.ref, 'refs/tags/')
run: cargo build --release
- name: Package
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
strip target/release/${{ matrix.bin }}
cd target/release
if [[ "${{ matrix.os }}" == "windows-latest" ]]
then
7z a ../../${{ matrix.name }} ${{ matrix.bin }}
else
tar czvf ../../${{ matrix.name }} ${{ matrix.bin }}
fi
cd -
- name: Archive binaries
uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/')
with:
name: build-${{ matrix.name }}
path: ${{ matrix.name }}
cross_builds:
name: ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
target:
- armv7-linux-androideabi
- armv7-unknown-linux-gnueabihf
- armv7-unknown-linux-musleabihf
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
prefix-key: cross-build-${{ matrix.target }}-
- name: Check
uses: houseabsolute/actions-rust-cross@v0
with:
command: check
target: ${{ matrix.target }}
- name: Test
uses: houseabsolute/actions-rust-cross@v0
with:
command: test
target: ${{ matrix.target }}
- uses: houseabsolute/actions-rust-cross@v0
if: startsWith(github.ref, 'refs/tags/')
with:
command: build
target: ${{ matrix.target }}
args: --release
- name: Package
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
cd target/${{ matrix.target }}/release/
tar czvf ../../../gping-${{ matrix.target }}.tar.gz gping
cd -
- name: Archive production artifacts
uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/')
with:
name: build-${{ matrix.target }}
path: |
gping*.tar.gz
gping*.zip
create_release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- cross_builds
- build_and_test
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Publish
uses: softprops/action-gh-release@v2
with:
draft: false
files: |
gping.1
**/*.tar.gz
**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
prefix-key: checks-build-
- name: Run cargo fmt
if: success() || failure()
run: cargo fmt --all -- --check
- name: Run cargo check
if: success() || failure()
run: cargo check
- if: success() || failure()
run: cargo clippy --all-targets --all-features -- -D warnings