[tracker/wip/carlosg/test: 5/5] ci: Add intermediate job to build the website before deploying




commit 8187bacd119b1f8ab2ab1d76cccce99ac7f845e5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Aug 29 17:12:58 2021 +0200

    ci: Add intermediate job to build the website before deploying
    
    This job allows us to check website output in merge requests, before
    having it deployed to the gitlab pages.
    
    The script that generates the website HTML has been changed to allow
    specifying the output directory, so it's not always the "public"
    special directory.

 .gitlab-ci.yml        | 38 +++++++++++++++++++++++++-------------
 docs/website/build.py |  6 ++++--
 2 files changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8bb04fcda..0fb0d6515 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -321,6 +321,29 @@ test-alpine@x86_64:
     - build-alpine-edge@x86_64
   <<: *test
 
+test-website:
+  extends:
+    - .fdo.distribution-image@fedora
+    - .tracker.fedora:34@x86_64
+  stage: test
+  script:
+    - export install_prefix="$(pwd)/tracker-install"
+    # Build tracker and install.
+    - mkdir website-build; pushd website-build; meson .. --prefix="$install_prefix"; ninja; ninja install; 
popd
+    # Build tracker-miners and install any documentation from there as well.
+    - .gitlab-ci/checkout-tracker-miners.sh
+    - pushd extra/tracker-miners; mkdir build; pushd build; env 
PKG_CONFIG_PATH="$install_prefix/lib64/pkgconfig" meson .. --prefix="$install_prefix"; ninja install; popd; 
popd
+    # Generate the website using mkdocs.
+    - |
+      export tracker_commit=$CI_COMMIT_SHA
+      export tracker_miners_commit=$(git -C ./extra/tracker-miners rev-parse HEAD)
+      ./docs/website/build.py --output=website --api-docs="$install_prefix/share/gtk-doc/html" 
--tracker-commit=${tracker_commit} --man-pages ./docs/manpages/*.txt 
./extra/tracker-miners/docs/manpages/*.txt
+  artifacts:
+    paths:
+      - website
+  needs:
+    - build-fedora-container@x86_64
+
 coverage-analysis:
   extends:
     - .fdo.distribution-image@fedora
@@ -389,22 +412,11 @@ pages:
     - .tracker.fedora:34@x86_64
   stage: website
   script:
-    - export install_prefix="$(pwd)/tracker-install"
-    # Build tracker and install.
-    - mkdir website-build; pushd website-build; meson .. --prefix="$install_prefix"; ninja; ninja install; 
popd
-    # Build tracker-miners and install any documentation from there as well.
-    - .gitlab-ci/checkout-tracker-miners.sh
-    - pushd extra/tracker-miners; mkdir build; pushd build; env 
PKG_CONFIG_PATH="$install_prefix/lib64/pkgconfig" meson .. --prefix="$install_prefix"; ninja install; popd; 
popd
-    # Generate the website using mkdocs.
-    - |
-      export tracker_commit=$CI_COMMIT_SHA
-      export tracker_miners_commit=$(git -C ./extra/tracker-miners rev-parse HEAD)
-      ./docs/website/build.py --api-docs="$install_prefix/share/gtk-doc/html" 
--tracker-commit=${tracker_commit} --man-pages ./docs/manpages/*.txt 
./extra/tracker-miners/docs/manpages/*.txt
+    - mv website public
   artifacts:
     paths:
       - public
   needs:
-    - build-fedora-container@x86_64
+    - test-website
   only:
     - master
-    - /^sam\/website.*$/
diff --git a/docs/website/build.py b/docs/website/build.py
index 599021377..629c07b33 100755
--- a/docs/website/build.py
+++ b/docs/website/build.py
@@ -32,7 +32,6 @@ import tempfile
 
 log = logging.getLogger('build.py')
 
-output_path = pathlib.Path('public')
 website_root = pathlib.Path(__file__).parent
 docs_root = website_root.parent
 source_root = docs_root.parent
@@ -45,6 +44,8 @@ xmlto = shutil.which('xmlto')
 def argument_parser():
     parser = argparse.ArgumentParser(
         description="Tracker website build script")
+    parser.add_argument('--output', required=True, metavar='OUTPUT',
+                        help="Output directory")
     parser.add_argument('--debug', dest='debug', action='store_true',
                         help="Enable detailed logging to stderr")
     parser.add_argument('--api-docs', required=True, metavar='PATH',
@@ -143,6 +144,7 @@ def tmpdir():
 
 def main():
     args = argument_parser().parse_args()
+    output_path = pathlib.Path(args.output)
 
     if args.debug:
         logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
@@ -205,7 +207,7 @@ def main():
     for filename in apidocs_dest.rglob('*.html'):
         add_apidocs_header(text, filename)
 
-    log.info("Documentation available in public/ directory.")
+    log.info("Documentation available in %s/ directory.", args.output)
 
 
 try:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]