Skip to content

Commit

Permalink
ci: introduce matrix build for release and remove 8x runners
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Nov 10, 2023
1 parent dc81e3f commit 0205f26
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 23 deletions.
171 changes: 151 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,32 @@ jobs:

release-drive-docker-image:
name: Release Drive to Docker Hub
runs-on: [ "self-hosted", "linux", "x64", "8x-ubuntu-platform" ]
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
strategy:
matrix:
include:
- runner: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
platform: linux/amd64
- runner: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
platform: linux/arm64
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get image tag
uses: actions/github-script@v6
id: tag
Expand All @@ -147,33 +165,146 @@ jobs:
: context.payload.release.tag_name
);
- name: Configure AWS credentials and bucket region
uses: aws-actions/configure-aws-credentials@v4
- name: Set up Docker BuildX
id: buildx
uses: docker/setup-buildx-action@v3
with:
aws-region: ${{ vars.AWS_REGION }}
install: true
driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760
cleanup: false
platforms: ${{ matrix.platform }}
config-inline: |
[worker.oci]
gc = false
- name: Load Docker mount cache
uses: dcginfra/buildkit-cache-dance/inject@s5cmd
with:
bucket: multi-runner-cache-x1xibo9c
mounts: |
cargo_registry_index
cargo_registry_cache
cargo_git
- name: Build Docker image
uses: ./.github/actions/docker
# TODO: must be the same for dashpay/ and ECR
- name: Configure docker layer cache
uses: ./.github/actions/s3-layer-cache-settings
id: layer_cache_settings
with:
image: dashpay/drive
image_tag: ${{steps.tag.outputs.result}}
name: dashpay/drive
head_ref: ${{ steps.tag.outputs.result }}
bucket: multi-runner-cache-x1xibo9c

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: dashpay/drive

- name: Build and push by digest
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
target: drive-abci
cargo_profile: release
push: true
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
platforms: amd64,arm64
# TODO: Use the same bucket for tests and release
bucket: multi-runner-linux-x64-platform-8x-cache-wp1sy0o6
region: ${{ vars.AWS_REGION }}
cache_mounts: |
build-args: |
CARGO_BUILD_PROFILE=release
RUSTC_WRAPPER=sccache
SCCACHE_BUCKET=multi-runner-cache-x1xibo9c
SCCACHE_REGION=${{ vars.AWS_REGION }}
SCCACHE_S3_KEY_PREFIX=${{ runner.os }}/sccache
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: ${{ matrix.platform }}
cache-from: ${{ steps.layer_cache_settings.outputs.cache_from }}
cache-to: ${{ steps.layer_cache_settings.outputs.cache_to }}
outputs: type=image,name=dashpay/drive,push-by-digest=true,name-canonical=true,push=true

- name: Save Docker mount cache
uses: dcginfra/buildkit-cache-dance/extract@s5cmd
with:
bucket: multi-runner-cache-x1xibo9c
mounts: |
cargo_registry_index
cargo_registry_cache
cargo_git
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.docker_build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

push-drive-docker-image:
name: Push Drive to Docker Hub
needs: build-drive-docker-image
runs-on: ubuntu-22.04
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set suffix
uses: actions/github-script@v6
id: suffix
with:
result-encoding: string
script: |
const fullTag = '${{inputs.image_tag}}';
if (fullTag.includes('-')) {
const [, fullSuffix] = fullTag.split('-');
const [suffix] = fullSuffix.split('.');
return `-${suffix}`;
} else {
return '';
}
- name: Set Docker tags and labels from image tag
id: docker_meta
uses: docker/metadata-action@v5
with:
images: dashpay/drive
tags: |
type=match,pattern=v(\d+),group=1,value=${{inputs.image_tag}}
type=match,pattern=v(\d+.\d+),group=1,value=${{inputs.image_tag}}
type=match,pattern=v(\d+.\d+.\d+),group=1,value=${{inputs.image_tag}}
type=match,pattern=v(.*),group=1,value=${{inputs.image_tag}},suffix=
flavor: |
suffix=${{ steps.suffix.outputs.result }},onlatest=true
latest=${{ github.event_name == 'release' }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'dashpay/drive@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect dashpay/drive:${{ steps.docker_meta.outputs.version }}
release-dapi-docker-image:
name: Release DAPI to Docker Hub
runs-on: [ "self-hosted", "linux", "x64", "8x-ubuntu-platform" ]
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
timeout-minutes: 120
steps:
- name: Check out repo
Expand Down Expand Up @@ -217,7 +348,7 @@ jobs:
release-test-suite-docker-image:
name: Release Test Suite to Docker Hub
runs-on: [ "self-hosted", "linux", "x64", "8x-ubuntu-platform" ]
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
timeout-minutes: 120
steps:
- name: Check out repo
Expand Down Expand Up @@ -261,7 +392,7 @@ jobs:
release-dashmate-helper-docker-image:
name: Release Dashmate helper to Docker Hub
runs-on: [ "self-hosted", "linux", "x64", "8x-ubuntu-platform" ]
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
timeout-minutes: 120
steps:
- name: Check out repo
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests-build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
# TODO: try with x8
build-drive:
name: Build Drive image
runs-on: [ "self-hosted", "linux", "x64", "8x-ubuntu-platform" ]
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
# TODO: try with x8
build-dapi:
name: Build DAPI image
runs-on: [ "self-hosted", "linux", "x64", "8x-ubuntu-platform" ]
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
# TODO: try with x8
build-dashmate-helper:
name: Build Dashmate helper image
runs-on: [ "self-hosted", "linux", "x64", "8x-ubuntu-platform" ]
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-platform" ]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand Down

0 comments on commit 0205f26

Please sign in to comment.