test: cover stalled SABR initialization #734
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| IMAGE_NAME_BETA: ${{ github.repository }}-beta | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| concurrency: | |
| group: docker-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| prepare-image: | |
| runs-on: [self-hosted, Linux, X64, arko] | |
| permissions: | |
| contents: read | |
| outputs: | |
| build-time: ${{ steps.build-info.outputs.build-time }} | |
| image: ${{ steps.build-info.outputs.image }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| metadata-json: ${{ steps.meta.outputs.json }} | |
| version: ${{ steps.build-info.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Resolve build metadata | |
| id: build-info | |
| run: | | |
| base_version="$(sed -n 's/^appVersion=//p' gradle.properties)" | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| version="${GITHUB_REF_NAME#v}" | |
| else | |
| channel="${GITHUB_REF_NAME//[^0-9A-Za-z-]/-}" | |
| version="$base_version-$channel.$GITHUB_RUN_NUMBER" | |
| fi | |
| if [[ "$GITHUB_REF_NAME" == "dev" ]]; then | |
| image="${REGISTRY}/${GITHUB_REPOSITORY,,}-beta" | |
| else | |
| image="${REGISTRY}/${GITHUB_REPOSITORY,,}" | |
| fi | |
| { | |
| echo "image=$image" | |
| echo "version=$version" | |
| echo "build-time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: | | |
| name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},enable=${{ github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') }} | |
| name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BETA }},enable=${{ github.ref_name == 'dev' }} | |
| tags: | | |
| type=raw,value=${{ steps.build-info.outputs.version }} | |
| type=sha,prefix=sha-,format=short | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest,enable=${{ github.ref_name == 'main' }} | |
| type=raw,value=latest,enable=${{ github.ref_name == 'dev' }} | |
| type=raw,value=beta,enable=${{ github.ref_name == 'dev' }} | |
| build-platform: | |
| needs: prepare-image | |
| runs-on: [self-hosted, Linux, X64, arko, docker] | |
| timeout-minutes: 20 | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| arch: arm64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Isolate Docker credentials | |
| run: echo "DOCKER_CONFIG=$RUNNER_TEMP/docker-config" >> "$GITHUB_ENV" | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up QEMU | |
| if: matrix.arch == 'arm64' | |
| uses: docker/setup-qemu-action@v4.1.0 | |
| with: | |
| platforms: arm64 | |
| cache-image: false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push | |
| id: build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| pull: true | |
| labels: ${{ needs.prepare-image.outputs.labels }} | |
| outputs: type=image,name=${{ needs.prepare-image.outputs.image }},push-by-digest=true,name-canonical=true,push=true | |
| provenance: false | |
| build-args: | | |
| APP_VERSION=${{ needs.prepare-image.outputs.version }} | |
| GITHUB_SHA=${{ github.sha }} | |
| BUILD_TIME=${{ needs.prepare-image.outputs.build-time }} | |
| cache-from: type=gha,scope=typetype-server-${{ matrix.arch }} | |
| cache-to: type=gha,mode=max,scope=typetype-server-${{ matrix.arch }} | |
| - name: Export digest | |
| env: | |
| DIGEST: ${{ steps.build.outputs.digest }} | |
| run: | | |
| digest_dir="$RUNNER_TEMP/typetype-server-digests" | |
| rm -rf "$digest_dir" | |
| mkdir -p "$digest_dir" | |
| touch "$digest_dir/${DIGEST#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: server-digests-${{ matrix.arch }} | |
| path: ${{ runner.temp }}/typetype-server-digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| build-and-push: | |
| needs: [prepare-image, build-platform] | |
| runs-on: [self-hosted, Linux, X64, arko, docker] | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| digest: ${{ steps.manifest.outputs.digest }} | |
| steps: | |
| - name: Isolate Docker credentials | |
| run: echo "DOCKER_CONFIG=$RUNNER_TEMP/docker-config" >> "$GITHUB_ENV" | |
| - name: Prepare digest directory | |
| run: rm -rf "$RUNNER_TEMP/typetype-server-digests" | |
| - name: Download digests | |
| uses: actions/download-artifact@v8.0.1 | |
| with: | |
| path: ${{ runner.temp }}/typetype-server-digests | |
| pattern: server-digests-* | |
| merge-multiple: true | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Create manifest list and push | |
| id: manifest | |
| env: | |
| DIGEST_DIR: ${{ runner.temp }}/typetype-server-digests | |
| IMAGE: ${{ needs.prepare-image.outputs.image }} | |
| METADATA_JSON: ${{ needs.prepare-image.outputs.metadata-json }} | |
| run: | | |
| cd "$DIGEST_DIR" | |
| mapfile -t digests < <(find . -maxdepth 1 -type f -printf '%f\n' | sort) | |
| if [[ "${#digests[@]}" -ne 2 ]]; then | |
| echo "Expected two platform digests, found ${#digests[@]}" | |
| exit 1 | |
| fi | |
| mapfile -t tags < <(jq -r '.tags[]' <<< "$METADATA_JSON") | |
| if [[ "${#tags[@]}" -eq 0 ]]; then | |
| echo "No image tags were generated" | |
| exit 1 | |
| fi | |
| tag_args=() | |
| for tag in "${tags[@]}"; do | |
| tag_args+=(--tag "$tag") | |
| done | |
| source_args=() | |
| for digest in "${digests[@]}"; do | |
| source_args+=("$IMAGE@sha256:$digest") | |
| done | |
| docker buildx imagetools create "${tag_args[@]}" "${source_args[@]}" | |
| manifest_json="$(docker buildx imagetools inspect "${tags[0]}" --format '{{json .Manifest}}')" | |
| digest="$(jq -r '.digest' <<< "$manifest_json")" | |
| if [[ "$digest" != sha256:* ]]; then | |
| echo "Published manifest has no valid digest" | |
| exit 1 | |
| fi | |
| echo "digest=$digest" >> "$GITHUB_OUTPUT" | |
| - name: Verify manifest platforms | |
| env: | |
| IMAGE: ${{ needs.prepare-image.outputs.image }} | |
| VERSION: ${{ needs.prepare-image.outputs.version }} | |
| run: | | |
| platforms="$(docker buildx imagetools inspect "$IMAGE:$VERSION" --format '{{json .Manifest}}' | jq -r '.manifests[].platform | "\(.os)/\(.architecture)"' | sort -u)" | |
| if [[ "$platforms" != $'linux/amd64\nlinux/arm64' ]]; then | |
| printf 'Unexpected manifest platforms:\n%s\n' "$platforms" | |
| exit 1 | |
| fi | |
| notify-orchestrator: | |
| needs: [prepare-image, build-and-push] | |
| if: github.ref_name == 'dev' || github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') | |
| runs-on: [self-hosted, Linux, X64, arko] | |
| permissions: | |
| contents: read | |
| env: | |
| GH_TOKEN: ${{ secrets.TYPETYPE_ORCHESTRATOR_TOKEN }} | |
| steps: | |
| - name: Send image digest | |
| env: | |
| DIGEST: ${{ needs.build-and-push.outputs.digest }} | |
| IMAGE: ${{ needs.prepare-image.outputs.image }} | |
| VERSION: ${{ needs.prepare-image.outputs.version }} | |
| run: | | |
| if [[ "$GITHUB_REF_NAME" == "dev" ]]; then channel="beta"; else channel="stable"; fi | |
| jq -n \ | |
| --arg channel "$channel" \ | |
| --arg component "server" \ | |
| --arg digest "$DIGEST" \ | |
| --arg image "$IMAGE" \ | |
| --arg revision "$GITHUB_SHA" \ | |
| --arg version "$VERSION" \ | |
| '{event_type:"component-image",client_payload:{channel:$channel,component:$component,digest:$digest,image:$image,revision:$revision,version:$version}}' \ | |
| | gh api --method POST repos/TypeType-Video/TypeType/dispatches --input - |