Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncing with the main #1

Merged
merged 21 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
825b3e2
core: Rename 'InArray' to 'HasCapability' (#3118)
j0sh Aug 7, 2024
448206a
livepeer: add a `-hevcDecoding` flag (#3119)
j0sh Aug 8, 2024
02773f5
workflows: Update build workflow to not rely on curl based upload (#3…
hjpotter92 Aug 12, 2024
40207ba
workflows: Fix issue when github context is empty for merged commits …
hjpotter92 Aug 14, 2024
c312f61
discord-embed: Add log statements
hjpotter92 Aug 14, 2024
82c9eca
workflows: Revert to ubuntu-20 to stop selecting self-hosted runners …
hjpotter92 Aug 16, 2024
6e90491
lpms: Update to 9d6ea5f (#3144)
j0sh Aug 19, 2024
84d88af
release v0.7.7 (#3145)
j0sh Aug 19, 2024
45591da
Add flag 'ignoreMaxPriceIfNeeded' (#3127)
leszko Aug 20, 2024
8b4050d
build.yaml: Fix extraction of artifacts when preparing for release (#…
hjpotter92 Aug 20, 2024
e27bb64
releases.yaml: Flatten from inside releases directory
hjpotter92 Aug 20, 2024
eb2463f
release: v0.7.8 (#3151)
hjpotter92 Aug 21, 2024
2e55134
Add a metric tag for Orchestrator version (#3158)
mjh1 Sep 2, 2024
384b703
build.yaml: Skip upload step raising an error for PR from forks (#3162)
hjpotter92 Sep 5, 2024
48a92a1
validate `-serviceAddr` on startup and cli handler (#3156)
eliteprox Sep 5, 2024
a99a631
broadcaster: Fix media compatibility check (#3164)
j0sh Sep 9, 2024
eec6ed3
Add node version and orch addr to transcoded metadata (#3165)
j0sh Sep 9, 2024
45652c4
Clean up inactive sessions (#3166)
leszko Sep 10, 2024
834a9c6
selection: Clear known sessions if none of them has good enough laten…
leszko Sep 10, 2024
56a8a88
release v0.7.9 (#3167)
j0sh Sep 10, 2024
81bc9e5
feat: enable changing GetOrchestrator discovery timeout (#3150)
ad-astra-video Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/discord-embed-webhook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import argparse
import os
import json
import pathlib
from typing import Any

from requests import Response
from discord_webhook import DiscordEmbed, DiscordWebhook


GITHUB_CONTEXT_JSON = os.environ.get("GITHUB_CONTEXT_JSON", "{}")
DOWNLOAD_BASE_URL_TEMPLATE = (
"https://build.livepeer.live/go-livepeer/{version}/{filename}"
)


def get_github_context_vars(context: dict[str, Any]) -> dict[str, str]:
context_vars = {}
event: dict[str, Any] = context["event"]
if context.get("event_name") == "pull_request":
pull_request_context: dict[str, Any] = event["pull_request"]
head = pull_request_context.get("head", {})
repo = head.get("repo", {})
sha = head.get("sha")
context_vars["title"] = head.get("ref")
context_vars["sha"] = sha
context_vars["commit_url"] = f'{repo.get("html_url")}/commit/{sha}'
elif context.get("event_name") == "push":
sha = event["after"]
context_vars["title"] = context["ref_name"]
context_vars["sha"] = sha
context_vars["commit_url"] = event["compare"]
return context_vars


def populate_embeds(embed: DiscordEmbed, ref_name: str, checksums: list[str]):
for line in checksums:
_, filename = line.split()
download_url = DOWNLOAD_BASE_URL_TEMPLATE.format(
version=ref_name,
filename=filename,
)
title = filename.removeprefix("livepeer-").split(".")[0]
print(f"Adding embed field name={title} value={download_url}")
embed.add_embed_field(name=title, value=download_url, inline=False)


def main(args):
checksums = []
github_context: dict[str, Any] = json.loads(GITHUB_CONTEXT_JSON)
context_vars = get_github_context_vars(github_context)
checksums_file = pathlib.Path("releases") / f"{args.ref_name}_checksums.txt"
checksums = checksums_file.read_text().splitlines()
webhook = DiscordWebhook(
url=args.discord_url,
content=":white_check_mark: Build succeeded for go-livepeer :white_check_mark:",
username="[BOT] Livepeer builder",
)
webhook.add_file(filename=checksums_file.name, file=checksums_file.read_bytes())
embed = DiscordEmbed(
title=context_vars.get("title"),
description=args.git_commit,
color=2928914,
url=context_vars.get("commit_url"),
)
embed.add_embed_field(name="Commit SHA", value=context_vars.get("sha"))
embed.set_author(name=args.git_committer)
populate_embeds(embed, args.ref_name, checksums)
embed.set_timestamp()
webhook.add_embed(embed)
response: Response = webhook.execute()
print("sending webhook with content:")
print(webhook.json)
# Fail the script if discord returns anything except OK status
assert (
response.ok
), f"Discord webhook failed {response.status_code} {response.content}"


if __name__ == "__main__":
parser = argparse.ArgumentParser("Discord embed content generator for build system")
parser.add_argument("--discord-url", help="Discord webhook URL")
parser.add_argument("--ref-name", help="Tag/branch/commit for current build")
parser.add_argument("--git-commit", help="git commit message")
parser.add_argument("--git-committer", help="git commit author name")
args = parser.parse_args()
main(args)
1 change: 1 addition & 0 deletions .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
discord-webhook
130 changes: 79 additions & 51 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
jobs:
linux-build:
name: Build binaries for ${{ matrix.target.GOOS }}-${{ matrix.target.type }}-${{ matrix.target.GOARCH }}
runs-on: ${{ matrix.target.runner }}
runs-on: ubuntu-20.04
container:
image: ${{ matrix.target.container }}
env:
Expand All @@ -26,31 +26,26 @@ jobs:
target:
- GOOS: linux
GOARCH: amd64
runner: ubuntu-20.04
container: ubuntu:20.04
type: cpu

- GOOS: linux
GOARCH: arm64
runner: ubuntu-20.04
container: ubuntu:20.04
type: cpu

- GOOS: linux
GOARCH: amd64
runner: ubuntu-20.04
container: livepeerci/cuda:12.0.0-cudnn8-devel-ubuntu20.04
type: gpu

- GOOS: linux
GOARCH: arm64
runner: ubuntu-20.04
container: livepeerci/cuda:12.0.0-cudnn8-devel-ubuntu20.04
type: gpu

- GOOS: windows
GOARCH: amd64
runner: ubuntu-20.04
container: ubuntu:22.04
type: cpu

Expand All @@ -63,7 +58,7 @@ jobs:
apt update && apt install -yqq git zip unzip zlib1g-dev zlib1g yasm

- name: Check out code
uses: actions/[email protected].1
uses: actions/[email protected].7
with:
fetch-depth: 0
# Check https://github.com/livepeer/go-livepeer/pull/1891
Expand All @@ -78,19 +73,14 @@ jobs:
cache: true
cache-dependency-path: go.sum

- name: Cache ffmpeg
id: cache-ffmpeg
uses: actions/cache@v3
with:
path: /home/runner/compiled
key: ${{ runner.os }}-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}-${{ matrix.target.type }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }}

- name: Set build environment
run: |
echo "GOARCH=${{ matrix.target.GOARCH }}" >> $GITHUB_ENV
echo "GOOS=${{ matrix.target.GOOS }}" >> $GITHUB_ENV
echo "GO_BUILD_DIR=lp-builds/" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/github/home/compiled/lib/pkgconfig" >> $GITHUB_ENV
echo "LP_BUILD_DIR=livepeer-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}" >> $GITHUB_ENV
mkdir -p lp-builds/ releases/

- name: Set GPU build environment
if: matrix.target.type == 'gpu'
Expand All @@ -99,6 +89,7 @@ jobs:
echo "LIBRARY_PATH=/usr/local/cuda_${{ matrix.target.GOARCH }}/lib64" >> $GITHUB_ENV
echo "CGO_LDFLAGS=-L/usr/local/cuda_${{ matrix.target.GOARCH }}/lib64" >> $GITHUB_ENV
echo "RELEASE_TAG=gpu" >> $GITHUB_ENV
echo "LP_BUILD_DIR=livepeer-${{ matrix.target.GOOS }}-gpu-${{ matrix.target.GOARCH }}" >> $GITHUB_ENV

- name: Install dependencies
run: |
Expand All @@ -120,7 +111,6 @@ jobs:
run: go mod download

- name: Install ffmpeg
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: ./install_ffmpeg.sh

- name: Build binaries
Expand All @@ -130,24 +120,28 @@ jobs:
git config --global --add safe.directory '*'
./ci_env.sh make

- name: Upload build
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
env:
GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }}
GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }}
DISCORD_URL: ${{ secrets.DISCORD_URL }}
run: ./upload_build.sh
- name: Archive binaries for windows
if: matrix.target.GOOS == 'windows'
run: |
mkdir -p "${GO_BUILD_DIR}/${LP_BUILD_DIR}/"
cd "$GO_BUILD_DIR/"
find . -type f -exec mv '{}' "$LP_BUILD_DIR/" \;
zip -9rq "../releases/$LP_BUILD_DIR.zip" ./

- name: Archive binaries
if: matrix.target.GOOS != 'windows'
run: |
mkdir -p "${GO_BUILD_DIR}/${LP_BUILD_DIR}/"
cd "$GO_BUILD_DIR/"
find . -type f -exec mv '{}' "$LP_BUILD_DIR" \;
tar -czvf "../releases/$LP_BUILD_DIR.tar.gz" ./

- name: Upload artifacts for cutting release
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: release-artifacts
name: release-artifacts-${{ matrix.target.GOOS }}-${{ matrix.target.type }}-${{ matrix.target.GOARCH }}
path: releases/

- name: Notify new build upload
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev

macos-build:
name: Build binaries for ${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}
runs-on: ${{ matrix.target.runner }}
Expand All @@ -161,11 +155,11 @@ jobs:

- GOOS: darwin
GOARCH: arm64
runner: macos-latest
runner: macos-14-xlarge

steps:
- name: Check out code
uses: actions/[email protected].1
uses: actions/[email protected].7
with:
fetch-depth: 0
# Check https://github.com/livepeer/go-livepeer/pull/1891
Expand All @@ -185,10 +179,12 @@ jobs:
echo "GOARCH=${{ matrix.target.GOARCH }}" >> $GITHUB_ENV
echo "GOOS=${{ matrix.target.GOOS }}" >> $GITHUB_ENV
echo "GO_BUILD_DIR=lp-builds/" >> $GITHUB_ENV
echo "LP_BUILD_DIR=livepeer-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}" >> $GITHUB_ENV
mkdir -p lp-builds/ releases/

- name: Cache ffmpeg
id: cache-ffmpeg
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/compiled
key: ${{ runner.os }}-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }}
Expand Down Expand Up @@ -230,45 +226,60 @@ jobs:
app-notarization-team-id: ${{ secrets.CI_MACOS_NOTARIZATION_TEAM_ID }}
binary-path: "lp-builds/"

- name: Upload build
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
env:
GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }}
GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }}
DISCORD_URL: ${{ secrets.DISCORD_URL }}
run: ./upload_build.sh
- name: Archive binaries
if: matrix.platform.name != 'windows'
run: |
mkdir -p "${GO_BUILD_DIR}/${LP_BUILD_DIR}/"
cd "$GO_BUILD_DIR/"
find . -type f -exec mv '{}' "$LP_BUILD_DIR" \;
tar -czvf "../releases/${LP_BUILD_DIR}.tar.gz" .

- name: Upload artifacts for cutting release
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: release-artifacts
name: release-artifacts-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}
path: releases/

- name: Notify new build upload
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev

upload:
name: Upload artifacts to google bucket
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs:
- macos-build
- linux-build
steps:
- name: Check out code
uses: actions/[email protected]
with:
fetch-depth: 0
# Check https://github.com/livepeer/go-livepeer/pull/1891
# for ref value discussion
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up python
id: python
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: pip
cache-dependency-path: .github/requirements.txt
update-environment: true

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: release-artifacts
pattern: release-artifacts-*
path: releases/
merge-multiple: true

- name: Generate sha256 checksum and gpg signatures for release artifacts
uses: livepeer/action-gh-checksum-and-gpg-sign@latest
with:
artifacts-dir: releases
release-name: ${{ (github.ref_type == 'tag' && github.ref_name) || github.sha }}
release-name: ${{ (github.ref_type == 'tag' && github.ref_name) || (github.event.pull_request.head.sha || github.sha) }}
gpg-key: ${{ secrets.CI_GPG_SIGNING_KEY }}
gpg-key-passphrase: ${{ secrets.CI_GPG_SIGNING_PASSPHRASE }}

Expand All @@ -289,16 +300,33 @@ jobs:

- name: Upload release archives to Google Cloud
id: upload-archives
uses: google-github-actions/upload-cloud-storage@v1
uses: google-github-actions/upload-cloud-storage@v2
with:
path: "releases"
destination: "build.livepeer.live/${{ github.event.repository.name }}/${{ (github.ref_type == 'tag' && github.ref_name) || github.sha }}"
destination: "build.livepeer.live/${{ github.event.repository.name }}/${{ (github.ref_type == 'tag' && github.ref_name) || (github.event.pull_request.head.sha || github.sha) }}"
parent: false
process_gcloudignore: false

- name: Upload branch manifest file
id: upload-manifest
uses: google-github-actions/upload-cloud-storage@v1
uses: google-github-actions/upload-cloud-storage@v2
with:
path: ${{ steps.branch-manifest.outputs.manifest-file }}
destination: "build.livepeer.live/${{ github.event.repository.name }}/"
parent: false
process_gcloudignore: false

- name: Trigger discord webhook
shell: bash
env:
GITHUB_CONTEXT_JSON: ${{ toJson(github) }}
run: |
pip install -r .github/requirements.txt
python .github/discord-embed-webhook.py \
--ref-name="${{ (github.ref_type == 'tag' && github.ref_name) || (github.event.pull_request.head.sha || github.sha) }}" \
--discord-url="${{ secrets.DISCORD_URL }}" \
--git-commit="$(git log -1 --pretty=format:'%s')" \
--git-committer="$(git log -1 --pretty=format:'%an')"

- name: Notify new build upload
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: oxford
steps:
- name: Check out code
uses: actions/[email protected].1
uses: actions/[email protected].7
with:
fetch-depth: 0
# Check https://github.com/livepeer/go-livepeer/pull/1891
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/[email protected].1
uses: actions/[email protected].7
with:
fetch-depth: 0
# Check https://github.com/livepeer/go-livepeer/pull/1891
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/git.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ concurrency:

jobs:
block-fixup:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/[email protected].1
uses: actions/[email protected].7

- name: Block fixup commit merge
uses: 13rac1/[email protected]
Loading
Loading