From a963a492c699ae22073b035f4fbf6efa2573bb62 Mon Sep 17 00:00:00 2001 From: DDo <34526678+Ott-cop@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:53:58 -0300 Subject: [PATCH] Update rust.yml --- .github/workflows/rust.yml | 275 +++++++++++++++++++++---------------- Cargo.lock | 39 ++---- Cargo.toml | 4 +- 3 files changed, 173 insertions(+), 145 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9648236..89d93ad 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,143 +1,184 @@ name: Rust on: - push: + workflow_dispatch: pull_request: + push: + tags: + - 'v*' + branches: + - main + + +permissions: + contents: write env: - CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + CARGO_INCREMENTAL: 0 + CARGO_PROFILE_DEV_DEBUG: 0 + CARGO_HUSKY_DONT_INSTALL_HOOKS: true + COMPLETION_DIR: "target/tmp/bottom/completion/" + MANPAGE_DIR: "target/tmp/bottom/manpage/" -defaults: - run: - # necessary for windows - shell: bash +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'ClementTsang/bottom' }} jobs: - test: + release: runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} steps: - - uses: actions/checkout@v2 - - name: Cargo cache - uses: actions/cache@v2 + - name: Check if this action should be skipped + id: skip_check + uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 with: - path: | - ~/.cargo/registry - ./target - key: test-cargo-registry - - name: List - run: find ./ - - name: Run tests - run: cargo test --verbose - - build: + skip_after_successful_duplicate: "true" + paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml", "Cross.toml"]' + do_not_skip: '["workflow_dispatch", "push"]' + + + build-release: + needs: release + runs-on: ${{ matrix.info.os }} + if: ${{ needs.release.outputs.should_skip != 'true' }} + timeout-minutes: 20 strategy: fail-fast: false matrix: - # a list of all the targets - include: - - TARGET: x86_64-unknown-linux-gnu # tested in a debian container on a mac - OS: ubuntu-latest - - TARGET: x86_64-unknown-linux-musl # test in an alpine container on a mac - OS: ubuntu-latest - - TARGET: aarch64-unknown-linux-gnu # tested on aws t4g.nano - OS: ubuntu-latest - - TARGET: aarch64-unknown-linux-musl # tested on aws t4g.nano in alpine container - OS: ubuntu-latest - - TARGET: armv7-unknown-linux-gnueabihf # raspberry pi 2-3-4, not tested - OS: ubuntu-latest - - TARGET: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4, not tested - OS: ubuntu-latest - - TARGET: arm-unknown-linux-gnueabihf # raspberry pi 0-1, not tested - OS: ubuntu-latest - - TARGET: arm-unknown-linux-musleabihf # raspberry pi 0-1, not tested - OS: ubuntu-latest - - TARGET: x86_64-apple-darwin # tested on a mac, is not properly signed so there are security warnings - OS: macos-latest - - TARGET: x86_64-pc-windows-msvc # tested on a windows machine - OS: windows-latest - needs: test - runs-on: ${{ matrix.OS }} - env: - NAME: rust-cross-compile-example # change with the name of your project - TARGET: ${{ matrix.TARGET }} - OS: ${{ matrix.OS }} + info: + - { + os: "ubuntu-latest", + target: "i686-unknown-linux-gnu", + cross: true, + rust: stable, + } + + - { + os: "ubuntu-latest", + target: "x86_64-unknown-linux-gnu", + cross: true, + rust: stable, + } + + - { + os: "windows-2019", + target: "i686-pc-windows-msvc", + cross: false, + rust: stable, + } + - { + os: "windows-2019", + target: "x86_64-pc-windows-gnu", + cross: false, + rust: stable, + } + + # Beta + - { + os: "ubuntu-latest", + target: "x86_64-unknown-linux-gnu", + cross: false, + rust: beta, + } + - { + os: "macos-12", + target: "x86_64-apple-darwin", + cross: false, + rust: beta, + } + - { + os: "windows-2019", + target: "x86_64-pc-windows-msvc", + cross: false, + rust: beta, + } + steps: - - uses: actions/checkout@v2 - - name: Cargo cache - uses: actions/cache@v2 + - name: Install Dependencies + if: ${{ matrix.info.os == 'ubuntu-latest' }} + run: sudo apt update && sudo apt install pkg-config libssl-dev -y + + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set up Rust toolchain + uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 with: - path: | - ~/.cargo/registry - ./target - key: build-cargo-registry-${{matrix.TARGET}} - - name: List - run: find ./ - - name: Install and configure dependencies - run: | - # dependencies are only needed on ubuntu as that's the only place where - # we make cross-compilation - if [[ $OS =~ ^ubuntu.*$ ]]; then - sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf - fi + toolchain: ${{ matrix.info.rust }} + target: ${{ matrix.info.target }} + + - name: Enable Rust cache + uses: Swatinem/rust-cache@378c8285a4eaf12899d11bea686a763e906956af # 2.7.3 + if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork + with: + key: ${{ matrix.info.target }} + cache-all-crates: true + + - name: Try building with only default features enabled + uses: ClementTsang/cargo-action@v0.0.5 + if: ${{ matrix.info.no-default-features != true }} + with: + command: build + args: --all-targets --verbose --target=${{ matrix.info.target }} --locked + use-cross: ${{ matrix.info.cross }} + cross-version: ${{ matrix.info.cross-version || '0.2.5' }} + + - name: Try building with no features enabled + uses: ClementTsang/cargo-action@v0.0.5 + if: ${{ matrix.info.no-default-features == true }} + with: + command: build + args: --all-targets --verbose --target=${{ matrix.info.target }} --locked --no-default-features + use-cross: ${{ matrix.info.cross }} + cross-version: ${{ matrix.info.cross-version || '0.2.5' }} + + - name: Get the release version from the tag + shell: bash + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - # some additional configuration for cross-compilation on linux - cat >>~/.cargo/config <> $GITHUB_ENV else - TAG=$GITHUB_SHA + tar -czf "$dirname.tar.gz" "$dirname" + echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV fi - mv ./target/$TARGET/release/$EXEC ./$EXEC - tar -czf ./artifacts/$NAME-$TARGET-$TAG.tar.gz $EXEC - - name: Archive artifact - uses: actions/upload-artifact@v2 - with: - name: result - path: | - ./artifacts - - # deploys to github releases on tag - deploy: - if: startsWith(github.ref, 'refs/tags/') - needs: build - runs-on: ubuntu-latest - steps: - - name: Download artifacts - uses: actions/download-artifact@v2 - with: - name: result - path: ./artifacts - - name: List - run: find ./artifacts - name: Release uses: softprops/action-gh-release@v1 with: - files: ./artifacts/*.tar.gz + files: | + ${{ env.ASSET }} + + completion: + name: "Check" + needs: [build-release] + if: ${{ success() || failure() }} + runs-on: "ubuntu-latest" + steps: + - name: Relesead Success + if: ${{ (needs.build-release.result == 'success') || (needs.build-release.result == 'skipped') }} + run: | + echo "Release completed successfully."; + + - name: Release Failed + if: ${{ needs.build-release.result == 'failure' }} + run: | + echo "Release failed!"; + exit 1; \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 531fab3..4c645aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -846,7 +846,7 @@ dependencies = [ "indexmap", "slab", "tokio 0.2.25", - "tokio-util 0.3.1", + "tokio-util", "tracing", "tracing-futures", ] @@ -1023,8 +1023,8 @@ dependencies = [ "calamine", "futures", "image_search", + "openssl", "tokio 1.36.0", - "tokio-stream", ] [[package]] @@ -1329,6 +1329,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.2.1+3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fe476c29791a5ca0d1273c697e96085bbabbbea2ef7afd5617e78a4b40332d3" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.99" @@ -1337,6 +1346,7 @@ checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -2069,18 +2079,6 @@ dependencies = [ "syn 2.0.49", ] -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite 0.2.13", - "tokio 1.36.0", - "tokio-util 0.7.10", -] - [[package]] name = "tokio-tls" version = "0.3.1" @@ -2105,19 +2103,6 @@ dependencies = [ "tokio 0.2.25", ] -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes 1.5.0", - "futures-core", - "futures-sink", - "pin-project-lite 0.2.13", - "tokio 1.36.0", -] - [[package]] name = "tower-service" version = "0.3.2" diff --git a/Cargo.toml b/Cargo.toml index 4d48fd1..3ff60b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,4 +20,6 @@ calamine = "0.24.0" futures = "0.3.30" image_search = "0.4.3" tokio = { version = "1.36.0", features = ["full"] } -tokio-stream = { version = "0.1.14", features = ["full"] } + +[target.'cfg(not(windows))'.dependencies] +openssl = { version = "0.10", features = [ "vendored" ] } \ No newline at end of file