Skip to content

Commit

Permalink
Merge branch 'master' into feat/release-rs-dpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pshenmic authored Nov 16, 2023
2 parents c69988d + d3577ee commit 3a1534c
Show file tree
Hide file tree
Showing 58 changed files with 891 additions and 321 deletions.
48 changes: 48 additions & 0 deletions .github/actions/crate_info/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Crate Info"
description: "Get crate information. Requires repo to be checked out."
inputs:
package:
description: "Package name"
required: true
outputs:
cargo_manifest_dir:
description: "The directory of the Cargo.toml file"
value: ${{ steps.crate_info.outputs.cargo_manifest_dir }}
cargo_toml:
description: "The path to the Cargo.toml file"
value: ${{ steps.crate_info.outputs.cargo_toml }}
features:
description: "The features of the crate"
value: ${{ steps.crate_info.outputs.features }}
runs:
using: "composite"

steps:
- name: Install yq
id: yq
shell: bash
run: |
set -ex
mkdir -p $HOME/bin
if [ "$(uname -m)" = "x86_64" ] ; then
wget --compression=auto -q -O $HOME/bin/yq \
https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64;
else
wget --compression=auto -q -O $HOME/bin/yq \
https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64;
fi;
chmod +x $HOME/bin/yq
- name: Get crate ${{ inputs.package }} info
id: crate_info
shell: bash
run: |
set -ex
cargo_toml=$(find . -name Cargo.toml -exec \
bash -c "$HOME/bin/yq -e eval '.package.name == \"${{ inputs.package }}\"' {} > /dev/null 2> /dev/null && echo {}" \; )
cargo_manifest_dir=$(dirname "${cargo_toml}")
echo "cargo_manifest_dir=${cargo_manifest_dir}" >> $GITHUB_OUTPUT
echo "cargo_toml=${cargo_toml}" >> $GITHUB_OUTPUT
echo "features=$($HOME/bin/yq -oy eval '.features | keys | .[]' ${cargo_toml} | tr '\n' ' ')" >> $GITHUB_OUTPUT
23 changes: 21 additions & 2 deletions .github/actions/rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,30 @@ inputs:
cache:
description: Enable Rust cache
required: false
default: 'true'
default: "true"

runs:
using: composite
steps:
- name: Get arch
shell: bash
id: arch
run: |
arch="$(uname -m)"
echo "arch=${arch}" >> $GITHUB_OUTPUT
case "$arch" in
x86_64)
echo "protoc_arch=x86_64" >> $GITHUB_OUTPUT
;;
aarch64)
echo "protoc_arch=aarch_64" >> $GITHUB_OUTPUT
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
# TODO: Move to AMI and build every day
- uses: dtolnay/rust-toolchain@master
name: Install Rust toolchain
Expand All @@ -35,7 +54,7 @@ runs:
shell: bash
run: |
curl -Lo /tmp/protoc.zip \
https://github.com/protocolbuffers/protobuf/releases/download/v22.0/protoc-22.0-linux-aarch_64.zip
"https://github.com/protocolbuffers/protobuf/releases/download/v22.0/protoc-22.0-linux-${{ steps.arch.outputs.protoc_arch }}.zip"
unzip /tmp/protoc.zip -d ${HOME}/.local
echo "PROTOC=${HOME}/.local/bin/protoc" >> $GITHUB_ENV
export PATH="${PATH}:${HOME}/.local/bin"
Expand Down
18 changes: 18 additions & 0 deletions .github/package-filters/rs-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,21 @@ drive-abci:
- .github/workflows/tests*
- packages/rs-drive-abci/**
- *drive

dapi-grpc: &dapi_grpc
- .github/workflows/tests*
- packages/rs-platform-version/**
- packages/rs-dapi-grpc-macros/**
- packages/dapi-grpc/**

rs-dapi-client: &dapi_client
- .github/workflows/tests*
- packages/rs-dapi-client/**
- *dapi_grpc

rs-sdk:
- .github/workflows/tests*
- packages/rs-drive-proof-verifier/**
- packages/rs-sdk/**
- *dapi_client
- *drive
54 changes: 0 additions & 54 deletions .github/workflows/rs-features.yml

This file was deleted.

98 changes: 98 additions & 0 deletions .github/workflows/tests-rs-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
description: Runner for linting. Must be JSON valid string.
type: string
default: '"ubuntu-22.04"'
check-each-feature:
description: If true, try to build each individual feature for this crate
type: boolean
default: false

jobs:
lint:
Expand Down Expand Up @@ -67,6 +71,46 @@ jobs:
- name: Check formatting
run: exit `cargo fmt --check --package=${{ inputs.package }} | wc -l`

unused_deps:
name: Unused dependencies
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: read
timeout-minutes: 15
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Configure AWS credentials and bucket region
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }}

- name: Get arch
id: arch
run: echo "arch=$(uname -m)" >> $GITHUB_OUTPUT

- name: Setup Rust
uses: ./.github/actions/rust

- name: Get crate ${{ inputs.package }} info
id: crate_info
uses: ./.github/actions/crate_info
with:
package: ${{ inputs.package }}

- name: Find unused dependencies
uses: lklimek/cargo-machete@feat/workdir
env:
RUSTC_WRAPPER: sccache
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ vars.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ steps.arch.outputs.arch }}/linux-gnu
with:
args: ${{ steps.crate_info.outputs.cargo_manifest_dir }}

detect_structure_changes:
name: Detect immutable structure changes
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -151,3 +195,57 @@ jobs:
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ vars.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ steps.arch.outputs.arch }}/linux-gnu

check_each_feature:
name: Check each feature
runs-on: ${{ fromJSON(inputs.test-runner) }}
timeout-minutes: 10
if: ${{ inputs.check-each-feature }}
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Configure AWS credentials and bucket region
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}

- name: Setup Rust
uses: ./.github/actions/rust

- name: Get arch
id: arch
run: echo "arch=$(uname -m)" >> $GITHUB_OUTPUT

- name: Get crate ${{ inputs.package }} info
id: crate_info
uses: ./.github/actions/crate_info
with:
package: ${{ inputs.package }}

- name: Check each feature in ${{ inputs.package }}
env:
RUSTC_WRAPPER: sccache
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ vars.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ steps.arch.outputs.arch }}/linux-gnu
run: |
echo Verify all features disabled
set -ex
features="${{ steps.crate_info.outputs.features }}"
fails=""
cargo check --no-default-features --package "${{ inputs.package }}" --locked
for feature in $features ; do
echo " ============== Verify feature $feature =============="
cargo check \
--no-default-features \
--package "${{ inputs.package }}" \
--features="${feature}" \
--locked || fails="${fails} ${feature}"
done
if [ -n "$fails" ] ; then
echo "Failed features: $fails"
exit 1
fi
echo "All features verified"
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- master
- 'v[0-9]+\.[0-9]+-dev'
schedule:
- cron: '30 4 * * *'
- cron: "30 4 * * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
lint-runner: ${{ contains(fromJSON('["drive-abci", "drive"]'), matrix.rs-package) && '[ "self-hosted", "linux", "arm64", "ubuntu-platform" ]' || '"ubuntu-22.04"' }}
# Run drive tests on self-hosted 4x
test-runner: ${{ contains(fromJSON('["drive-abci"]'), matrix.rs-package) && '[ "self-hosted", "linux", "arm64", "ubuntu-platform-4x" ]' || '[ "self-hosted", "linux", "arm64", "ubuntu-platform" ]' }}

check-each-feature: ${{ contains(fromJSON('["rs-sdk","rs-dapi-client","dapi-grpc","dpp","drive-abci"]'), matrix.rs-package) }}
rs-crates-security:
name: Rust crates security audit
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || !github.event.pull_request.draft }}
Expand Down
Loading

0 comments on commit 3a1534c

Please sign in to comment.