[PATCH 0/2] gitlab: Adapt name of CI job building the web page to 'pages'

The subject is deliberately chosen so that it does not imply that we actually want to host libvirt.org via gitlab pages at this time. It's not possible as gitlab pages don't allow redirects to different domains: https://gitlab.com/gitlab-org/gitlab-pages/-/issues/601 The merit of this change was discussed here: https://gitlab.com/libvirt/libvirt-ocaml/-/merge_requests/23#note_1360494690 Along with this patch, a change to to the job deploying the page on libvirt.org will be needed. Peter Krempa (2): gitlab-ci: Configure website build to be published via gitlab pages docs: Add redirects configuration for gitlab pages .gitlab-ci.yml | 70 ++++++++++++++++++++++++++++++++++++------ docs/.gitlab_redirects | 38 +++++++++++++++++++++++ 2 files changed, 99 insertions(+), 9 deletions(-) create mode 100644 docs/.gitlab_redirects -- 2.40.0

Modify the build process of the web page to publish the contents of the web page also via gitlab pages. This is achieved by the following steps: - the artifact is now named 'pages' - on push to the default branch a new job 'pages' is used - otherwise the old job names are used Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab-ci.yml | 69 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a36c0ef18..df1074c518 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,22 +69,53 @@ include: - .gitlab_cross_build_job_local_env -# This artifact published by this job is downloaded by libvirt.org to -# be deployed to the web root: -# https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=webs... +# This job builds the website and publishes it in the following ways: +# - 'pages' +# - publishing for gitlab pages +# - done only on push to the default branch +# - 'website*' +# - for CI purposes +# - job name based on how it was invoked: +# - 'website_prebuilt_env' +# - when the CI runs on the container images build by the upstream libvirt project +# - 'website_local_env' +# - when run in locally-rebuilt environment +# +# The job exposes artifacts containing a directory named 'public'. +# +# 'libvirt.org' is currently populated from content got from: +# +# https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=page... +# +# which is unpacked and deployed to the web root. .website_job: script: - *script_variables - meson setup build --werror -Dsystem=true || (cat build/meson-logs/meson-log.txt && exit 1) - DESTDIR=$(pwd)/install ninja -C build install-web - - mv install/usr/share/doc/libvirt/html/ website + - mv install/usr/share/doc/libvirt/html/ public artifacts: - expose_as: 'Website' - name: 'website' - when: on_success - expire_in: 30 days + expose_as: 'pages' + name: 'pages' paths: - - website + - public + +pages: + extends: + - .website_job + needs: + - job: x86_64-almalinux-8-container + optional: true + variables: + NAME: almalinux-8 + stage: builds + image: $CI_REGISTRY/$RUN_UPSTREAM_NAMESPACE/libvirt/ci-$NAME:latest + before_script: + - cat /packages.txt + rules: + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + when: on_success + - when: never website_prebuilt_env: extends: @@ -95,6 +126,26 @@ website_prebuilt_env: optional: true variables: NAME: almalinux-8 + rules: + # forks: pushes to a branch when a pipeline run in upstream env is explicitly requested + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE_UPSTREAM_ENV' + when: on_success + + # upstream: other web/api/scheduled pipelines targeting the default branch + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' + when: on_success + + # upstream+forks: merge requests targeting the default branch, without CI changes + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + changes: + - ci/gitlab/container-templates.yml + - ci/containers/$NAME.Dockerfile + when: never + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + when: on_success + + # upstream+forks: that's all folks + - when: never website_local_env: extends: -- 2.40.0

Adapt the configuration of redirects from the server hosting libvirt.org The redirect to the 'libvirt-console-proxy' Golang module is not adapted as it doesn't exist on the current server. NOTES: - The redirects are currently configured for hosting via the 'gitlab.io/libvirt' URI. For hosting via custom domain it will need to be rewritten to drop the '/libvirt' prefixes. - gitlab pages doesn't currently support redirects to outside content, thus most of the redirects don't actually work: https://gitlab.com/gitlab-org/gitlab-pages/-/issues/601 - The redirects file is only installed in the webpage job but is not actually distributed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab-ci.yml | 1 + docs/.gitlab_redirects | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docs/.gitlab_redirects diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df1074c518..f7aaac4150 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -94,6 +94,7 @@ include: - meson setup build --werror -Dsystem=true || (cat build/meson-logs/meson-log.txt && exit 1) - DESTDIR=$(pwd)/install ninja -C build install-web - mv install/usr/share/doc/libvirt/html/ public + - cp docs/.gitlab_redirects public/_redirects artifacts: expose_as: 'pages' name: 'pages' diff --git a/docs/.gitlab_redirects b/docs/.gitlab_redirects new file mode 100644 index 0000000000..d61d0ee07d --- /dev/null +++ b/docs/.gitlab_redirects @@ -0,0 +1,38 @@ +# Redirects to golang module pages +/libvirt/libvirt-go /libvirt-go.html 200 +/libvirt/libvirt-go-xml /libvirt-go-xml.html 200 +/libvirt/go/libvirt /go/libvirt.html 200 +/libvirt/go/libvirtxml /go/libvirtxml.html 200 + +# Redirects to the download server +/libvirt/sources/* https://download.libvirt.org/:splat 301 +/libvirt/ruby/download/* https://download.libvirt.org/ruby/:splat 301 +/libvirt/maven2/* https://download.libvirt.org/maven2/:splat 301 + +# Redirects to subproject pages +/libvirt/ruby/* https://ruby.libvirt.org/:splat 301 +/libvirt/ocaml/* https://ocaml.libvirt.org/:splat 301 +/libvirt/php/* https://php.libvirt.org/:splat 301 +/libvirt/libvirt-appdev-guide-python/en-US/html/* https://libvirt.gitlab.io/libvirt-appdev-guide-python/:splat: 301 +/libvirt/java.html https://java.libvirt.org 301 +# Redirect to the proper javadoc directory on the subproject page +/libvirt/sources/java/javadoc/* https://java.libvirt.org/javadoc/:splat 301 + +# Redirects to the old gitweb server +/libvirt/git/* https://git.libvirt.org/:splat 301 + +# The above rules are adapted from the following set of 'mod_rewrite' rules used +# originally on libvirt.org: +# +# RewriteRule ^/libvirt-go$ /libvirt-go.html [L] +# RewriteRule ^/libvirt-go-xml$ /libvirt-go-xml.html [L] +# RewriteRule ^/go/libvirt$ /go/libvirt.html [L] +# RewriteRule ^/go/libvirtxml$ /go/libvirtxml.html [L] +# RewriteRule ^/sources/(.*) https://download.libvirt.org/$1 [L] +# RewriteRule ^/ruby/download/(.*) https://download.libvirt.org/ruby/$1 [L] +# RewriteRule ^/(maven2/.*) https://download.libvirt.org/$1 [L] +# RewriteRule ^/ocaml/(.*) https://ocaml.libvirt.org/$1 [L] +# RewriteRule ^/ruby/(.*) https://ruby.libvirt.org/$1 [L] +# RewriteRule ^/php/(.*) https://php.libvirt.org/$1 [L] +# RewriteRule ^/java.html https://java.libvirt.org [L] +# RewriteRule ^/docs/libvirt-appdev-guide-python/en-US/html/(.*) https://libvirt.gitlab.io/libvirt-appdev-guide-python/$1 [L] -- 2.40.0
participants (1)
-
Peter Krempa