Skip to content

Commit aa84960

Browse files
committed
CICD: Add workflow for WHIP.
1 parent 17729aa commit aa84960

File tree

5 files changed

+586
-0
lines changed

5 files changed

+586
-0
lines changed

.github/workflows/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# docker build -t ossrs/srs:ffmpeg-fate
2+
# docker push ossrs/srs:ffmpeg-fate
3+
FROM ubuntu:22.04
4+
5+
RUN apt-get update && \
6+
apt-get install -y build-essential git rsync make nasm pkg-config libssl-dev &&\
7+
rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /opt
10+
RUN git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
11+
12+
WORKDIR /opt/ffmpeg
13+
RUN ./configure --enable-openssl --enable-version3
14+
RUN make -j$(nproc)
15+
16+
RUN make fate-rsync SAMPLES=/opt/ffmpeg/fate-suite
17+
RUN du -sh /opt/ffmpeg/fate-suite
18+
19+
# Note that you should use the fate-suite.tar, then extract it out of
20+
# docker, to avoid resync all files.
21+
RUN tar cf fate-suite.tar fate-suite
22+
RUN du -sh /opt/ffmpeg/fate-suite.tar
23+
24+
ENV FATE_SAMPLES=/opt/ffmpeg/fate-suite

.github/workflows/fate-cache.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "FFmpeg FATE Cache"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions: read-all
7+
8+
jobs:
9+
build:
10+
name: "Build FFmpeg Fate Cache"
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Login to docker hub
15+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
16+
with:
17+
username: "${{ secrets.DOCKER_USERNAME }}"
18+
password: "${{ secrets.DOCKER_PASSWORD }}"
19+
- name: Build FFmpeg Fate Cache
20+
run: |
21+
set -euxo pipefail
22+
docker build -t ossrs/srs:ffmpeg-fate -f .github/workflows/Dockerfile .
23+
- name: Push FFmpeg Fate Cache
24+
run: |
25+
set -euxo pipefail
26+
docker push ossrs/srs:ffmpeg-fate
27+
runs-on: ubuntu-22.04

.github/workflows/format-patch.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/bash
2+
3+
if [[ $(jq --version 1>/dev/null 2>&1 && echo yes) != "yes" ]]; then
4+
echo "Tool jq is not installed. Please install it to parse JSON data. For example:"
5+
echo " apt install jq"
6+
echo " brew install jq"
7+
echo " yum install jq"
8+
echo "See https://github.com/jqlang/jq"
9+
exit 1
10+
fi
11+
12+
if [ -z "$1" ]; then
13+
echo "Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20"
14+
exit 1
15+
fi
16+
17+
if [[ "$1" =~ ^https://github.com/ossrs/ffmpeg-webrtc/pull/([0-9]+)$ ]]; then
18+
PR_NUMBER="${BASH_REMATCH[1]}"
19+
elif [[ "$1" =~ ^[0-9]+$ ]]; then
20+
PR_NUMBER="$1"
21+
else
22+
echo "Invalid input format. Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20"
23+
exit 1
24+
fi
25+
26+
PR_URL="https://github.com/ossrs/ffmpeg-webrtc/pull/$PR_NUMBER"
27+
echo "Fetching PR #$PR_NUMBER from $PR_URL"
28+
29+
PR_DATA=$(curl -s "https://api.github.com/repos/ossrs/ffmpeg-webrtc/pulls/$PR_NUMBER")
30+
REPO_NAME=$(echo "$PR_DATA" | jq -r '.head.repo.full_name')
31+
BRANCH_NAME=$(echo "$PR_DATA" | jq -r '.head.ref')
32+
if [[ -z "$REPO_NAME" || -z "$BRANCH_NAME" ]]; then
33+
echo "Error: REPO_NAME or BRANCH_NAME is empty!"
34+
exit 1
35+
fi
36+
echo "Repository: $REPO_NAME, Branch: $BRANCH_NAME"
37+
38+
PR_TITLE=$(echo "$PR_DATA" | jq -r '.title')
39+
PR_DESCRIPTION=$(echo "$PR_DATA" | jq -r '.body // ""')
40+
if [[ -z "$PR_TITLE" ]]; then
41+
echo "Error: PR title is empty!"
42+
exit 1
43+
fi
44+
45+
echo "PR information:"
46+
echo "==================================================================="
47+
echo "$PR_TITLE"
48+
echo "$PR_DESCRIPTION"
49+
echo "==================================================================="
50+
echo ""
51+
52+
set -euxo pipefail
53+
54+
git checkout workflows
55+
echo "Switched to workflows branch."
56+
57+
git pull
58+
echo "Pulled latest changes from workflows branch."
59+
60+
REMOTE_NAME=patch-tmp
61+
if git remote | grep -q "^$REMOTE_NAME$"; then
62+
git remote rm "$REMOTE_NAME"
63+
fi
64+
git remote add $REMOTE_NAME https://github.com/${REPO_NAME}.git
65+
git fetch $REMOTE_NAME $BRANCH_NAME
66+
echo "Fetch remote $REMOTE_NAME at $(git remote get-url $REMOTE_NAME)"
67+
68+
TMP_BRANCH=tmp-branch-for-patch-$PR_NUMBER
69+
if git branch --list "$TMP_BRANCH" | grep -q "^..$TMP_BRANCH$"; then
70+
git branch -D "$TMP_BRANCH"
71+
fi
72+
git checkout -b $TMP_BRANCH $REMOTE_NAME/$BRANCH_NAME
73+
echo "Checkout branch $TMP_BRANCH from $REMOTE_NAME/$BRANCH_NAME"
74+
75+
FIRST_AUTHOR_NAME=$(git log workflows..HEAD --reverse --format='%an' | head -n1)
76+
FIRST_AUTHOR_EMAIL=$(git log workflows..HEAD --reverse --format='%ae' | head -n1)
77+
echo "Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>"
78+
79+
COAUTHORS=$(git log workflows..HEAD --format='Co-authored-by: %an <%ae>' |grep -v "$FIRST_AUTHOR_NAME" | sort -u)
80+
COAUTHOR_COUNT=$(echo "$COAUTHORS" | wc -l)
81+
if [ "$COAUTHOR_COUNT" -gt 0 ]; then
82+
echo "$COAUTHORS"
83+
fi
84+
85+
COMMIT_MSG="$PR_TITLE"
86+
if [ -n "$PR_DESCRIPTION" ]; then
87+
COMMIT_MSG="$COMMIT_MSG\n\n$PR_DESCRIPTION"
88+
fi
89+
90+
if [ "$COAUTHOR_COUNT" -gt 0 ]; then
91+
COMMIT_MSG="$COMMIT_MSG\n"
92+
COMMIT_MSG="$COMMIT_MSG\n$COAUTHORS"
93+
fi
94+
95+
echo "Commit information:"
96+
echo "Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>"
97+
echo "==================================================================="
98+
echo -e "$COMMIT_MSG"
99+
echo "==================================================================="
100+
echo ""
101+
102+
git rebase workflows
103+
git reset --soft workflows
104+
git commit --author "$FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -m "$(echo -e "$COMMIT_MSG")"
105+
echo "Squashed commits into a single commit."
106+
git log -1 --pretty=format:"%an <%ae> %h %s"
107+
108+
PATCH_FILE="patch-$PR_NUMBER-$(date +%s).patch"
109+
rm -f $PATCH_FILE
110+
git format-patch -1 --stdout > $PATCH_FILE
111+
112+
git checkout workflows
113+
#git br -D $TMP_BRANCH
114+
#echo "Removed temporary branch $TMP_BRANCH."
115+
116+
set +e +u +x +o pipefail
117+
118+
echo ""
119+
echo "Patch file created: $PATCH_FILE"
120+
echo ""

0 commit comments

Comments
 (0)