Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v0.25-dev' into feat/rs-drive-li…
Browse files Browse the repository at this point in the history
…ght-client
  • Loading branch information
lklimek committed Jul 17, 2023
2 parents df024b1 + c435a3e commit f064493
Show file tree
Hide file tree
Showing 157 changed files with 8,213 additions and 4,094 deletions.
101 changes: 67 additions & 34 deletions .github/actions/docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,81 @@
name: "Build Docker image"
description: "Build Docker image with Rust caching"
inputs:
dockerfile:
description: Path to the Dockerfile, for example `./Dockerfile`
required: true
image:
description: Name of image in Docker Hub, like `dashpay/drive`
required: true
dockerfile:
description: Path to the Dockerfile, for example `./Dockerfile`
default: './Dockerfile'
target:
description: "Target stage within Dockerfile: dapi, drive-abci, dashmate-helper, test-suite"
required: false
push:
description: Shall we push the image to Docker Hub?
default: "false"
dockerhub_username:
description: User name to use when pushing images to Docker Hub
required: false
dockerhub_token:
description: Docker Hub token to use
required: false
image_tag:
description: Docker image tag
default: ${{ github.head_ref || github.ref_name }}
platforms:
description: Docker image platform to build
default: amd64,arm64
cache_mounts:
description: Load cache mounts cache
cargo_profile:
description: Cargo build profile, i.e release or dev
default: release

runs:
using: composite
steps:
- name: Setup sccache
uses: mozilla-actions/[email protected]
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ inputs.dockerhub_token }}
if: ${{ inputs.dockerhub_token != '' }}

- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: amd64,arm64
platforms: ${{ inputs.platforms }}

- name: Set up Docker Build
uses: docker/[email protected]
- name: Format platforms for docker
uses: actions/github-script@v6
id: platforms
with:
result-encoding: string
script: |
return '${{inputs.platforms}}'
.split(',')
.map((platform) => `linux/${platform.trim()}`)
.join(',')
- name: Login to DockerHub
uses: docker/login-action@v2
- name: Set up Docker BuildX
id: buildx
uses: docker/setup-buildx-action@v2
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ inputs.dockerhub_token }}
if: inputs.dockerhub_token != ''
install: true
driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760
cleanup: false
platforms: ${{ steps.platforms.outputs.result }}
config-inline: |
[worker.oci]
gc = true
gckeepstorage = 40000 # 40 GB
[[worker.oci.gcpolicy]]
all = true
keepBytes = 30000000000 # 30 GB
keepDuration = 864000 # 10 days
- name: Load Docker mount cache
uses: dcginfra/buildkit-cache-dance/inject@main
if: ${{ inputs.cache_mounts != '' }}
with:
mounts: ${{ inputs.cache_mounts }}

- name: Set suffix
uses: actions/github-script@v6
Expand Down Expand Up @@ -74,32 +107,32 @@ runs:
suffix=${{ steps.suffix.outputs.result }},onlatest=true
latest=${{ github.event_name == 'release' }}
# ARM build takes very long time, so we build PRs for AMD64 only
- name: Select target platforms
shell: bash
id: select_platforms
run: |
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]] ; then
echo "build_platforms=linux/amd64" >> $GITHUB_ENV
else
echo "build_platforms=linux/amd64,linux/arm64" >> $GITHUB_ENV
fi
- name: Configure docker layer cache
uses: ./.github/actions/s3-layer-cache-settings
id: layer_cache_settings
with:
name: ${{ inputs.image }}
head_ref: ${{ inputs.image_tag }}

- name: Build and push Docker image ${{ inputs.image }}
id: docker_build
uses: docker/[email protected]
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: ${{ inputs.dockerfile }}
target: ${{ inputs.target }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
build-args: |
SCCACHE_GHA_ENABLED=true
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
CARGO_BUILD_PROFILE=dev
platforms: ${{ env.build_platforms }}
push: ${{ inputs.push }}
cache-from: type=s3,region=eu-west-1,bucket=platform-runner-cache
cache-to: type=s3,region=eu-west-1,bucket=platform-runner-cache,mode=max
CARGO_BUILD_PROFILE=${{ inputs.cargo_profile }}
platforms: ${{ steps.platforms.outputs.result }}
push: ${{ fromJSON(inputs.push) }}
cache-from: ${{ steps.layer_cache_settings.outputs.cache_from }}
cache-to: ${{ steps.layer_cache_settings.outputs.cache_to }}

- name: Save Docker mount cache
uses: dcginfra/buildkit-cache-dance/extract@main
if: ${{ inputs.cache_mounts != '' }}
with:
mounts: ${{ inputs.cache_mounts }}
38 changes: 38 additions & 0 deletions .github/actions/nodejs/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: "Setup Node.JS"
description: "Setup Node.JS binaries, dependencies and cache"
runs:
using: composite
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: eu-west-1

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

- name: Enable corepack
shell: bash
run: corepack enable

- name: Disable NPM audit
shell: bash
run: npm config set audit false

- name: Cache NPM build artifacts
uses: everpcpc/actions-cache@v1
with:
bucket: platform-runner-cache
root: actions-cache
path: |
.yarn/unplugged
key: ${{ runner.os }}-yarn-unplugged-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-unplugged-
- name: Install dependencies
shell: bash
run: yarn install
28 changes: 15 additions & 13 deletions .github/actions/rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ runs:
echo "PROTOC=${HOME}/.local/bin/protoc" >> $GITHUB_ENV
export PATH="${PATH}:${HOME}/.local/bin"
- name: Install sccache cache
uses: mozilla-actions/[email protected]
- name: Set sccache Rust variables
shell: bash
run: |
echo SCCACHE_GHA_ENABLED=true >> $GITHUB_ENV
echo RUSTC_WRAPPER=sccache >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: eu-west-1

- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Cache Rust build artifacts
uses: everpcpc/actions-cache@v1
with:
# Don't cache ./target, as it takes tons of space, use sccache instead.
cache-targets: false
# We set a shared key, as our cache is reusable between jobs
shared-key: rust-cargo
bucket: platform-runner-cache
root: actions-cache
path: |
/home/ubuntu/.cargo/registry/index
/home/ubuntu/.cargo/registry/cache
/home/ubuntu/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Install clang
id: deps-clang
Expand Down
66 changes: 66 additions & 0 deletions .github/actions/s3-layer-cache-settings/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 'Get S3 Docker Layer Cache settings'
description: |
This action generates string with s3-based cache configuration for docker buildx.
It defines three manifests:
- name and current commit to hit all builds for this commit (restart) with this name
- name and head ref to hit all builds for this branch with this name
- just name to hit all builds for this name
inputs:
name:
description: 'Cache key name will be used as a prefix for all docker image manifests'
required: true
head_ref:
description: 'Head ref for an additional manifest to hit all builds for this head'
default: ${{ github.head_ref }}
region:
description: S3 region
default: eu-west-1
bucket:
description: S3 bucket name
default: platform-runner-cache
prefix:
description: S3 key prefix
default: 'cache-layers/'
mode:
description: Cache mode
default: max

outputs:
cache_to:
description: 'String with s3-based cache configuration for docker buildx cache-to option'
value: ${{ steps.script.outputs.cache_to }}
cache_from:
description: 'String with s3-based cache configuration for docker buildx cache-from option'
value: ${{ steps.script.outputs.cache_from }}

runs:
using: composite
steps:
- uses: actions/github-script@v6
id: script
with:
script: |
const sanitizedHeadRef = '${{ inputs.head_ref }}'.replace(/[^a-zA-Z0-9]/g, '-');
const manifestNames = [
'${{ inputs.name }}_sha_${{ github.sha }}',
`${{ inputs.name }}_tag_${ sanitizedHeadRef }`,
'${{ inputs.name }}'
];
const settings = {
type: 's3',
region: '${{ inputs.region }}',
bucket: '${{ inputs.bucket }}',
prefix: '${{ inputs.prefix }}',
name: manifestNames.join(';'),
};
const settingsString = Object.entries(settings)
.filter(([,value]) => value !== '')
.map(([key, value]) => `${key}=${value}`)
.join(',');
core.setOutput('cache_from', settingsString);
core.setOutput('cache_to', `${settingsString},mode=${{ inputs.mode }}`);
Loading

0 comments on commit f064493

Please sign in to comment.