Skip to content

Send EOS for every appsrc linked into the pipeline (CS-1547) #2170

Send EOS for every appsrc linked into the pipeline (CS-1547)

Send EOS for every appsrc linked into the pipeline (CS-1547) #2170

# Copyright 2023 LiveKit, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Integration Test
on:
workflow_dispatch:
pull_request:
branches: [ main ]
paths:
- build/chrome/**
- build/egress/**
- build/gstreamer/**
- build/test/**
- cmd/**
- pkg/**
- test/**
- go.mod
permissions:
contents: read
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest-m
outputs:
image: ${{ steps.docker-md.outputs.tags }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: true
- name: Fetch media-samples (with LFS)
env:
GITHUB_TOKEN: ${{ github.token }}
run: build/test/fetch-media-samples.sh
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
~/go/pkg/mod
~/go/bin
~/.cache
key: egress-integration-${{ hashFiles('**/go.sum') }}
restore-keys: egress-integration
- name: Docker metadata
id: docker-md
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
with:
images: livekit/egress-integration
tags: |
type=sha
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: .go-version
- name: Download Go modules
run: go mod download
- name: Get template image
id: template-tag
run: |
TEMPLATE_TAG=`go run github.com/livekit/egress/cmd/template_version`
echo "template_tag=$TEMPLATE_TAG" > "$GITHUB_OUTPUT"
- name: Login to DockerHub
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Buildx
id: buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
with:
driver: docker-container
install: true
- name: Build and push
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./build/test/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.docker-md.outputs.tags }}
labels: ${{ steps.docker-md.outputs.labels }}
build-args: |
DEADLOCK=1
TEMPLATE_TAG=${{ steps.template-tag.outputs.template_tag }}
SECURITY_REFRESH=${{ github.run_id }}-${{ github.run_attempt }}
# TODO: Enable caching once registry periodic cleanup is implemented
#cache-from: type=registry,ref=livekit/egress-integration:buildcache
#cache-to: type=registry,ref=livekit/egress-integration:buildcache,mode=max,ignore-error=true
test:
needs: build
strategy:
fail-fast: false
matrix:
integration_type: [file-room, file-track, file-media, stream, segments, images, multi, edge]
runs-on: ubuntu-latest-m
steps:
- uses: shogo82148/actions-setup-redis@3e38d435ea02619c76909c929ecc501806c7145e # v1
with:
redis-version: '6.x'
auto-start: true
- run: redis-cli ping
- name: Run tests
env:
IMAGE: ${{needs.build.outputs.image}}
run: |
set -o pipefail
docker run --rm \
--network host \
-e GITHUB_WORKFLOW=1 \
-e EGRESS_CONFIG_STRING="$(echo ${{ secrets.EGRESS_CONFIG_STRING }} | base64 -d)" \
-e INTEGRATION_TYPE="${{ matrix.integration_type }}" \
-e S3_UPLOAD="$(echo ${{ secrets.S3_UPLOAD }} | base64 -d)" \
-e GCP_UPLOAD="$(echo ${{ secrets.GCP_UPLOAD }} | base64 -d)" \
${{ env.IMAGE }} \
2>&1 | tee /tmp/test-output.log
- name: Extract avsync stats
if: always()
run: |
# Extract the JSON block between sentinel markers; fall back to []
# so the artifact always exists for the summary job.
awk '/===AVSYNC_STATS_BEGIN===/{flag=1; next} /===AVSYNC_STATS_END===/{flag=0} flag' \
/tmp/test-output.log > /tmp/avsync-stats.json
if [ ! -s /tmp/avsync-stats.json ]; then
echo "[]" > /tmp/avsync-stats.json
fi
echo "Stats rows: $(jq 'length' /tmp/avsync-stats.json)"
- name: Upload avsync stats artifact
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: avsync-stats-${{ matrix.integration_type }}
path: /tmp/avsync-stats.json
stats:
needs: test
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Download avsync stats artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: avsync-stats-*
path: stats/
- name: Render avsync summary
run: .github/scripts/render-avsync-stats.sh stats/*/avsync-stats.json >> "$GITHUB_STEP_SUMMARY"
- name: Post/update PR comment with summary link
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
marker='<!-- avsync-stats-comment -->'
body="${marker}"$'\n'"AV-sync stats summary: [view in run #${{ github.run_id }}](${RUN_URL})"
existing=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" \
--paginate --jq ".[] | select(.body | contains(\"${marker}\")) | .id" | head -1)
if [ -n "$existing" ]; then
gh api --method PATCH "repos/${REPO}/issues/comments/${existing}" -f body="$body"
else
gh api --method POST "repos/${REPO}/issues/${PR_NUMBER}/comments" -f body="$body"
fi