Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use cargo binstall to speed up builds #2321

Merged
merged 26 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
24177fa
feat: hardcoded identity transfers in strategy tests
pauldelucia Nov 4, 2024
dacc6db
fix(drive): uncommitted state if db transaction fails (#2305)
shumkov Nov 4, 2024
306b86c
fix(drive): apply batch is not using transaction in `remove_all_votes…
QuantumExplorer Nov 4, 2024
99fe5fa
add comment
pauldelucia Nov 4, 2024
cee3098
Merge remote-tracking branch 'origin/v1.6-dev' into feat/hardcoded-id…
pauldelucia Nov 4, 2024
0d3e091
comment
pauldelucia Nov 5, 2024
e421514
use into_iter instead of iter
pauldelucia Nov 5, 2024
3d941ec
use current identities instead of hardcoded start identities
pauldelucia Nov 5, 2024
4bc0a65
let transfer keys be any security level or key type
pauldelucia Nov 5, 2024
dc48827
fix
pauldelucia Nov 5, 2024
cafda11
feat: hardcoded identity transfers in strategy tests (#2312)
pauldelucia Nov 5, 2024
b86f4e0
Merge branch 'v1.6-dev' of github.com:dashpay/platform into v1.6-dev
shumkov Nov 6, 2024
ae97f47
ci: run devcontainers workflow only on push to master (#2295)
shumkov Nov 6, 2024
48cca1a
ci: do not run test on push (#2308)
shumkov Nov 6, 2024
5c80069
ci: use prebuilt librocksdb in github actions (#2316)
lklimek Nov 8, 2024
fc0082d
build: use cargo binstall to speed up builds
shumkov Nov 9, 2024
d4c2f7d
build: use binstall in devcontainer too
shumkov Nov 9, 2024
88d3596
Merge branch 'v1.6-dev' into ci/binstall
shumkov Nov 10, 2024
681bf72
ci: install wasm bindgen for release
shumkov Nov 11, 2024
1ac8d3b
build: CARGO_HOME is not defined
shumkov Nov 11, 2024
fa4cf99
build: fix sccache error
shumkov Nov 13, 2024
6584fae
ci: use version instead of branch
shumkov Nov 13, 2024
8c880aa
Merge branch 'refs/heads/v1.6-dev' into ci/binstall
shumkov Nov 13, 2024
113e695
ci: specify correct version
shumkov Nov 13, 2024
6e02f6a
build: set HOME variable
shumkov Nov 13, 2024
e395f2e
ci: disable saving mount cache
shumkov Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,30 @@ ENV PATH=$CARGO_HOME/bin:$PATH
COPY rust-toolchain.toml .
RUN TOOLCHAIN_VERSION="$(grep channel rust-toolchain.toml | awk '{print $3}' | tr -d '"')" && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
--profile minimal \
-y \
--default-toolchain "${TOOLCHAIN_VERSION}" \
--target wasm32-unknown-unknown

# Install wasm-bindgen-cli in the same profile as other components, to sacrifice some performance & disk space to gain
# better build caching
RUN if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
RUSTFLAGS="-C target-feature=-crt-static" \
# Meanwhile if you want to update wasm-bindgen you also need to update version in:
# - packages/wasm-dpp/Cargo.toml
# - packages/wasm-dpp/scripts/build-wasm.sh
cargo install [email protected] --locked
# Download and install cargo-binstall
ENV BINSTALL_VERSION=1.10.11
RUN set -ex; \
if [ "$TARGETARCH" = "amd64" ]; then \
CARGO_BINSTALL_ARCH="x86_64-unknown-linux-musl"; \
elif [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
CARGO_BINSTALL_ARCH="aarch64-unknown-linux-musl"; \
else \
echo "Unsupported architecture: $TARGETARCH"; exit 1; \
fi; \
DOWNLOAD_URL="https://github.com/cargo-bins/cargo-binstall/releases/download/v${BINSTALL_VERSION}/cargo-binstall-${CARGO_BINSTALL_ARCH}.tgz"; \
curl -L --fail --show-error "$DOWNLOAD_URL" -o /tmp/cargo-binstall.tgz; \
tar -xzf /tmp/cargo-binstall.tgz -C /tmp cargo-binstall; \
chmod +x /tmp/cargo-binstall; \
/tmp/cargo-binstall -y --force cargo-binstall; \
rm /tmp/cargo-binstall; \
cargo binstall -V

shumkov marked this conversation as resolved.
Show resolved Hide resolved
RUN cargo binstall [email protected] --locked \
--no-discover-github-token \
--disable-telemetry \
--no-track \
--no-confirm
55 changes: 55 additions & 0 deletions .github/actions/librocksdb/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# This action builds and caches librocksdb. If we find that this solution consumes too much time, we can consider
# prebuilding librocksdb outside of the pipeline (eg. in the grovedb release process), publish as an artifact, and
# download it in the pipeline.
name: "librocksdb"
description: "Build and install librocksdb"
inputs:
version:
description: RocksDB version, eg. "8.10.2"
required: false
default: "8.10.2"
bucket:
description: S3 bucket to use for caching
required: false
default: multi-runner-cache-x1xibo9c
force:
description: Force rebuild
required: false
default: "false"

runs:
using: composite
steps:
# Cache librocksdb using s3 bucket
- name: Restore cached librocksdb from S3
id: librocksdb-cache
uses: strophy/actions-cache@opendal-update
with:
bucket: ${{ inputs.bucket }}
path: /opt/rocksdb
key: librocksdb/${{ inputs.version }}/${{ runner.os }}/${{ runner.arch }}

- if: ${{ steps.librocksdb-cache.outputs.cache-hit != 'true' || inputs.force == 'true' }}
shell: bash
name: Build librocksdb
run: |
set -ex
WORKDIR=/tmp/rocksdb-build
mkdir -p ${WORKDIR}/rocksdb
mkdir -p /opt/rocksdb/usr/local/lib/
pushd ${WORKDIR}/rocksdb

# building rocksdb
git clone https://github.com/facebook/rocksdb.git -b v${{ inputs.version }} --depth 1 .
make -j$(nproc) static_lib
make DESTDIR=/opt/rocksdb install-static
set +x

echo Done.
echo Configuration:
echo
echo "ROCKSDB_STATIC='/opt/rocksdb/usr/local/lib/librocksdb.a'"
echo "ROCKSDB_LIB_DIR='/opt/rocksdb/usr/local/lib'"

popd
4 changes: 2 additions & 2 deletions .github/actions/rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ runs:
export PATH="${PATH}:${HOME}/.local/bin"

- name: Run sccache-cache
uses: mozilla-actions/[email protected].3
uses: mozilla-actions/[email protected].6
with:
version: "v0.7.1" # Must be the same as in Dockerfile
version: "v0.8.2" # Must be the same as in Dockerfile
if: inputs.cache == 'true'

- name: Hash ref_name
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/cached.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Rebuild cached dependencies

on:
workflow_dispatch:
jobs:
build-rust-deps:
name: Prebuild and cache some Rust dependencies
runs-on: ubuntu-24.04
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Precompile librocksdb
uses: ./.github/actions/librocksdb
with:
force: true
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
build:
name: Deploy docs
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout main
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manage-runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
cancel-merged-or-closed-pr-runs:
name: Cancel runs for merged or closed PRs
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: octokit/[email protected]
id: get_active_workflows
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
pr-title:
name: PR title
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Validate conventional PR title
uses: amannn/action-semantic-pull-request@v5
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prebuild-devcontainers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
- '.github/workflows/prebuild-devcontainers.yml'
- rust-toolchain.toml
- Dockerfile
branches:
- master
workflow_dispatch:

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
publish-manifest:
name: Publish image tags
needs: build-image
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Download digests
uses: actions/download-artifact@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ jobs:
matrix:
include:
- package_type: tarballs
os: ubuntu-22.04
os: ubuntu-24.04
- package_type: win
os: ubuntu-22.04
os: ubuntu-24.04
- package_type: deb
os: ubuntu-22.04
os: ubuntu-24.04
- package_type: macos
os: macos-14
steps:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/tests-build-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ jobs:
with:
target: wasm32-unknown-unknown

- name: Install Cargo binstall
uses: cargo-bins/cargo-binstall@main
if: ${{ steps.cache.outputs.cache-hit != 'true' }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid using @main tag for GitHub Actions.

Using cargo-bins/cargo-binstall@main could lead to unexpected behavior if the action is updated. Consider pinning to a specific version for better stability and reproducibility.

-      - name: Install Cargo binstall
-        uses: cargo-bins/cargo-binstall@main
+      - name: Install Cargo binstall
+        uses: cargo-bins/[email protected]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Install Cargo binstall
uses: cargo-bins/cargo-binstall@main
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Install Cargo binstall
uses: cargo-bins/[email protected]
if: ${{ steps.cache.outputs.cache-hit != 'true' }}

- name: Install wasm-bindgen-cli
run: cargo binstall [email protected]
if: ${{ steps.cache.outputs.cache-hit != 'true' }}

- name: Build JS packages
run: yarn build
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
jobs:
codeql:
name: Run Code QL
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests-js-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
lint:
name: Linting
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
permissions:
id-token: write
contents: read
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:

test:
name: Tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
permissions:
id-token: write
contents: read
Expand Down
37 changes: 32 additions & 5 deletions .github/workflows/tests-rs-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
lint-runner:
description: Runner for linting. Must be JSON valid string.
type: string
default: '"ubuntu-22.04"'
default: '"ubuntu-24.04"'
check-each-feature:
description: If true, try to build each individual feature for this crate
type: boolean
Expand Down Expand Up @@ -42,6 +42,9 @@ jobs:
with:
components: clippy

- name: Install librocksdb
uses: ./.github/actions/librocksdb

- uses: clechasseur/rs-clippy-check@v3
with:
args: --package ${{ inputs.package }} --all-features --locked -- --no-deps
Expand All @@ -50,10 +53,12 @@ jobs:
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ secrets.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu
ROCKSDB_STATIC: "/opt/rocksdb/usr/local/lib/librocksdb.a"
ROCKSDB_LIB_DIR: "/opt/rocksdb/usr/local/lib"

formatting:
name: Formatting
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Check out repo
Expand All @@ -65,12 +70,19 @@ jobs:
components: rustfmt
cache: false

# This step doesn't need librocksdb, so we don't install it

- name: Check formatting
env:
RUSTC_WRAPPER: sccache
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ secrets.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu
run: cargo fmt --check --package=${{ inputs.package }}

unused_deps:
name: Unused dependencies
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
permissions:
id-token: write
contents: read
Expand All @@ -89,6 +101,9 @@ jobs:
- name: Setup Rust
uses: ./.github/actions/rust

- name: Install librocksdb
uses: ./.github/actions/librocksdb

- name: Get crate ${{ inputs.package }} info
id: crate_info
uses: ./.github/actions/crate_info
Expand All @@ -102,12 +117,14 @@ jobs:
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ secrets.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu
ROCKSDB_STATIC: "/opt/rocksdb/usr/local/lib/librocksdb.a"
ROCKSDB_LIB_DIR: "/opt/rocksdb/usr/local/lib"
with:
args: ${{ steps.crate_info.outputs.cargo_manifest_dir }}

detect_structure_changes:
name: Detect immutable structure changes
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
# FIXME: as we use `gh pr view` below, this check can only
# run on pull requests. We should find a way to run it
# when manual triggers are used.
Expand Down Expand Up @@ -184,13 +201,18 @@ jobs:
- name: Setup Rust
uses: ./.github/actions/rust

- name: Install librocksdb
uses: ./.github/actions/librocksdb

- name: Run tests
run: cargo test --package=${{ inputs.package }} --all-features --locked
env:
RUSTC_WRAPPER: sccache
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ secrets.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu
ROCKSDB_STATIC: "/opt/rocksdb/usr/local/lib/librocksdb.a"
ROCKSDB_LIB_DIR: "/opt/rocksdb/usr/local/lib"

check_each_feature:
name: Check each feature
Expand All @@ -199,7 +221,7 @@ jobs:
if: ${{ inputs.check-each-feature }}
steps:
- name: Check out repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure AWS credentials and bucket region
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -211,6 +233,9 @@ jobs:
- name: Setup Rust
uses: ./.github/actions/rust

- name: Install librocksdb
uses: ./.github/actions/librocksdb

- name: Get crate ${{ runner.arch }} info
id: crate_info
uses: ./.github/actions/crate_info
Expand All @@ -223,6 +248,8 @@ jobs:
SCCACHE_BUCKET: multi-runner-cache-x1xibo9c
SCCACHE_REGION: ${{ secrets.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu
ROCKSDB_STATIC: "/opt/rocksdb/usr/local/lib/librocksdb.a"
ROCKSDB_LIB_DIR: "/opt/rocksdb/usr/local/lib"
run: |
echo Verify all features disabled
set -ex
Expand Down
Loading
Loading