Skip to content

Add test and coverage steps to Rust CI pipeline #43

Add test and coverage steps to Rust CI pipeline

Add test and coverage steps to Rust CI pipeline #43

Workflow file for this run

name: Docker CI/CD
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
release:
types: [created]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
docker:
strategy:
matrix:
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Convert repository name to lowercase
id: repo
run: echo "name=$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Build and push (per-arch)
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/${{ matrix.arch }}
push: true
tags: ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ matrix.arch }}-${{ github.sha }}
cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
manifest:
needs: docker
runs-on: ubuntu-latest
steps:
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifest
run: |
NAME="${{ env.REGISTRY }}/${{ github.repository }}" && NAME="${NAME,,}"
TAG="${{ github.event_name == 'release' && github.ref_name || (github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'dev') }}"
# Always create the version/pr/dev tag
docker buildx imagetools create \
-t "${NAME}:${TAG}" \
"${NAME}:amd64-${{ github.sha }}" \
"${NAME}:arm64-${{ github.sha }}"
# Only update latest tag for releases
if [ "${{ github.event_name }}" = "release" ]; then
docker buildx imagetools create \
-t "${NAME}:latest" \
"${NAME}:amd64-${{ github.sha }}" \
"${NAME}:arm64-${{ github.sha }}"
fi