diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 6d151b7..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Check - -on: [ pull_request ] - -env: - CARGO_TERM_COLOR: always - -jobs: - check: - 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/toolchain@v1.0.7 - with: - toolchain: stable - components: rustfmt, clippy - - - uses: actions-rs/cargo@v1.0.3 - with: - command: fmt - args: -- --check - - - uses: actions-rs/clippy-check@v1.0.7 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml new file mode 100644 index 0000000..07939d0 --- /dev/null +++ b/.github/workflows/lints.yml @@ -0,0 +1,54 @@ +name: Lints + +on: [ pull_request, merge_group ] + +jobs: + check: + name: Cargo Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + with: + toolchain: 1.76.0 + - uses: olix0r/cargo-action-fmt/setup@v2.0.1 + - run: cargo check -q --message-format=json | cargo-action-fmt + + rustfmt: + name: rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + 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/rustfmt@v1.1.0 + + clippy: + name: Clippy + runs-on: ubuntu-latest + permissions: + checks: write + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + with: + toolchain: 1.76.0 + components: clippy + - uses: auguwu/clippy-action@1.3.0 + with: + token: ${{secrets.GITHUB_TOKEN}} + + doc: + name: Doc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + with: + toolchain: 1.76.0 + - uses: olix0r/cargo-action-fmt/setup@v2.0.1 + - run: cargo doc --no-deps --message-format=json | cargo-action-fmt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 327f2d8..843d135 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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/toolchain@v1.0.7 - with: - toolchain: stable - - - name: Prepare Crate - uses: actions-rs/cargo@v1.0.3 + - uses: actions/checkout@v4.1.1 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: - command: package - - - name: Login to crates.io - uses: actions-rs/cargo@v1.0.3 - with: - command: login - args: ${{ secrets.CARGO_TOKEN }} - - - name: Publish Crate - uses: actions-rs/cargo@v1.0.3 - 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/checkout@v4.1.1 - name: Set environment run: echo "docker_image_tag=${GITHUB_REF##*/v}" >> $GITHUB_ENV - - uses: docker/login-action@v2.2.0 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - uses: docker/build-push-action@v4.1.1 with: push: true @@ -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/toolchain@v1.0.7 + - uses: actions/checkout@v4.1.1 + - 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/cargo@v1.0.3 - 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 @@ -116,4 +73,3 @@ jobs: file: mc-server-pinger-* file_glob: true tag: ${{ github.ref }} - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a09bc79..a586a83 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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/toolchain@v1.0.7 - with: - toolchain: stable - - - uses: actions-rs/cargo@v1.0.3 + - uses: actions/checkout@v4.1.1 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: - command: test - args: --verbose + toolchain: 1.76.0 + - run: cargo test --all-features diff --git a/.mergify.yml b/.mergify.yml index 75a1e20..231bd2b 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,7 +1,7 @@ queue_rules: - name: dependabot-updates conditions: - - check-success=test + - check-success=lints - check-success=check pull_request_rules: diff --git a/Cargo.toml b/Cargo.toml index bb929f9..03c9119 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "mc-server-pinger" version = "0.1.0-alpha.6" authors = ["Petr Portnov "] 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" @@ -24,8 +25,9 @@ peg = "0.8.2" # 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