[PATCH v2 0/3] Prepare webpage for hosting via gitlab pages

Diff to v1: - improve and simplify 'pages' job - fix redirect to 'maven' As the progress on the gitlab feature we need to do this seems good: https://gitlab.com/gitlab-org/gitlab-pages/-/issues/601 this series prepares the libvirt project to do the hosting and will allow us to validate it before switching over once the feature is enabled. Patches 1/3 and 2/3 can be pushed right away: - Patch 1/4 prepares the job to publish the page (currently via the libvirt.gitlab.io/libvirt URL each project gets automatically - Patch 2/4 adds the '_redirects' file which is populated from adapted 'mod_rewrite' rules from the current server. This file serves for validation of the rules and will allow us to validate them before switching over The last patch is needed for the final switchover as the redirects need to be modified slightly to work properly. Peter Krempa (3): gitlab-ci: Configure website build to be published via gitlab pages docs: Add redirects configuration for gitlab pages docs: gitlab redirects: Drop '/libvirt' prefix for hosting the web through gitlab pages .gitlab-ci.yml | 19 +++++++++++++++ .gitlab_pages_redirects | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .gitlab_pages_redirects -- 2.43.0

On pushes to master publish the webpage (built in the 'website_job' job) via gitlab pages. The 'pages' job uses the default image that gitlab assumes as it's consuming artifacts from an existing job and naming them properly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab-ci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 81433652ae..b0e2724706 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,6 +6,7 @@ stages: - builds - integration_tests - sanity_checks + - pages .script_variables: &script_variables | export CCACHE_BASEDIR="$(pwd)" @@ -85,6 +86,23 @@ website_job: NAME: almalinux-8 TARGET_BASE_IMAGE: docker.io/library/almalinux:8 +# On push to master publish the website from 'website_job' via gitlab pages +pages: + stage: pages + script: + - mv website public + dependencies: + - website_job + rules: + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + when: on_success + - when: never + artifacts: + expose_as: 'pages' + name: 'pages' + paths: + - public + .codestyle_job: stage: sanity_checks needs: -- 2.43.0

On Fri, Jan 19, 2024 at 03:33:42PM +0100, Peter Krempa wrote:
On pushes to master publish the webpage (built in the 'website_job' job) via gitlab pages. The 'pages' job uses the default image that gitlab assumes as it's consuming artifacts from an existing job and naming them properly.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab-ci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

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. - The validity of the redirects can be checked by visiting: https://libvirt.gitlab.io/_redirects Having them installed allows us to validate them before we'll be switching to use gitlab pages completely. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab-ci.yml | 1 + .gitlab_pages_redirects | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .gitlab_pages_redirects diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b0e2724706..b879b88f74 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,6 +91,7 @@ pages: stage: pages script: - mv website public + - cp .gitlab_pages_redirects public/_redirects dependencies: - website_job rules: diff --git a/.gitlab_pages_redirects b/.gitlab_pages_redirects new file mode 100644 index 0000000000..baa94384ba --- /dev/null +++ b/.gitlab_pages_redirects @@ -0,0 +1,54 @@ +# 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/org/libvirt* https://download.libvirt.org/maven2/org/libvirt/: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 from old gitweb location (see below) +/libvirt/git https://gitlab.com/libvirt/ 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/org/libvirt.*) 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] +# RewriteRule ^/git https://gitlab.com/libvirt/ [L] +# +# Redirect replacing 'gitweb'. The 'gitweb' interface was originally replaced +# by the following redirect condition: +# +# RewriteCond %{QUERY_STRING} p=([-a-zA-Z0-9]+).git +# RewriteRule ^/git/$ https://gitlab.com/libvirt/%1 [L] +# +# That unfortunately can't be represented in gitlab redirects as it doesn't +# support redirects based on query strings. Given that the above redirect broke +# most gitweb links anyways, due to handling only the 'p=' argument, git gitlab +# redirect will break the rest of them. +# +# The following rule was dropped as the page never existed: +# +# RewriteRule ^/libvirt-console-proxy$ /libvirt-console-proxy.html [L] -- 2.43.0

On Fri, Jan 19, 2024 at 03:33:43PM +0100, Peter Krempa wrote:
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.
- The validity of the redirects can be checked by visiting:
https://libvirt.gitlab.io/_redirects
Having them installed allows us to validate them before we'll be switching to use gitlab pages completely.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab-ci.yml | 1 + .gitlab_pages_redirects | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .gitlab_pages_redirects
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

The prefix needs to be dropped for the redirects to work properly once hosting 'libvirt.org' via gitlab pages. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab_pages_redirects | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.gitlab_pages_redirects b/.gitlab_pages_redirects index baa94384ba..97ebcede77 100644 --- a/.gitlab_pages_redirects +++ b/.gitlab_pages_redirects @@ -1,25 +1,25 @@ # 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 +/libvirt-go /libvirt-go.html 200 +/libvirt-go-xml /libvirt-go-xml.html 200 +/go/libvirt /go/libvirt.html 200 +/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/org/libvirt* https://download.libvirt.org/maven2/org/libvirt/:splat 301 +/sources/* https://download.libvirt.org/:splat 301 +/ruby/download/* https://download.libvirt.org/ruby/:splat 301 +/maven2/org/libvirt* https://download.libvirt.org/maven2/org/libvirt/: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 +/ruby/* https://ruby.libvirt.org/:splat 301 +/ocaml/* https://ocaml.libvirt.org/:splat 301 +/php/* https://php.libvirt.org/:splat 301 +/libvirt-appdev-guide-python/en-US/html/* https://libvirt.gitlab.io/libvirt-appdev-guide-python/:splat: 301 +/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 +/sources/java/javadoc/* https://java.libvirt.org/javadoc/:splat 301 # Redirects from old gitweb location (see below) -/libvirt/git https://gitlab.com/libvirt/ 301 +/git https://gitlab.com/libvirt/ 301 # The above rules are adapted from the following set of 'mod_rewrite' rules used # originally on libvirt.org: -- 2.43.0

On Fri, Jan 19, 2024 at 03:33:44PM +0100, Peter Krempa wrote:
The prefix needs to be dropped for the redirects to work properly once hosting 'libvirt.org' via gitlab pages.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab_pages_redirects | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrangé
-
Peter Krempa