Skip to content

refactor(starknet_batcher): pack metadata in exec artifacts #3452

refactor(starknet_batcher): pack metadata in exec artifacts

refactor(starknet_batcher): pack metadata in exec artifacts #3452

name: Sequencer-Docker-Publish
on:
workflow_dispatch:
push:
branches: [main]
tags: ["v*.*.*"]
paths:
- '.github/workflows/sequencer_docker-publish.yml'
- 'crates/**'
- 'scripts/dependencies.sh'
- 'scripts/install_build_tools.sh'
- 'deployments/images/base/Dockerfile'
- 'deployments/images/sequencer/Dockerfile'
pull_request:
paths:
- '.github/workflows/sequencer_docker-publish.yml'
- 'crates/**'
- 'scripts/dependencies.sh'
- 'scripts/install_build_tools.sh'
- 'deployments/images/base/Dockerfile'
- 'deployments/images/sequencer/Dockerfile'
permissions:
contents: read
packages: write
# On PR events, cancel existing CI runs on this same PR for this workflow.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}
RUSTFLAGS: "-D warnings -C link-arg=-fuse-ld=lld"
jobs:
docker-build-push:
runs-on: starkware-ubuntu-latest-large
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Not required but recommended - enables build multi-platform images, export cache, etc
# Also workaround for: https://github.com/docker/build-push-action/issues/461
# https://github.com/docker/setup-buildx-action
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2.2.1
# Login to a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: true
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4.1.1
with:
images: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/sequencer
tags: |
type=semver,pattern={{raw}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=pr
# set `dev` tag for the default branch (`main`).
type=raw,value=dev,enable={{is_default_branch}}
# set `dev-{{branch}}-{{sha}}` additional tag for the default branch (`main`).
type=raw,value=dev-{{branch}}{{tag}}-{{sha}},enable={{is_default_branch}}
type=raw,value={{branch}}{{tag}}-{{sha}},enable=${{ github.event_name == 'workflow_dispatch' }}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v6.13.0
with:
context: .
file: deployments/images/sequencer/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
load: true # Loads the build result to docker images. Required for "Run docker test" step to work.
no-cache: true
- name: Run basic docker test
env:
TIMEOUT_DURATION: "30s"
SEQUENCER_CONFIG_PATH: "./config/sequencer/presets/system_test_presets/single_node_config.json"
run: |
# converts steps.meta.outputs.tags array to bash array.
tags="${{ steps.meta.outputs.tags }}"
tags_array=($tags)
tag=${tags_array[0]}
timeout "$TIMEOUT_DURATION" docker run -e 'RUST_LOG=debug' -e 'RUST_BACKTRACE=full' "$tag" --config_file "$SEQUENCER_CONFIG_PATH" || exit_code="$?"
# Return code 124 from `timeout` process means timeout reached, which considered success for this test.
if (( $exit_code == 124 )); then
echo "Docker ran successfully for $TIMEOUT_DURATION!"
exit 0
# Any other return codes could be application or docker failure.
else
echo "Docker failed or exited prematurely with exit code $exit_code."
exit 1
fi