Skip to content

Commit 2ce3957

Browse files
committed
Add a CI workflow checking if the links used for precompileds are working
1 parent 20be91d commit 2ce3957

2 files changed

Lines changed: 64 additions & 4 deletions

File tree

.github/workflows/check_links.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Check precompiled dependency links
2+
3+
on:
4+
schedule:
5+
- cron: "0 6 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
issues: write
10+
11+
jobs:
12+
check_links:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: erlef/setup-beam@v1
18+
with:
19+
otp-version: "27"
20+
elixir-version: "1.18"
21+
22+
- run: mix deps.get
23+
24+
- run: mix run scripts/check_links.exs
25+
26+
- name: Open issue on failure
27+
if: failure()
28+
uses: actions/github-script@v7
29+
with:
30+
script: |
31+
const title = "Broken precompiled dependency links";
32+
const open = await github.rest.issues.listForRepo({
33+
...context.repo,
34+
state: "open",
35+
labels: "broken-links",
36+
});
37+
if (open.data.length === 0) {
38+
await github.rest.issues.create({
39+
...context.repo,
40+
title,
41+
labels: ["broken-links"],
42+
body:
43+
"The daily link check failed - some precompiled dependency links " +
44+
"are broken. See the workflow run for the list of broken URLs: " +
45+
`${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
46+
});
47+
}

lib/membrane_precompiled_dependency_provider.ex

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ defmodule Membrane.PrecompiledDependencyProvider do
3939
Get URL of a precompiled build of given dependency for a platform from which this function is being
4040
called.
4141
42-
A specific version of the dependency can be provided with `:version` option or through config
42+
A specific version of the dependency can be provided with `:version` option or through config
4343
(see `t:version_config/0`). If provided in both ways, the config value will be taken.
4444
For generic dependencies this version needs to be the same as a release name from the
4545
repository of the precompiled dependency, but without the leading "v". By default the latest
4646
version is chosen.
47+
48+
The target platform can be overridden with the `:target` option (a map in the format returned
49+
by `Bundlex.get_target/0`). By default the platform from which this function is being called
50+
is used.
4751
"""
48-
@spec get_dependency_url(precompiled_dependency(), version: String.t()) ::
52+
@spec get_dependency_url(precompiled_dependency(), version: String.t(), target: map()) ::
4953
String.t() | nil
5054
def get_dependency_url(dependency, options \\ [])
5155

@@ -55,7 +59,7 @@ defmodule Membrane.PrecompiledDependencyProvider do
5559
generic_url_prefix =
5660
get_generic_dependency_url_prefix(:ffmpeg, version)
5761

58-
case Bundlex.get_target() do
62+
case resolve_target(options) do
5963
%{abi: "musl"} ->
6064
nil
6165

@@ -89,7 +93,7 @@ defmodule Membrane.PrecompiledDependencyProvider do
8993
generic_url_prefix =
9094
get_generic_dependency_url_prefix(generic_dependency, version)
9195

92-
case Bundlex.get_target() do
96+
case resolve_target(options) do
9397
%{abi: "musl"} ->
9498
nil
9599

@@ -110,6 +114,15 @@ defmodule Membrane.PrecompiledDependencyProvider do
110114
end
111115
end
112116

117+
@doc false
118+
@spec known_ffmpeg_versions() :: [String.t()]
119+
def known_ffmpeg_versions(), do: ["6.0.1", "6.1.3", "7.1.2", "8.0", "latest"]
120+
121+
@spec resolve_target(version: String.t(), target: map()) :: map()
122+
defp resolve_target(opts) do
123+
Keyword.get_lazy(opts, :target, &Bundlex.get_target/0)
124+
end
125+
113126
@spec resolve_version(precompiled_dependency(), version: String.t()) :: String.t()
114127
defp resolve_version(dependency, opts) do
115128
opts_version = Keyword.get(opts, :version, "latest")

0 commit comments

Comments
 (0)