diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11c362c..6023789 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,18 +1,22 @@ -name: Release plugin +permissions: + contents: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: - push: - tags: - - 'v*' - branches: - - 'master' pull_request: paths: - '.github/workflows/release.yml' + push: + branches: + - 'master' + - 'v1.16' + - 'v1.17' + tags: + - 'v*' + workflow_dispatch: env: CARGO_TERM_COLOR: always @@ -23,13 +27,14 @@ jobs: matrix: os: [ubuntu-20.04, ubuntu-22.04] runs-on: ["${{ matrix.os }}"] + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set rust version run: | - source ci/rust-version.sh - echo "RUST_STABLE=$rust_stable" | tee -a $GITHUB_ENV + RUST_VERSION="$(grep -oP 'channel = "\K\d\.\d+\.\d+(?=")' rust-toolchain.toml)" + echo "RUST_VERSION=$RUST_VERSION" >> "$GITHUB_ENV" - name: Set env vars run: | @@ -42,22 +47,22 @@ jobs: sudo apt-get update sudo apt-get install -y libudev-dev libssl-dev libsasl2-dev libzstd-dev - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_STABLE }} - override: true - profile: minimal - components: rustfmt - - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ matrix.os }}-cargo-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('Cargo.lock') }}-0001 + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ./target + key: cargo-${{ matrix.os }}-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}-0000 + restore-keys: | + cargo-${{ matrix.os }}-${{ hashFiles('rust-toolchain.toml') }} + + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + components: rustfmt - name: Check Solana version run: | @@ -89,7 +94,7 @@ jobs: - name: Release if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.BUILD_NAME }} body: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06ab07b..61a7c6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,15 +1,18 @@ # Source: # https://github.com/solana-labs/solana-accountsdb-plugin-postgres/blob/master/.github/workflows/test.yml -name: Build plugin - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: - workflow_dispatch: pull_request: + push: + branches: + - 'master' + - 'v1.16' + - 'v1.17' + workflow_dispatch: env: CARGO_TERM_COLOR: always @@ -20,13 +23,14 @@ jobs: matrix: os: [ubuntu-20.04, ubuntu-22.04] runs-on: ["${{ matrix.os }}"] + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set rust version run: | - source ci/rust-version.sh - echo "RUST_STABLE=$rust_stable" | tee -a $GITHUB_ENV + RUST_VERSION="$(grep -oP 'channel = "\K\d\.\d+\.\d+(?=")' rust-toolchain.toml)" + echo "RUST_VERSION=$RUST_VERSION" >> "$GITHUB_ENV" - name: Set env vars run: | @@ -39,40 +43,39 @@ jobs: sudo apt-get update sudo apt-get install -y libudev-dev libssl-dev libsasl2-dev libzstd-dev - - uses: actions-rs/toolchain@v1 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ./target + key: cargo-${{ matrix.os }}-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}-0000 + restore-keys: | + cargo-${{ matrix.os }}-${{ hashFiles('rust-toolchain.toml') }} + + - uses: dtolnay/rust-toolchain@stable with: - toolchain: ${{ env.RUST_STABLE }} - override: true - profile: minimal - components: rustfmt, clippy + toolchain: nightly + components: rustfmt - - uses: actions/cache@v3 + - uses: dtolnay/rust-toolchain@stable with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ matrix.os }}-cargo-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('Cargo.lock') }}-0001 + toolchain: ${{ env.RUST_VERSION }} + components: clippy - name: cargo tree run: | cargo tree git checkout Cargo.lock - cargo tree --frozen + cargo tree --frozen --offline - - name: cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - name: Run fmt + run: cargo +nightly fmt --all -- --check - - name: cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --workspace --all-targets --tests #-- --deny=warnings + - name: Run clippy + run: cargo clippy --all-targets --tests -- -Dwarnings - name: Build run: ./ci/cargo-build-test.sh diff --git a/ci/rust-version.sh b/ci/rust-version.sh deleted file mode 100755 index 95a892c..0000000 --- a/ci/rust-version.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash - -# Source: -# https://github.com/solana-labs/solana-accountsdb-plugin-postgres/blob/master/ci/rust-version.sh - -# -# This file maintains the rust versions for use by CI. -# -# Obtain the environment variables without any automatic toolchain updating: -# $ source ci/rust-version.sh -# -# Obtain the environment variables updating both stable and nightly, only stable, or -# only nightly: -# $ source ci/rust-version.sh all -# $ source ci/rust-version.sh stable -# $ source ci/rust-version.sh nightly - -# Then to build with either stable or nightly: -# $ cargo +"$rust_stable" build -# $ cargo +"$rust_nightly" build -# - -if [[ -n $RUST_STABLE_VERSION ]]; then - stable_version="$RUST_STABLE_VERSION" -else - stable_version=1.73.0 -fi - -if [[ -n $RUST_NIGHTLY_VERSION ]]; then - nightly_version="$RUST_NIGHTLY_VERSION" -else - nightly_version=2022-04-01 -fi - - -export rust_stable="$stable_version" -export rust_stable_docker_image=solanalabs/rust:"$stable_version" - -export rust_nightly=nightly-"$nightly_version" -export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version" - -[[ -z $1 ]] || ( - rustup_install() { - declare toolchain=$1 - if ! cargo +"$toolchain" -V > /dev/null; then - echo "$0: Missing toolchain? Installing...: $toolchain" >&2 - rustup install "$toolchain" - cargo +"$toolchain" -V - fi - } - - set -e - cd "$(dirname "${BASH_SOURCE[0]}")" - case $1 in - stable) - rustup_install "$rust_stable" - ;; - nightly) - rustup_install "$rust_nightly" - ;; - all) - rustup_install "$rust_stable" - rustup_install "$rust_nightly" - ;; - *) - echo "$0: Note: ignoring unknown argument: $1" >&2 - ;; - esac -) diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..fe957b9 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +edition = "2021" +imports_granularity = "One" +group_imports = "One"