Skip to content

Use actual block time in slot monitor alerts #53

Use actual block time in slot monitor alerts

Use actual block time in slot monitor alerts #53

Workflow file for this run

# This action builds an alerter container image.
#
# Container images are only marked as "latest" in GitHub Container Registry for pushes to `main` and tags (including release tags).
name: Docker build
# This action is triggered for every PR, push to `main`, tag, release, merge queue, and manually.
on:
push:
branches:
- "main"
tags:
- "*"
release:
pull_request:
merge_group:
workflow_dispatch:
concurrency:
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Incremental compilation here isn't helpful
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
jobs:
# This will build container images
docker-build:
runs-on: ubuntu-24.04
permissions:
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
with:
# Limit concurrency so it can complete with small official runners
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 1
- name: Log into registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: |
ghcr.io/${{ github.repository_owner }}/chain-alerter
tags: |
type=ref,event=tag
type=ref,event=branch
type=sha,format=long
flavor: |
latest=${{ github.ref_name == 'main' || github.ref_type == 'tag' }}
suffix=
- name: Build and push chain-alerter image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
file: docker/chain-alerter.Dockerfile
pull: true
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Runs a chain-alerter docker container until it sends a startup alert, but with Slack disabled.
# This is useful for testing the chain-alerter docker image.
#
# This should be kept in sync with the rust.yml `cargo-run` job.
docker-run:
name: docker-run
runs-on: ubuntu-24.04
# Unfortunately, this doesn't work at the step level on Windows.
defaults:
run:
shell: bash
# Don't use the full 6 hours if this integration test hangs
timeout-minutes: 30
# We need the container built first
needs: docker-build
steps:
# Using the default node in the docker image, run a simple test we have the correct image,
# printing all the logs to the console.
# https://aschmelyun.com/blog/using-docker-run-inside-of-github-actions/
- name: docker run chain-alerter --help
# Stop the Docker instance after 60 seconds, regardless of whether it succeeded or failed.
# TODO: work out how to let this Docker instance make outbound connections, then use --slack=false
run: |
(docker stop $(sleep 60; docker ps --quiet | tail --lines=1)) &
docker run --tty ghcr.io/autonomys/chain-alerter:sha-${{ github.sha }} --help \
| tee /dev/stderr \
| grep --max-count=1 "A Slack-based alerter that runs on the Autonomys network"
docker-all:
# Hack for buggy GitHub Actions behavior with skipped checks:
# <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks>
if: ${{ always() }}
runs-on: ubuntu-24.04
needs:
- docker-build
- docker-run
steps:
- name: Check job statuses
# Another hack is to actually check the status of the dependencies or else it'll fall through
run: |
echo "Checking statuses..."
[[ "${{ needs.docker-build.result }}" == "success" ]] || exit 1
[[ "${{ needs.docker-run.result }}" == "success" ]] || exit 1