From 5872eb32c3fc1bb8b71b72546c37cde287cab130 Mon Sep 17 00:00:00 2001 From: nbari Date: Thu, 1 Feb 2024 16:07:59 +0100 Subject: [PATCH] cleanup pipeline --- .github/actions-rs/grcov.yml | 3 ++ .github/workflows/.codespellrc | 2 + .github/workflows/build.yml | 91 ++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 67 ------------------------- .github/workflows/deploy.yml | 90 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 85 +++++++++++++++++++++++++++++++ Cargo.toml | 9 ++-- 7 files changed, 274 insertions(+), 73 deletions(-) create mode 100644 .github/actions-rs/grcov.yml create mode 100644 .github/workflows/.codespellrc create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/actions-rs/grcov.yml b/.github/actions-rs/grcov.yml new file mode 100644 index 0000000..7b4157b --- /dev/null +++ b/.github/actions-rs/grcov.yml @@ -0,0 +1,3 @@ +--- +output-type: lcov +output-file: ./lcov.info diff --git a/.github/workflows/.codespellrc b/.github/workflows/.codespellrc new file mode 100644 index 0000000..8511d3f --- /dev/null +++ b/.github/workflows/.codespellrc @@ -0,0 +1,2 @@ +[codespell] +ignore-words-list = crate diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4080272 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,91 @@ +--- +name: Test & Build + +on: + push: + branches: + - '*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + test: + uses: ./.github/workflows/test.yml + + build: + name: Build + runs-on: ${{ matrix.os }} + needs: test + + strategy: + matrix: + include: + - build: linux + os: ubuntu-latest + target: x86_64-unknown-linux-musl + + - build: macos + os: macos-latest + target: x86_64-apple-darwin + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Branch name + run: echo "${GITHUB_REF##*/}" + + - name: Get the release version from the tag + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - run: sudo apt -y install musl-dev musl-tools + if: matrix.build == 'linux' + + - name: Build Linux + run: | + cargo build --release --locked --target ${{ matrix.target }} --features "openssl/vendored" + if: matrix.build == 'linux' + + - name: Build + run: | + cargo build --release --locked --target ${{ matrix.target }} + if: matrix.build != 'linux' + + packages: + name: package + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN }} + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/permesi/genesis + + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Build & Push the Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index a3915d7..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: ci - -on: [push] - -env: - CARGO_TERM_COLOR: always - -jobs: - check: - name: Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: check - - test: - name: Test Suite - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D clippy::all -D clippy::nursery -D warnings diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..1dc34ef --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,90 @@ +--- +name: Build + +on: + push: + tags: + - '*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + test: + uses: ./.github/workflows/test.yml + + build: + name: Build and release + runs-on: ${{ matrix.os }} + needs: test + + strategy: + matrix: + include: + - build: linux + os: ubuntu-latest + target: x86_64-unknown-linux-musl + + - build: macos + os: macos-latest + target: x86_64-apple-darwin + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get the release version from the tag + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - run: sudo apt -y install musl-dev musl-tools + if: matrix.build == 'linux' + + - name: Build Linux + run: | + cargo build --release --locked --target ${{ matrix.target }} --features "openssl/vendored" + if: matrix.build == 'linux' + + - name: Build + run: | + cargo build --release --locked --target ${{ matrix.target }} + if: matrix.build != 'linux' + + - name: Build archive + shell: bash + run: | + binary_name="genesis" + + dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" + mkdir "$dirname" + mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" + tar -czf "$dirname.tar.gz" "$dirname" + echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV + + - name: Release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v1 + with: + files: |- + ${{ env.ASSET }} + + publish: + name: Publish + runs-on: ubuntu-latest + needs: + - build + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - run: cargo publish --token ${CRATES_TOKEN} + env: + CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fbd5d59 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,85 @@ +--- +name: Test + +on: + workflow_call: + pull_request: + branches: + - '*' + +jobs: + format: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: Format + run: cargo fmt --all -- --check + + lint: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: Clippy + run: cargo clippy -- -D clippy::all -D clippy::nursery -D warnings + + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: Check + run: cargo check + + test: + name: Test + strategy: + matrix: + os: + - ubuntu-latest + - macOS-latest + rust: + - stable + runs-on: ${{ matrix.os }} + needs: + - format + - lint + - check + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: test + run: cargo test + + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + + - name: Run tests + run: cargo test --verbose + env: + CARGO_INCREMENTAL: '0' + RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code + -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests + RUSTDOCFLAGS: -Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code + -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests + + - name: rust-grcov + uses: actions-rs/grcov@v0.1 + + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2 diff --git a/Cargo.toml b/Cargo.toml index e91ecbb..70f391b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fork" -version = "0.1.22" +version = "0.1.23" authors = ["Nicolas Embriz "] description = "Library for creating a new process detached from the controlling terminal (daemon)" documentation = "https://docs.rs/fork/latest/fork/" @@ -9,11 +9,8 @@ repository = "https://github.com/immortal/fork" readme = "README.md" keywords = ["fork", "setsid", "daemon", "process", "daemonize"] categories = ["command-line-utilities", "os"] -license = "BSD-3-Clause" -edition = "2018" - -[badges] -travis-ci = { repository = "immortal/fork", branch = "master" } +license-file = "LICENSE" +edition = "2021" [dependencies] libc = "0.2"