From 274896f40cc2f23c6127565d625993413bcc2964 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 10 Jun 2025 10:10:08 -0400 Subject: [PATCH 1/7] Update --- .github/{workflows => docker}/Dockerfile | 0 .github/{workflows => scripts}/format-patch.sh | 0 .github/workflows/fate-cache.yml | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename .github/{workflows => docker}/Dockerfile (100%) rename .github/{workflows => scripts}/format-patch.sh (100%) diff --git a/.github/workflows/Dockerfile b/.github/docker/Dockerfile similarity index 100% rename from .github/workflows/Dockerfile rename to .github/docker/Dockerfile diff --git a/.github/workflows/format-patch.sh b/.github/scripts/format-patch.sh similarity index 100% rename from .github/workflows/format-patch.sh rename to .github/scripts/format-patch.sh diff --git a/.github/workflows/fate-cache.yml b/.github/workflows/fate-cache.yml index f8abc46ccf777..77ea32e3f3f4e 100644 --- a/.github/workflows/fate-cache.yml +++ b/.github/workflows/fate-cache.yml @@ -19,7 +19,7 @@ jobs: - name: Build FFmpeg Fate Cache run: | set -euxo pipefail - docker build -t ossrs/srs:ffmpeg-fate -f .github/workflows/Dockerfile . + docker build -t ossrs/srs:ffmpeg-fate -f .github/docker/Dockerfile . - name: Push FFmpeg Fate Cache run: | set -euxo pipefail diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ace9519b88258..42a46a91defdf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -676,7 +676,7 @@ jobs: echo "Patch file is $PATCH_FILENAME.patch" echo "Temporary branch is $TMP_BRANCH" - bash .github/workflows/format-patch.sh $PR_NUMBER "$PATCH_FILENAME.patch" + bash .github/scripts/format-patch.sh $PR_NUMBER "$PATCH_FILENAME.patch" echo "patch_file=$PATCH_FILENAME" >> $GITHUB_OUTPUT echo "temporary_branch=$TMP_BRANCH" >> $GITHUB_OUTPUT - name: Show Branch Info From 448362b474458441834bd2ff7bab0cbd03268abd Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 10 Jun 2025 10:12:36 -0400 Subject: [PATCH 2/7] Update --- libavformat/whip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5ab97..d493c064ac008 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1902,6 +1902,7 @@ static const AVClass whip_muxer_class = { .version = LIBAVUTIL_VERSION_INT, }; +// TODO: FIXME: For test. const FFOutputFormat ff_whip_muxer = { .p.name = "whip", .p.long_name = NULL_IF_CONFIG_SMALL("WHIP(WebRTC-HTTP ingestion protocol) muxer"), From 8776d48373dbe4ef72db29c475acfbc09fa57388 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 10 Jun 2025 10:17:35 -0400 Subject: [PATCH 3/7] Update --- .github/scripts/format-patch.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/scripts/format-patch.sh b/.github/scripts/format-patch.sh index 5e80d8c5cc0ea..20d6235bcac08 100755 --- a/.github/scripts/format-patch.sh +++ b/.github/scripts/format-patch.sh @@ -131,6 +131,22 @@ fi git rebase workflows && git reset --soft workflows && +echo "Rebased onto workflows branch and reset to soft." +if [[ $? -ne 0 ]]; then + echo "Failed to rebase or reset changes." + exit 1 +fi + +git status && +git restore --staged .github && +git restore .github && +git status && +echo "Restored .github directory to the state of workflows branch." +if [[ $? -ne 0 ]]; then + echo "Failed to restore .github directory." + exit 1 +fi + git commit --author "$FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -m "$(echo -e "$COMMIT_MSG")" && echo "Squashed commits into a single commit." if [[ $? -ne 0 ]]; then From 67ab8f3a8872d5061da78427eb27f82d6e88df2c Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 10 Jun 2025 10:21:52 -0400 Subject: [PATCH 4/7] Update --- .github/scripts/format-patch.sh | 96 +++++++++++++++++---------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/.github/scripts/format-patch.sh b/.github/scripts/format-patch.sh index 20d6235bcac08..b5ec6b9b165ce 100755 --- a/.github/scripts/format-patch.sh +++ b/.github/scripts/format-patch.sh @@ -1,11 +1,13 @@ #!/bin/bash +LOGPREFIX=">>" + if [[ $(jq --version 1>/dev/null 2>&1 && echo yes) != "yes" ]]; then - echo "Tool jq is not installed. Please install it to parse JSON data. For example:" - echo " apt install jq" - echo " brew install jq" - echo " yum install jq" - echo "See https://github.com/jqlang/jq" + echo "${LOGPREFIX} Tool jq is not installed. Please install it to parse JSON data. For example:" + echo "${LOGPREFIX} apt install jq" + echo "${LOGPREFIX} brew install jq" + echo "${LOGPREFIX} yum install jq" + echo "${LOGPREFIX} See https://github.com/jqlang/jq" exit 1 fi @@ -13,7 +15,7 @@ PR_NUMBER="$1" PATCH_FILE="$2" TMP_BRANCH="$3" if [ -z "$PR_NUMBER" ]; then - echo "Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20" + echo "${LOGPREFIX} Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20" exit 1 fi @@ -22,41 +24,41 @@ if [[ "$1" =~ ^https://github.com/ossrs/ffmpeg-webrtc/pull/([0-9]+)$ ]]; then elif [[ "$1" =~ ^[0-9]+$ ]]; then PR_NUMBER="$1" else - echo "Invalid input format. Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20" + echo "${LOGPREFIX} Invalid input format. Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20" exit 1 fi PR_URL="https://github.com/ossrs/ffmpeg-webrtc/pull/$PR_NUMBER" -echo "Fetching PR #$PR_NUMBER from $PR_URL" +echo "${LOGPREFIX} Fetching PR #$PR_NUMBER from $PR_URL" PR_DATA=$(curl -s "https://api.github.com/repos/ossrs/ffmpeg-webrtc/pulls/$PR_NUMBER") REPO_NAME=$(printf '%s' "$PR_DATA" | jq -r '.head.repo.full_name') BRANCH_NAME=$(printf '%s' "$PR_DATA" | jq -r '.head.ref') -echo "Repository: $REPO_NAME, Branch: $BRANCH_NAME" +echo "${LOGPREFIX} Repository: $REPO_NAME, Branch: $BRANCH_NAME" if [[ -z "$REPO_NAME" || -z "$BRANCH_NAME" ]]; then - echo "Error: REPO_NAME or BRANCH_NAME is empty!" + echo "${LOGPREFIX} Error: REPO_NAME or BRANCH_NAME is empty!" exit 1 fi PR_TITLE=$(printf '%s' "$PR_DATA" | jq -r '.title') PR_DESCRIPTION=$(printf '%s' "$PR_DATA" | jq -r '.body // ""') -echo "PR information:" -echo "===================================================================" -echo "$PR_TITLE" -echo "$PR_DESCRIPTION" -echo "===================================================================" -echo "" +echo "${LOGPREFIX} PR information:" +echo "${LOGPREFIX} ===================================================================" +echo "${LOGPREFIX} $PR_TITLE" +echo "${LOGPREFIX} $PR_DESCRIPTION" +echo "${LOGPREFIX} ===================================================================" +echo "${LOGPREFIX} " if [[ -z "$PR_TITLE" ]]; then - echo "Error: PR title is empty!" + echo "${LOGPREFIX} Error: PR title is empty!" exit 1 fi git checkout workflows && -echo "Switched to workflows branch." && +echo "${LOGPREFIX} Switched to workflows branch." && git pull && -echo "Pulled latest changes from workflows branch." +echo "${LOGPREFIX} Pulled latest changes from workflows branch." if [[ $? -ne 0 ]]; then - echo "Failed to switch to workflows branch or pull latest changes." + echo "${LOGPREFIX} Failed to switch to workflows branch or pull latest changes." exit 1 fi @@ -66,9 +68,9 @@ if git remote | grep -q "^$REMOTE_NAME$"; then fi && git remote add $REMOTE_NAME https://github.com/${REPO_NAME}.git && git fetch $REMOTE_NAME $BRANCH_NAME && -echo "Fetch remote $REMOTE_NAME at $(git remote get-url $REMOTE_NAME)" +echo "${LOGPREFIX} Fetch remote $REMOTE_NAME at $(git remote get-url $REMOTE_NAME)" if [[ $? -ne 0 ]]; then - echo "Failed to fetch remote branch $BRANCH_NAME from $REMOTE_NAME." + echo "${LOGPREFIX} Failed to fetch remote branch $BRANCH_NAME from $REMOTE_NAME." exit 1 fi @@ -79,24 +81,24 @@ if git branch --list "$TMP_BRANCH" | grep -q "^..$TMP_BRANCH$"; then git branch -D "$TMP_BRANCH" fi && git checkout -b $TMP_BRANCH $REMOTE_NAME/$BRANCH_NAME && -echo "Checkout branch $TMP_BRANCH from $REMOTE_NAME/$BRANCH_NAME" +echo "${LOGPREFIX} Checkout branch $TMP_BRANCH from $REMOTE_NAME/$BRANCH_NAME" if [[ $? -ne 0 ]]; then - echo "Failed to checkout branch $TMP_BRANCH from $REMOTE_NAME/$BRANCH_NAME." + echo "${LOGPREFIX} Failed to checkout branch $TMP_BRANCH from $REMOTE_NAME/$BRANCH_NAME." exit 1 fi FIRST_AUTHOR_NAME=$(git log workflows..HEAD --reverse --format='%an' | head -n1) FIRST_AUTHOR_EMAIL=$(git log workflows..HEAD --reverse --format='%ae' | head -n1) -echo "Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" +echo "${LOGPREFIX} Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" if [[ -z "$FIRST_AUTHOR_NAME" || -z "$FIRST_AUTHOR_EMAIL" ]]; then - echo "Error: Unable to determine the first author of the PR." + echo "${LOGPREFIX} Error: Unable to determine the first author of the PR." exit 1 fi COAUTHORS=$(git log workflows..HEAD --format='Co-authored-by: %an <%ae>' |grep -v "$FIRST_AUTHOR_NAME" | sort -u) COAUTHOR_COUNT=$(echo "$COAUTHORS" | wc -l) if [[ "$COAUTHOR_COUNT" -gt 0 ]]; then - echo "$COAUTHORS" + echo "${LOGPREFIX} $COAUTHORS" fi COMMIT_MSG="$PR_TITLE" @@ -109,12 +111,12 @@ if [[ "$COAUTHOR_COUNT" -gt 0 ]]; then COMMIT_MSG="$COMMIT_MSG\n$COAUTHORS" fi -echo "Commit information:" -echo "Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -echo "===================================================================" +echo "${LOGPREFIX} Commit information:" +echo "${LOGPREFIX} Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" +echo "${LOGPREFIX} ===================================================================" echo -e "$COMMIT_MSG" -echo "===================================================================" -echo "" +echo "${LOGPREFIX} ===================================================================" +echo "${LOGPREFIX} " if [[ $(git config --list --local |grep 'user.name' >/dev/null 2>&1 && echo yes) != "yes" ]]; then git config --local user.name "$FIRST_AUTHOR_NAME" @@ -123,17 +125,17 @@ if [[ $(git config --list --local |grep 'user.email' >/dev/null 2>&1 && echo ye git config --local user.email "$FIRST_AUTHOR_EMAIL" fi && git config --list && -echo "Set local git user configuration to: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" +echo "${LOGPREFIX} Set local git user configuration to: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" if [[ $? -ne 0 ]]; then - echo "Failed to set local git user configuration." + echo "${LOGPREFIX} Failed to set local git user configuration." exit 1 fi git rebase workflows && git reset --soft workflows && -echo "Rebased onto workflows branch and reset to soft." +echo "${LOGPREFIX} Rebased onto workflows branch and reset to soft." if [[ $? -ne 0 ]]; then - echo "Failed to rebase or reset changes." + echo "${LOGPREFIX} Failed to rebase or reset changes." exit 1 fi @@ -141,23 +143,23 @@ git status && git restore --staged .github && git restore .github && git status && -echo "Restored .github directory to the state of workflows branch." +echo "${LOGPREFIX} Restored .github directory to the state of workflows branch." if [[ $? -ne 0 ]]; then - echo "Failed to restore .github directory." + echo "${LOGPREFIX} Failed to restore .github directory." exit 1 fi git commit --author "$FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -m "$(echo -e "$COMMIT_MSG")" && -echo "Squashed commits into a single commit." +echo "${LOGPREFIX} Squashed commits into a single commit." if [[ $? -ne 0 ]]; then - echo "Failed to rebase or commit changes." + echo "${LOGPREFIX} Failed to rebase or commit changes." exit 1 fi git branch -vv && git log -1 --pretty=format:"%an <%ae> %h %s" if [[ $? -ne 0 ]]; then - echo "Failed to display branch information or last commit." + echo "${LOGPREFIX} Failed to display branch information or last commit." exit 1 fi @@ -166,16 +168,16 @@ if [[ -z "$PATCH_FILE" ]]; then fi && rm -f $PATCH_FILE && git format-patch --add-header "X-Unsent: 1" --to ffmpeg-devel@ffmpeg.org -1 --stdout > $PATCH_FILE && -echo "Created patch file: $PATCH_FILE" +echo "${LOGPREFIX} Created patch file: $PATCH_FILE" if [[ $? -ne 0 ]]; then - echo "Failed to create patch file." + echo "${LOGPREFIX} Failed to create patch file." exit 1 fi git checkout workflows #git br -D $TMP_BRANCH -#echo "Removed temporary branch $TMP_BRANCH." +#echo "${LOGPREFIX} Removed temporary branch $TMP_BRANCH." -echo "" -echo "Patch file created: $PATCH_FILE" -echo "" +echo "${LOGPREFIX} " +echo "${LOGPREFIX} Patch file created: $PATCH_FILE" +echo "${LOGPREFIX} " From c7f608e451778dc3fdd6d4ece01eb1effbe245ae Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 10 Jun 2025 10:24:09 -0400 Subject: [PATCH 5/7] Update --- libavformat/whip.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index d493c064ac008..710f24fc5ab97 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1902,7 +1902,6 @@ static const AVClass whip_muxer_class = { .version = LIBAVUTIL_VERSION_INT, }; -// TODO: FIXME: For test. const FFOutputFormat ff_whip_muxer = { .p.name = "whip", .p.long_name = NULL_IF_CONFIG_SMALL("WHIP(WebRTC-HTTP ingestion protocol) muxer"), From b4d820c9788c734a5c495ae04d3ecbe41e86723c Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 10 Jun 2025 10:31:07 -0400 Subject: [PATCH 6/7] Update --- .github/scripts/format-patch.sh | 6 ++++++ .github/workflows/test.yml | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/.github/scripts/format-patch.sh b/.github/scripts/format-patch.sh index b5ec6b9b165ce..3b56e701a652e 100755 --- a/.github/scripts/format-patch.sh +++ b/.github/scripts/format-patch.sh @@ -149,6 +149,12 @@ if [[ $? -ne 0 ]]; then exit 1 fi +if [[ $(git status | grep 'nothing to commit, working tree clean' >/dev/null 2>&1 && echo yes) == "yes" ]]; then + echo "${LOGPREFIX} No changes to commit. Exiting." + git checkout workflows + exit 0 +fi + git commit --author "$FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -m "$(echo -e "$COMMIT_MSG")" && echo "${LOGPREFIX} Squashed commits into a single commit." if [[ $? -ne 0 ]]; then diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42a46a91defdf..33c8322fafbfe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -679,11 +679,19 @@ jobs: bash .github/scripts/format-patch.sh $PR_NUMBER "$PATCH_FILENAME.patch" echo "patch_file=$PATCH_FILENAME" >> $GITHUB_OUTPUT echo "temporary_branch=$TMP_BRANCH" >> $GITHUB_OUTPUT + + if [[ -f "$PATCH_FILENAME.patch" ]]; then + echo "has_patch=true" >> $GITHUB_OUTPUT + fi + - name: Show Branch Info + if: ${{ steps.format_patch.outputs.has_patch == 'true' }} run: git show ${{ steps.format_patch.outputs.temporary_branch }} - name: Show Patch File + if: ${{ steps.format_patch.outputs.has_patch == 'true' }} run: cat ${{ steps.format_patch.outputs.patch_file }}.patch - name: Upload all patch files + if: ${{ steps.format_patch.outputs.has_patch == 'true' }} uses: actions/upload-artifact@v4 with: name: ${{ steps.format_patch.outputs.patch_file }} From 1befaa9a7c980273ed0070bece7096e04d0fd634 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 10 Jun 2025 10:33:44 -0400 Subject: [PATCH 7/7] Update --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 33c8322fafbfe..397d9c69390a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -682,8 +682,9 @@ jobs: if [[ -f "$PATCH_FILENAME.patch" ]]; then echo "has_patch=true" >> $GITHUB_OUTPUT + else + echo "has_patch=false" >> $GITHUB_OUTPUT fi - - name: Show Branch Info if: ${{ steps.format_patch.outputs.has_patch == 'true' }} run: git show ${{ steps.format_patch.outputs.temporary_branch }}