Skip to content

Commit

Permalink
ci: rework CI configuration (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvisCraft authored Feb 18, 2024
1 parent 5c652ab commit dd8430c
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 116 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/check.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Lints

on: [ pull_request, merge_group ]

jobs:
check:
name: Cargo Check
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions-rust-lang/[email protected]
with:
toolchain: 1.76.0
- uses: olix0r/cargo-action-fmt/[email protected]
- run: cargo check -q --message-format=json | cargo-action-fmt

rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions-rust-lang/[email protected]
with:
# we have to use nightly since come important options are not stable yet
toolchain: nightly
components: rustfmt
- name: Rustfmt Check
uses: actions-rust-lang/[email protected]

clippy:
name: Clippy
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/[email protected]
- uses: actions-rust-lang/[email protected]
with:
toolchain: 1.76.0
components: clippy
- uses: auguwu/[email protected]
with:
token: ${{secrets.GITHUB_TOKEN}}

doc:
name: Doc
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions-rust-lang/[email protected]
with:
toolchain: 1.76.0
- uses: olix0r/cargo-action-fmt/[email protected]
- run: cargo doc --no-deps --message-format=json | cargo-action-fmt
66 changes: 11 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,24 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- uses: actions-rs/[email protected]
with:
toolchain: stable

- name: Prepare Crate
uses: actions-rs/[email protected]
- uses: actions/[email protected]
- uses: actions-rust-lang/[email protected]
with:
command: package

- name: Login to crates.io
uses: actions-rs/[email protected]
with:
command: login
args: ${{ secrets.CARGO_TOKEN }}

- name: Publish Crate
uses: actions-rs/[email protected]
with:
command: publish
toolchain: 1.76.0
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_PUBLISH_TOKEN }}

dockerize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/[email protected]
- name: Set environment
run: echo "docker_image_tag=${GITHUB_REF##*/v}" >> $GITHUB_ENV

- uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- uses: docker/[email protected]
with:
push: true
Expand All @@ -78,34 +53,16 @@ jobs:
artifact-name: mc-server-pinger-darwin-x86_64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- uses: actions-rs/[email protected]
- uses: actions/[email protected]
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
toolchain: 1.76.0
target: ${{ matrix.target }}
override: true

- name: Build
uses: actions-rs/[email protected]
with:
command: build
args: --release --target ${{ matrix.target }}
- run: cargo build --release --target ${{ matrix.target }}

- name: Move binary
run: mv target/${{ matrix.target }}/release/${{ matrix.binary-name }} ${{ matrix.artifact-name }}

- name: Strip binary
run: strip ${{ matrix.artifact-name }}

- name: Generate checksum
run: shasum -a 256 ${{ matrix.artifact-name }} > ${{ matrix.artifact-name }}.sha256

Expand All @@ -116,4 +73,3 @@ jobs:
file: mc-server-pinger-*
file_glob: true
tag: ${{ github.ref }}

27 changes: 6 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
name: Test

on: [ workflow_dispatch, push, pull_request ]

env:
CARGO_TERM_COLOR: always
on: [ push, merge_group ]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- uses: actions-rs/[email protected]
with:
toolchain: stable

- uses: actions-rs/[email protected]
- uses: actions/[email protected]
- uses: actions-rust-lang/[email protected]
with:
command: test
args: --verbose
toolchain: 1.76.0
- run: cargo test --all-features
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
queue_rules:
- name: dependabot-updates
conditions:
- check-success=test
- check-success=lints
- check-success=check

pull_request_rules:
Expand Down
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "mc-server-pinger"
version = "0.1.0-alpha.6"
authors = ["Petr Portnov <[email protected]>"]
edition = "2018"
rust-version = "1.76.0"
# Basic properties
description = "Command line utility for pinging Minecraft servers via Server List Ping protocol"
license = "Apache-2.0"
Expand All @@ -15,17 +16,18 @@ categories = ["command-line-utilities", "network-programming"]
name = "mc-server-pinger"

[dependencies]
craftping = { version = "0.4.1", features = ["async-tokio"] }
tokio = { version = "1.28.2", features = ["rt", "net", "time", "macros"] }
clap = { version = "4.1.11", features = ["derive"] }
craftping = { version = "0.4", features = ["async-tokio"] }
tokio = { version = "1.28", features = ["rt", "net", "time", "macros"] }
clap = { version = "4.1", features = ["derive"] }
peg = "0.8.1"

[profile.release]
# This allows a better optimized binary at cost of more complicated compilation
# which is fine and worth it
lto = true
# This minimizes build parallelization bu allows better optimizations
# This minimizes build parallelization but allows better optimizations
codegen-units = 1
# This is a single-purpose binary which has no space for panic
# thus even if it (somehow) makes it way to production is not as critical
panic = "abort"
strip = true

0 comments on commit dd8430c

Please sign in to comment.