ci: Pick up the right branches when building a windows image

Now we will pick up the right gstreamer branch + namespace when
building an image, and also the right (matching, if any) cerbero
branch + namespace.

This solves the bootstrapping issue when doing an image update that
requires coordination between gstreamer and cerbero.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5043>
This commit is contained in:
Nirbheek Chauhan 2023-07-13 15:38:50 +05:30 committed by GStreamer Marge Bot
parent cc6ccd881e
commit 585d719bd1
5 changed files with 54 additions and 14 deletions

View file

@ -180,14 +180,12 @@ windows amd64 docker:
- "2022" - "2022"
script: script:
# We need to pass an array and to resolve the env vars, so we can't use a variable: # We need to pass an array and to resolve the env vars, so we can't use a variable:
- $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH") - $DOCKER_BUILD_ARGS = @(`
"--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH", `
- "& ci/docker/windows/container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE $DOCKERFILE" "--build-arg", "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE", `
- | "--build-arg", "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" `
if (!($?)) { )
echo "Failed to build the image" - ci/docker/windows/container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE $DOCKERFILE
Exit 1
}
# ---- Preparation ----- # # ---- Preparation ----- #
@ -503,7 +501,7 @@ build vs2022 arm64:
--native-file ci/meson/vs2022-paths.ini --native-file ci/meson/vs2022-paths.ini
--native-file ci/meson/vs2022-x64-native.ini --native-file ci/meson/vs2022-x64-native.ini
build msys2 : build msys2:
extends: '.build windows' extends: '.build windows'
timeout: '60min' timeout: '60min'
script: script:

View file

@ -54,7 +54,7 @@ RUN C:\upgrade_msys2.ps1
RUN C:\msys64\msys2_shell.cmd -ucrt64 -defterm -here -no-start -use-full-path -lc 'pacman -S --noconfirm mingw-w64-ucrt-x86_64-toolchain ninja' RUN C:\msys64\msys2_shell.cmd -ucrt64 -defterm -here -no-start -use-full-path -lc 'pacman -S --noconfirm mingw-w64-ucrt-x86_64-toolchain ninja'
RUN python -m pip install meson==1.1.1 RUN python -m pip install meson==1.1.1 python-gitlab
RUN 'git config --global user.email "cirunner@gstreamer.freedesktop.org"; git config --global user.name "GStreamer CI system"' RUN 'git config --global user.email "cirunner@gstreamer.freedesktop.org"; git config --global user.name "GStreamer CI system"'
@ -62,9 +62,15 @@ COPY install_rust.ps1 C:\
RUN C:\install_rust.ps1 RUN C:\install_rust.ps1
ARG DEFAULT_BRANCH="main" ARG DEFAULT_BRANCH="main"
ARG CI_PROJECT_NAMESPACE
ARG CI_COMMIT_REF_NAME
ENV CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE
ENV CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME
COPY prepare_gst_env.ps1 C:\ COPY prepare_gst_env.ps1 C:\
RUN C:\prepare_gst_env.ps1 RUN C:\prepare_gst_env.ps1
ENV CI="true"
COPY get_cerbero_clone_args.py C:\
COPY prepare_cerbero_env.sh C:\ COPY prepare_cerbero_env.sh C:\
RUN C:\msys64\msys2_shell.cmd -ucrt64 -defterm -here -no-start -use-full-path -lc "C:/prepare_cerbero_env.sh" RUN C:\msys64\msys2_shell.cmd -ucrt64 -defterm -here -no-start -use-full-path -lc "C:/prepare_cerbero_env.sh"

View file

@ -0,0 +1,27 @@
#!/usr/bin/python3
import os
import gitlab
server = 'https://gitlab.freedesktop.org'
gl = gitlab.Gitlab(server)
branch = os.environ.get('DEFAULT_BRANCH', 'main')
project = f'gstreamer/cerbero'
# We do not want to run on (often out of date) user upstream branch
if os.environ["CI_COMMIT_REF_NAME"] != os.environ['DEFAULT_BRANCH']:
try:
try_project = f'{os.environ["CI_PROJECT_NAMESPACE"]}/cerbero'
match_branch = os.environ["CI_COMMIT_REF_NAME"]
# Search for matching branches, return only if the branch name matches
# exactly
proj = gl.projects.get(try_project)
for b in proj.branches.list(search=match_branch, iterator=True):
if match_branch == b.name:
project = try_project
branch = b.name
break
except gitlab.exceptions.GitlabGetError:
pass
print(f'-b {branch} {server}/{project}', end='')

View file

@ -2,8 +2,12 @@
set -eux set -eux
cd C:/ # Clone `-b main gstreamer/cerbero` by default, but if running on a gstreamer
git clone -b ${DEFAULT_BRANCH} https://gitlab.freedesktop.org/gstreamer/cerbero.git C:/cerbero # branch in another namespace that has a corresponding cerbero branch by the
# same name, clone that instead.
clone_args="$(py -3 C:/get_cerbero_clone_args.py)"
echo "Cloning Cerbero using $clone_args"
git clone $clone_args C:/cerbero
cd C:/cerbero cd C:/cerbero
echo 'local_sources="C:/cerbero/cerbero-sources"' > localconf.cbc echo 'local_sources="C:/cerbero/cerbero-sources"' > localconf.cbc

View file

@ -14,8 +14,13 @@ $secure_pw = ConvertTo-SecureString $plaintext_pw -AsPlainText -Force
C:\msys64\ucrt64\bin\openssl.exe pkcs12 -export -nokeys -out $env:TEMP\certs.pfx -in $cert_pem -passout pass:$plaintext_pw C:\msys64\ucrt64\bin\openssl.exe pkcs12 -export -nokeys -out $env:TEMP\certs.pfx -in $cert_pem -passout pass:$plaintext_pw
Import-PfxCertificate -Password $secure_pw -CertStoreLocation Cert:\LocalMachine\Root -FilePath $env:TEMP\certs.pfx Import-PfxCertificate -Password $secure_pw -CertStoreLocation Cert:\LocalMachine\Root -FilePath $env:TEMP\certs.pfx
Write-Host "Cloning GStreamer" $namespace = "gstreamer"
git clone -b $env:DEFAULT_BRANCH https://gitlab.freedesktop.org/gstreamer/gstreamer.git C:\gstreamer if ($env:CI_COMMIT_REF_NAME -ne $env:DEFAULT_BRANCH) {
$namespace = $env:CI_PROJECT_NAMESPACE
}
$url = "https://gitlab.freedesktop.org/$namespace/gstreamer.git"
Write-Host "Cloning GStreamer branch $env:CI_COMMIT_REF_NAME from $url"
git clone -b $env:CI_COMMIT_REF_NAME $url C:\gstreamer
# download the subprojects to try and cache them # download the subprojects to try and cache them
Write-Host "Downloading subprojects" Write-Host "Downloading subprojects"