Skip to content

Commit

Permalink
Rewrite the pinger library
Browse files Browse the repository at this point in the history
  • Loading branch information
orf committed Dec 16, 2024
1 parent 703db5f commit 44650de
Show file tree
Hide file tree
Showing 26 changed files with 829 additions and 568 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
if: github.event_name == 'tag' || github.ref_name == 'master'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -57,7 +58,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
push: true
push: ${{ github.event_name == 'tag' || github.ref_name == 'master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
formula-name: gping
commit-message: |
gping ${{ steps.extract-version.outputs.VERSION }}
Created by https://github.com/mislav/bump-homebrew-formula-action
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
205 changes: 88 additions & 117 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,101 +9,91 @@ on:
name: CI

jobs:
build_and_test:
name: Rust project
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
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 }}

test_alpine:
name: Test in Alpine
runs-on: ubuntu-latest
container:
image: alpine:latest
steps:
- uses: actions/checkout@v4
- run: apk add --no-cache libgcc gcc musl-dev bash curl

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: alpine-build-
- name: Run tests
run: cargo test
# build_and_test:
# name: Rust project
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - os: macOS-latest
# bin: gping
# target: aarch64-apple-darwin
# extension: .tar.gz
# - os: windows-latest
# bin: gping.exe
# name: gping-Windows-x86_64.zip
# 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: Cross-build
runs-on: ubuntu-latest
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
os: [ 'ubuntu-24.04' ]
target:
- armv7-linux-androideabi
- armv7-unknown-linux-gnueabihf
- armv7-unknown-linux-musleabihf
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- 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 }}-
Expand All @@ -119,54 +109,35 @@ jobs:
with:
command: test
target: ${{ matrix.target }}
args: --locked

- uses: houseabsolute/actions-rust-cross@v0
if: startsWith(github.ref, 'refs/tags/')
- name: Build example
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/')
args: --release --locked --examples --bins

- name: Build release
uses: houseabsolute/actions-rust-cross@v0
#if: startsWith(github.ref, 'refs/tags/')
with:
name: build-${{ matrix.target }}
path: |
gping*.tar.gz
gping*.zip
command: build
target: ${{ matrix.target }}
args: --release --locked

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
- name: Publish artifacts and release
#if: startsWith(github.ref, 'refs/tags/')
uses: houseabsolute/actions-rust-release@v0
with:
draft: false
files: |
gping.1
**/*.tar.gz
**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
executable-name: gping
target: ${{ matrix.target }}
extra-files: gping.1

checks:
name: Checks
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
.idea/
.idea/
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: 'ping.1'
- repo: local
hooks:
- id: rustfmt
name: rustfmt
entry: cargo fmt -- --check
pass_filenames: false
language: system
- id: clippy
name: clippy
entry: cargo clippy --all-targets --all-features -- -D warnings
pass_filenames: false
language: system
- id: mangen
name: mangen
entry: env GENERATE_MANPAGE="gping.1" cargo run
pass_filenames: false
language: system
Loading

0 comments on commit 44650de

Please sign in to comment.