Skip to content

Commit

Permalink
Merge branch 'v1.4-dev' into feat/splitABCITestCI
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer authored Sep 29, 2024
2 parents 97ea8d7 + 8b847ea commit 51dcff5
Show file tree
Hide file tree
Showing 1,093 changed files with 201,110 additions and 48,061 deletions.
11 changes: 11 additions & 0 deletions .cargo/config-release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a config file used by Docker build process when building release version of drive-abci.
# Hopefully it can be removed once profile-rustflags is stabilized, see https://github.com/rust-lang/cargo/issues/10271

[target.aarch64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static"]

[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
59 changes: 59 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Use the official VS Code base image for dev containers
FROM mcr.microsoft.com/devcontainers/base:ubuntu

# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
pkg-config \
clang \
cmake \
llvm \
curl \
gnupg \
lsb-release \
software-properties-common \
unzip

# Switch to clang
RUN rm /usr/bin/cc && ln -s /usr/bin/clang /usr/bin/cc

# Install protoc - protobuf compiler
# The one shipped with Alpine does not work
ARG TARGETARCH
ARG PROTOC_VERSION=25.2
RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export PROTOC_ARCH=aarch_64; else export PROTOC_ARCH=x86_64; fi; \
curl -Ls https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip \
-o /tmp/protoc.zip && \
unzip -qd /opt/protoc /tmp/protoc.zip && \
rm /tmp/protoc.zip && \
ln -s /opt/protoc/bin/protoc /usr/bin/

# Install protoc v25.2+
RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protoc-25.2-linux-x86_64.zip \
&& unzip protoc-25.2-linux-x86_64.zip -d /usr/local \
&& rm protoc-25.2-linux-x86_64.zip

# Switch to vscode user
USER vscode

ENV CARGO_HOME=/home/vscode/.cargo
ENV PATH=$CARGO_HOME/bin:$PATH

# TODO: It doesn't sharing PATH between stages, so we need "source $HOME/.cargo/env" everywhere
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 wasm-bindgen-cli@0.2.86 --locked
73 changes: 73 additions & 0 deletions .devcontainer/devcontainer-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "Dash Platform Dev Container",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"arcanis.vscode-zipfs",
"chrmarti.regex",
"davidanson.vscode-markdownlint",
"ms-vscode.cmake-tools",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"vadimcn.vscode-lldb",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"zhangyue.rust-mod-generator",
"ms-azuretools.vscode-docker"
]
}
},
"remoteUser": "vscode",
"mounts": [
{
"source": "devcontainer-platform-cargo-registry-index-${devcontainerId}",
"target": "/home/vscode/.cargo/registry",
"type": "volume"
},
{
"source": "devcontainer-platform-cargo-registry-cache-${devcontainerId}",
"target": "/home/vscode/.cargo/registry/cache",
"type": "volume"
},
{
"source": "devcontainer-platform-cargo-git-db-${devcontainerId}",
"target": "/home/vscode/.cargo/git/db",
"type": "volume"
},
{
"source": "devcontainer-platform-target-${devcontainerId}",
"target": "${containerWorkspaceFolder}/target",
"type": "volume"
}
],
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
"ppa": "false"
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/node:1": {
"version": 20,
"installYarnUsingApt": false
},
"ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/schlich/devcontainer-features/starship:0": {},
},
"postCreateCommand": {
"git-safe": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"cargo-permissions": "sudo chown -R vscode:vscode /home/vscode/.cargo ${containerWorkspaceFolder}/target"
}
}
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Dash Platform Dev Container",
"image": "ghcr.io/dashpay/platform/devcontainer:0.1.0"
}
20 changes: 16 additions & 4 deletions .github/actions/rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: "Rust Dependencies"
description: "Install dependencies"
inputs:
toolchain:
description: Rust toolchain to use, stable / nightly / beta, or exact version
# The same as in /README.md
default: "1.76"
description: Rust toolchain to use, stable / nightly / beta, or exact version; uses rust-toolchain.toml if not specified
default: ""
target:
description: Target Rust platform
required: false
Expand All @@ -21,11 +20,24 @@ inputs:
runs:
using: composite
steps:
- name: Extract Rust toolchain version from rust-toolchain.toml
shell: bash
id: rust_toolchain
run: |
TOOLCHAIN_VERSION="${{ inputs.toolchain }}"
if [[ -z "$TOOLCHAIN_VERSION" ]]; then
TOOLCHAIN_VERSION=$(grep channel rust-toolchain.toml | awk '{print $3}' | tr -d '"')
fi
echo "TOOLCHAIN_VERSION=$TOOLCHAIN_VERSION" >> $GITHUB_ENV
echo "::set-output name=version::$TOOLCHAIN_VERSION"
# TODO: Move to AMI and build every day
- uses: dtolnay/rust-toolchain@master
name: Install Rust toolchain
id: install_rust
with:
toolchain: ${{ inputs.toolchain }}
toolchain: ${{ steps.rust_toolchain.outputs.version }}
target: ${{ inputs.target }}
components: ${{ inputs.components }}

Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/prebuild-devcontainers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Prebuild Dev Containers

on:
push:
paths:
- '.devcontainer/**'
- '.github/workflows/prebuild-devcontainers.yml'
- rust-toolchain.toml
- Dockerfile
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and push devcontainer
runs-on: ["self-hosted", "linux", "x64", "ubuntu-platform"]
timeout-minutes: 60
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node.JS
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install skopeo
run: |
sudo apt-get update
sudo apt-get install -y skopeo
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
with:
use: true

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: dashpay
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push Platform devcontainer
uses: devcontainers/ci@v0.3
with:
imageName: ghcr.io/dashpay/platform/devcontainer
imageTag: 0.1.0
platform: linux/amd64,linux/arm64
configFile: .devcontainer/devcontainer-build.json
push: always
cacheFrom: ghcr.io/dashpay/platform/devcontainer
47 changes: 21 additions & 26 deletions .github/workflows/release-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ on:
type: string
description: Image target. i.e. drive-abci, dapi
required: true
tag:
type: string
description: Image tag, i.e. v0.1.0; note it can be inherited from 'workflow_dispatch' event
default: ${{ github.event.inputs.tag || github.event.release.tag_name }}
cargo_profile:
type: string
description: Cargo profile. i.e. release, dev
default: release
env:
DIGEST_NAME: digests-${{ inputs.image_org }}-${{ inputs.image_name }}-${{ github.sha }}
DIGEST_NAME: digests-${{ inputs.image_org }}-${{ inputs.image_name }}-${{ inputs.tag }}-${{ inputs.cargo_profile }}-${{ github.sha }}
DIGEST_DIR_PATH: /tmp/digests

jobs:
Expand All @@ -29,9 +37,9 @@ jobs:
strategy:
matrix:
include:
- runner: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
- runner: ["self-hosted", "linux", "x64", "ubuntu-platform"]
platform: linux/amd64
- runner: [ "self-hosted", "linux", "arm64", "ubuntu-platform" ]
- runner: ["self-hosted", "linux", "arm64", "ubuntu-platform"]
platform: linux/arm64
steps:
- name: Check out repo
Expand All @@ -52,10 +60,10 @@ jobs:
with:
image_name: ${{ inputs.image_name }}
image_org: ${{ inputs.image_org }}
image_version: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.event.release.tag_name }}
image_version: ${{ inputs.tag }}
target: ${{ inputs.target }}
platform: ${{ matrix.platform }}
cargo_profile: release
cargo_profile: ${{ inputs.cargo_profile }}
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
region: ${{ secrets.AWS_REGION }}
Expand Down Expand Up @@ -92,29 +100,17 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Get image version
uses: actions/github-script@v6
id: version
with:
result-encoding: string
script: |
return (
context.eventName === 'workflow_dispatch'
? '${{ github.event.inputs.tag }}'
: context.payload.release.tag_name
);
- name: Set suffix
uses: actions/github-script@v6
id: suffix
with:
result-encoding: string
script: |
const fullTag = '${{ steps.version.outputs.result }}';
const fullTag = '${{ inputs.tag }}';
if (fullTag.includes('-')) {
const [, fullSuffix] = fullTag.split('-');
const [suffix] = fullSuffix.split('.');
return `-${suffix}`;
const suffixes = fullTag.split('-').slice(1);
const firstElements = suffixes.map(suffix => suffix.split('.')[0]);
return `-${firstElements.join('-')}`;
} else {
return '';
}
Expand All @@ -125,10 +121,10 @@ jobs:
with:
images: ${{ inputs.image_org }}/${{ inputs.image_name }}
tags: |
type=match,pattern=v(\d+),group=1,value=${{ steps.version.outputs.result }}
type=match,pattern=v(\d+.\d+),group=1,value=${{ steps.version.outputs.result }}
type=match,pattern=v(\d+.\d+.\d+),group=1,value=${{ steps.version.outputs.result }}
type=match,pattern=v(.*),group=1,value=${{ steps.version.outputs.result }},suffix=
type=match,pattern=v(.*),group=1,value=${{ inputs.tag }},priority=910,suffix=
type=match,pattern=v(\d+),group=1,value=${{ inputs.tag }}
type=match,pattern=v(\d+.\d+),group=1,value=${{ inputs.tag }}
type=match,pattern=v(\d+.\d+.\d+),group=1,value=${{ inputs.tag }}
flavor: |
suffix=${{ steps.suffix.outputs.result }},onlatest=true
latest=${{ github.event_name == 'release' }}
Expand All @@ -138,7 +134,6 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create manifest list and push
working-directory: ${{ env.DIGEST_DIR_PATH }}
run: |
Expand Down
Loading

0 comments on commit 51dcff5

Please sign in to comment.