diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f1d88e9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: + - axum + pull_request: + branches: + - axum + paths: + - '.github/**' + - 'src/**' + - 'templates/**' + - 'tests/**' + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + RUSTFLAGS: "-Dwarnings" + RUSTDOCFLAGS: "-Dwarnings" + +jobs: + build_and_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + with: + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + + - name: Restore qbittorrent-nox + id: qbittorrent-nox + uses: actions/cache/restore@v4 + with: + path: qbittorrent-nox + key: ${{ runner.os }}-qbittorrent-nox-github + - if: ${{ steps.qbittorrent-nox.outputs.cache-hit != 'true' }} + name: Download qbittorrent-nox + run: wget -O qbittorrent-nox https://github.com/userdocs/qbittorrent-nox-static/releases/download/release-5.0.4_v2.0.11/x86_64-qbittorrent-nox + - run: chmod +x qbittorrent-nox + - run: sudo ln -s $(pwd)/qbittorrent-nox /usr/local/bin/qbittorrent-nox + - if: ${{ steps.qbittorrent-nox.outputs.cache-hit != 'true' }} + name: Save qbittorrent-nox + uses: actions/cache/save@v4 + with: + path: qbittorrent-nox + key: ${{ steps.qbittorrent-nox.outputs.cache-primary-key }} + - run: mkdir -p /tmp/qbittorrent-nox + # - run: ./scripts/qbittorrent.sh start /tmp/qbittorrent-nox 8080 + - run: ./scripts/pre-commit.sh + # - run: ./scripts/qbittorrent.sh stop /tmp/qbittorrent-nox + diff --git a/justfile b/justfile new file mode 100644 index 0000000..e091d5f --- /dev/null +++ b/justfile @@ -0,0 +1,10 @@ +set export + +RUSTFLAGS := "-Dwarnings" +RUSTDOCFLAGS := "--cfg docs -Dwarnings" + +pre-commit *FLAGS: + ./scripts/pre-commit.sh {{FLAGS}} + +doc *FLAGS: + cargo +nightly doc -Zrustdoc-map --all-features {{FLAGS}} diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh new file mode 100755 index 0000000..3b0af54 --- /dev/null +++ b/scripts/pre-commit.sh @@ -0,0 +1,19 @@ +#! /usr/bin/env bash + +export RUSTFLAGS="-Dwarnings" +export RUSTDOCFLAGS="--cfg docsrs -Dwarnings" + +set -e +set -x + +cargo +nightly --version +cargo +nightly fmt --check +cargo +nightly clippy --all-features +cargo +nightly test +cargo +nightly test --all-features +cargo +nightly doc --no-deps -Zrustdoc-map --all-features +# if command -v cargo-rdme 2>&1 >/dev/null; then +# cargo-rdme --check +# else +# echo "Skip cargo-rdme (not installed)" +# fi