Skip to content

Commit d16b4da

Browse files
committed
workflow: add job summary
1 parent 5fbeb6e commit d16b4da

File tree

2 files changed

+80
-8
lines changed

2 files changed

+80
-8
lines changed

.github/workflows/mpv.yml

+76-4
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
needs: params
114114
runs-on: ubuntu-latest
115115
container:
116-
image: archlinux:base-devel
116+
image: archlinux/archlinux:base-devel
117117
strategy:
118118
matrix:
119119
bit: [64]
@@ -249,6 +249,78 @@ jobs:
249249
name: ${{ env.ffmpeg_name }}
250250
path: mpv-winbuild-cmake/release/${{ env.ffmpeg_name }}.7z
251251

252+
253+
- name: "Job summary"
254+
uses: actions/github-script@v6
255+
continue-on-error: true
256+
if: ${{ always() }}
257+
with:
258+
script: |
259+
const path = require('path');
260+
const { readdirSync,existsSync } = require('fs');
261+
const myExec = async (command, args = null) => await exec.getExecOutput(command,args,{silent: true}).then(result => result.stdout.trim());
262+
263+
const toolchainDir = path.resolve("mpv-winbuild-cmake");
264+
const workdir = path.resolve(toolchainDir,"src_packages");
265+
const isGitSync = dirname => existsSync(path.join(workdir, dirname, '.git'));
266+
267+
const getGithubUrl = (hash,remote) => remote.replace(/\.git$/,"") + `/commit/${hash}`;
268+
const getGitlabUrl = (hash,remote) => remote.replace(/\.git$/,"") + `/-/commit/${hash}`;
269+
const getBitbucketUrl = (hash,remote) => remote.replace(/\.git$/,"") + `/commits/${hash}`;
270+
const getGoogleSourceUrl = (hash,remote) => remote + `/+/${hash}`;
271+
const gethGitVideolanUrl = (hash,remote) => remote.replace(/\/git\//,"/?p=") + `;a=commit;h=${hash}`;
272+
const getCgitUrl = (hash,remote) => remote + `/commit/?id=${hash}`;
273+
function getCommitUrl(hash,remote) {
274+
let url = "";
275+
switch (true) {
276+
case /github\.com/.test(remote):
277+
url = getGithubUrl(hash,remote);
278+
break;
279+
case /(gitlab\.com|code\.videolan\.org|gitlab\.gnome\.org)/.test(remote):
280+
url = getGitlabUrl(hash,remote);
281+
break;
282+
case /bitbucket\.org/.test(remote):
283+
url = getBitbucketUrl(hash,remote);
284+
break;
285+
case /googlesource\.com/.test(remote):
286+
url = getGoogleSourceUrl(hash,remote);
287+
break;
288+
case /git\.videolan\.org/.test(remote):
289+
url = gethGitVideolanUrl(hash,remote);
290+
break;
291+
case /git\.libssh\.org/.test(remote):
292+
url = getCgitUrl(hash,remote);
293+
break;
294+
default:
295+
url = remote;
296+
break;
297+
}
298+
return url;
299+
}
300+
301+
const dirs = readdirSync(workdir, { withFileTypes: true }).filter(dirent => dirent.isDirectory() && isGitSync(dirent.name) ).map(dirent => path.join(workdir, dirent.name));
302+
let packages_table = [[{data: 'Package', header: true}, {data: 'Local commit', header: true}, {data: 'Status', header: true}, {data: 'Remote commit', header: true}]];
303+
for (let dir of dirs) {
304+
let local_hash = await myExec(`git -C ${dir} rev-parse --short=7 HEAD`);
305+
let remote_branch = await myExec(`git -C ${dir} rev-parse --abbrev-ref HEAD@{upstream}`);
306+
let remote_hash = await myExec(`git -C ${dir} rev-parse ${remote_branch}`);
307+
let status = await myExec(`git -C ${dir} status -sb`).then(s => s.split("\n",1)[0].replace(/^## */,""));
308+
let remote = await myExec(`git -C ${dir} config --get remote.origin.url`);
309+
let url = getCommitUrl(remote_hash, remote);
310+
let package_name = path.basename(dir);
311+
packages_table.push([package_name, local_hash, status, `<a href="${url}">${remote_hash.slice(0,7)}</a>`]);
312+
}
313+
let toolchain_hash = await myExec(`git -C ${toolchainDir} rev-parse HEAD`);
314+
let toolchain_remote = await myExec(`git -C ${toolchainDir} config --get remote.origin.url`);
315+
let toolchain_url = getCommitUrl(toolchain_hash, toolchain_remote);
316+
317+
await core.summary
318+
.addHeading('Basic Info')
319+
.addRaw(`toolchain: <a href="${toolchain_url}">${toolchain_hash.slice(0,7)}</a>`,true)
320+
.addHeading('Packages Version')
321+
.addTable(packages_table)
322+
.write();
323+
252324
publish_release:
253325
name: Publish release
254326
needs: [build_mpv,params]
@@ -293,7 +365,7 @@ jobs:
293365
artifacts: "artifacts/*/*.7z"
294366
commit: version
295367
name: "MPV_OWN ${{ env.long_time }}"
296-
body: "**MPV git commit**: https://github.com/dyphire/mpv/commit/${{ fromJson(needs.params.outputs.params).sha }}\n- merged: https://github.com/mpv-player/mpv/pull/8865, https://github.com/mpv-player/mpv/pull/9360, https://github.com/mpv-player/mpv/pull/9621, https://github.com/mpv-player/mpv/pull/9664, https://github.com/mpv-player/mpv/pull/9856\n\n**Test**: Build with libass from [dyphire/libass_dev](https://github.com/dyphire/libass/tree/dev)\n- Ass: it can fix some problems for scaled with PlayResX\n\n**Remember**: This is not perfect\n**Build Time**: ${{ env.long_time }}"
368+
body: "**MPV git commit**: https://github.com/dyphire/mpv/commit/${{ fromJson(needs.params.outputs.params).sha }}\n- merged: https://github.com/mpv-player/mpv/pull/8865, https://github.com/mpv-player/mpv/pull/9360, https://github.com/mpv-player/mpv/pull/9621, https://github.com/mpv-player/mpv/pull/9664, https://github.com/mpv-player/mpv/pull/9856\n\n**Test**: Build with libass from [dyphire/libass_dev](https://github.com/dyphire/libass/tree/dev)\n- Ass: it can fix some problems for scaled with PlayResX\n\n**Remember**: This is not perfect\n**Build Details**: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}\n**Build Time**: ${{ env.long_time }}"
297369
tag: "mpv_own-${{ env.short_time }}"
298370
allowUpdates: true
299371
prerelease: false
@@ -305,7 +377,7 @@ jobs:
305377
artifacts: "artifacts/*/*.7z"
306378
commit: version
307379
name: "MPV_OWN ${{ env.long_time }}"
308-
body: "**MPV git commit**: https://github.com/mpv-player/mpv/commit/${{ fromJson(needs.params.outputs.params).sha }}\n**Test**: Build with libass from [dyphire/libass_dev](https://github.com/dyphire/libass/tree/dev)\n- Ass: it can fix some problems for scaled with PlayResX\n\n**Remember**: This is not perfect\n**Build Time**: ${{ env.long_time }}"
380+
body: "**MPV git commit**: https://github.com/mpv-player/mpv/commit/${{ fromJson(needs.params.outputs.params).sha }}\n**Test**: Build with libass from [dyphire/libass_dev](https://github.com/dyphire/libass/tree/dev)\n- Ass: it can fix some problems for scaled with PlayResX\n\n**Remember**: This is not perfect\n**Build Details**: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}\n**Build Time**: ${{ env.long_time }}"
309381
tag: "mpv_own-${{ env.short_time }}"
310382
allowUpdates: true
311383
prerelease: false
@@ -317,7 +389,7 @@ jobs:
317389
artifacts: "artifacts/*/*.7z"
318390
commit: version
319391
name: "MPV ${{ env.long_time }}"
320-
body: "**MPV git commit**: https://github.com/mpv-player/mpv/commit/${{ fromJson(needs.params.outputs.params).sha }}\n**Build Time**: ${{ env.long_time }}"
392+
body: "**MPV git commit**: https://github.com/mpv-player/mpv/commit/${{ fromJson(needs.params.outputs.params).sha }}\n**Build Details**: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}\n**Build Time**: ${{ env.long_time }}"
321393
tag: "mpv-${{ env.short_time }}"
322394
allowUpdates: true
323395
prerelease: false

build.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ build() {
3434

3535
cmake -DTARGET_ARCH=$arch-w64-mingw32 -DALWAYS_REMOVE_BUILDFILES=ON -DSINGLE_SOURCE_LOCATION=$srcdir -G Ninja -H$gitdir -B$buildroot/build$bit
3636
ninja -C $buildroot/build$bit download || true
37-
if [[ "$(ls -A $buildroot/build$bit/install/bin)" ]]; then
38-
ninja -C $buildroot/build$bit update
39-
else
37+
if [[ ! "$(ls -A $buildroot/build$bit/install/bin)" ]]; then
4038
ninja -C $buildroot/build$bit gcc
4139
fi
40+
ninja -C $buildroot/build$bit update
4241
ninja -C $buildroot/build$bit mpv-fullclean
43-
ninja -C $buildroot/build$bit mpv || ninja -C $buildroot/build$bit mpv || ninja -C $buildroot/build$bit mpv
42+
ninja -C $buildroot/build$bit libjxl && ninja -C $buildroot/build$bit vulkan
43+
ninja -C $buildroot/build$bit mpv || ninja -C $buildroot/build$bit mpv
4444
if [ -d $buildroot/build$bit/mpv-$arch* ] ; then
4545
echo "Successfully compiled $bit-bit. Continue"
4646
else

0 commit comments

Comments
 (0)